]> granicus.if.org Git - clang/commitdiff
Remove unused tracking of owning module for MacroInfo objects.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 12 May 2017 23:40:52 +0000 (23:40 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 12 May 2017 23:40:52 +0000 (23:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302966 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/MacroInfo.h
include/clang/Lex/Preprocessor.h
lib/Lex/MacroInfo.cpp
lib/Lex/PPDirectives.cpp
lib/Lex/Preprocessor.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp

index 44b7b2e4a474b5429ecb2a5318857e4b311a973b..7da1e7b41ab8d96b6d1e7ffbaaaa9413398b41ba 100644 (file)
@@ -105,9 +105,6 @@ class MacroInfo {
   /// \brief Must warn if the macro is unused at the end of translation unit.
   bool IsWarnIfUnused : 1;
 
-  /// \brief Whether this macro info was loaded from an AST file.
-  bool FromASTFile : 1;
-
   /// \brief Whether this macro was used as header guard.
   bool UsedForHeaderGuard : 1;
 
@@ -264,34 +261,16 @@ public:
     IsDisabled = true;
   }
 
-  /// \brief Determine whether this macro info came from an AST file (such as
-  /// a precompiled header or module) rather than having been parsed.
-  bool isFromASTFile() const { return FromASTFile; }
-
   /// \brief Determine whether this macro was used for a header guard.
   bool isUsedForHeaderGuard() const { return UsedForHeaderGuard; }
 
   void setUsedForHeaderGuard(bool Val) { UsedForHeaderGuard = Val; }
 
-  /// \brief Retrieve the global ID of the module that owns this particular
-  /// macro info.
-  unsigned getOwningModuleID() const {
-    if (isFromASTFile())
-      return *(const unsigned *)(this + 1);
-
-    return 0;
-  }
-
   void dump() const;
 
 private:
   unsigned getDefinitionLengthSlow(const SourceManager &SM) const;
 
-  void setOwningModuleID(unsigned ID) {
-    assert(isFromASTFile());
-    *(unsigned *)(this + 1) = ID;
-  }
-
   friend class Preprocessor;
 };
 
index 0e3f563785d405e8fe7ade4b31afe85408b67f95..114bf70ad59aa85402e8430103cacf2feb8ac640 100644 (file)
@@ -644,14 +644,6 @@ class Preprocessor {
   /// of that list.
   MacroInfoChain *MIChainHead;
 
-  struct DeserializedMacroInfoChain {
-    MacroInfo MI;
-    unsigned OwningModuleID; // MUST be immediately after the MacroInfo object
-                     // so it can be accessed by MacroInfo::getOwningModuleID().
-    DeserializedMacroInfoChain *Next;
-  };
-  DeserializedMacroInfoChain *DeserialMIChainHead;
-
   void updateOutOfDateIdentifier(IdentifierInfo &II) const;
 
 public:
@@ -1669,10 +1661,6 @@ public:
   /// \brief Allocate a new MacroInfo object with the provided SourceLocation.
   MacroInfo *AllocateMacroInfo(SourceLocation L);
 
-  /// \brief Allocate a new MacroInfo object loaded from an AST file.
-  MacroInfo *AllocateDeserializedMacroInfo(SourceLocation L,
-                                           unsigned SubModuleID);
-
   /// \brief Turn the specified lexer token into a fully checked and spelled
   /// filename, e.g. as an operand of \#include. 
   ///
@@ -1764,9 +1752,6 @@ private:
   /// macro name.
   void updateModuleMacroInfo(const IdentifierInfo *II, ModuleMacroInfo &Info);
 
-  /// \brief Allocate a new MacroInfo object.
-  MacroInfo *AllocateMacroInfo();
-
   DefMacroDirective *AllocateDefMacroDirective(MacroInfo *MI,
                                                SourceLocation Loc);
   UndefMacroDirective *AllocateUndefMacroDirective(SourceLocation UndefLoc);
index bec434085e3a232d8705ad382c960f8bb6cf1d6e..1e5deeb1919b5383fd1c4eeae992dcd4c80fda3d 100644 (file)
@@ -29,7 +29,6 @@ MacroInfo::MacroInfo(SourceLocation DefLoc)
     IsUsed(false),
     IsAllowRedefinitionsWithoutWarning(false),
     IsWarnIfUnused(false),
-    FromASTFile(false),
     UsedForHeaderGuard(false) {
 }
 
@@ -137,7 +136,6 @@ LLVM_DUMP_METHOD void MacroInfo::dump() const {
   if (IsAllowRedefinitionsWithoutWarning)
     Out << " allow_redefinitions_without_warning";
   if (IsWarnIfUnused) Out << " warn_if_unused";
-  if (FromASTFile) Out << " imported";
   if (UsedForHeaderGuard) Out << " header_guard";
 
   Out << "\n    #define <macro>";
index 06fee8e5b0a8b9bb92db9665d84f8438531107b3..faf8809e4eb4f647ebd18e2b4a8eb9a7a6b63cd8 100644 (file)
@@ -54,35 +54,12 @@ using namespace clang;
 // Utility Methods for Preprocessor Directive Handling.
 //===----------------------------------------------------------------------===//
 
-MacroInfo *Preprocessor::AllocateMacroInfo() {
-  MacroInfoChain *MIChain = BP.Allocate<MacroInfoChain>();
-  MIChain->Next = MIChainHead;
+MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) {
+  auto *MIChain = new (BP) MacroInfoChain{L, MIChainHead};
   MIChainHead = MIChain;
   return &MIChain->MI;
 }
 
-MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) {
-  MacroInfo *MI = AllocateMacroInfo();
-  new (MI) MacroInfo(L);
-  return MI;
-}
-
-MacroInfo *Preprocessor::AllocateDeserializedMacroInfo(SourceLocation L,
-                                                       unsigned SubModuleID) {
-  static_assert(alignof(MacroInfo) >= sizeof(SubModuleID),
-                "alignment for MacroInfo is less than the ID");
-  DeserializedMacroInfoChain *MIChain =
-      BP.Allocate<DeserializedMacroInfoChain>();
-  MIChain->Next = DeserialMIChainHead;
-  DeserialMIChainHead = MIChain;
-
-  MacroInfo *MI = &MIChain->MI;
-  new (MI) MacroInfo(L);
-  MI->FromASTFile = true;
-  MI->setOwningModuleID(SubModuleID);
-  return MI;
-}
-
 DefMacroDirective *Preprocessor::AllocateDefMacroDirective(MacroInfo *MI,
                                                            SourceLocation Loc) {
   return new (BP) DefMacroDirective(MI, Loc);
index e409ab03653507934b8124cb3cccae6a4bb340a1..dce8c1efda23d477652d24a81e54784fd842a460 100644 (file)
@@ -88,7 +88,7 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
       CurDirLookup(nullptr), CurLexerKind(CLK_Lexer),
       CurLexerSubmodule(nullptr), Callbacks(nullptr),
       CurSubmoduleState(&NullSubmoduleState), MacroArgCache(nullptr),
-      Record(nullptr), MIChainHead(nullptr), DeserialMIChainHead(nullptr) {
+      Record(nullptr), MIChainHead(nullptr) {
   OwnsHeaderSearch = OwnsHeaders;
   
   CounterValue = 0; // __COUNTER__ starts at 0.
@@ -169,11 +169,6 @@ Preprocessor::~Preprocessor() {
   std::fill(TokenLexerCache, TokenLexerCache + NumCachedTokenLexers, nullptr);
   CurTokenLexer.reset();
 
-  while (DeserializedMacroInfoChain *I = DeserialMIChainHead) {
-    DeserialMIChainHead = I->Next;
-    I->~DeserializedMacroInfoChain();
-  }
-
   // Free any cached MacroArgs.
   for (MacroArgs *ArgList = MacroArgCache; ArgList;)
     ArgList = ArgList->deallocate();
index 61b5a822c55200d9fad5ee0b81c835c8ce47eedd..ef8481488302435977b000b4da56347231335a83 100644 (file)
@@ -1534,9 +1534,8 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
         return Macro;
 
       unsigned NextIndex = 1; // Skip identifier ID.
-      SubmoduleID SubModID = getGlobalSubmoduleID(F, Record[NextIndex++]);
       SourceLocation Loc = ReadSourceLocation(F, Record, NextIndex);
-      MacroInfo *MI = PP.AllocateDeserializedMacroInfo(Loc, SubModID);
+      MacroInfo *MI = PP.AllocateMacroInfo(Loc);
       MI->setDefinitionEndLoc(ReadSourceLocation(F, Record, NextIndex));
       MI->setIsUsed(Record[NextIndex++]);
       MI->setUsedForHeaderGuard(Record[NextIndex++]);
index 8e4b217a44cd1bc9d530be0821a82115d3692e2a..b6c0cb2815fbf56ea372cc3fc8146b6b26655454 100644 (file)
@@ -2413,7 +2413,6 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
     }
 
     AddIdentifierRef(Name, Record);
-    Record.push_back(inferSubmoduleIDFromLocation(MI->getDefinitionLoc()));
     AddSourceLocation(MI->getDefinitionLoc(), Record);
     AddSourceLocation(MI->getDefinitionEndLoc(), Record);
     Record.push_back(MI->isUsed());