[cfe-commits] r136410 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp

Douglas Gregor dgregor at apple.com
Thu Jul 28 15:16:57 PDT 2011


Author: dgregor
Date: Thu Jul 28 17:16:57 2011
New Revision: 136410

URL: http://llvm.org/viewvc/llvm-project?rev=136410&view=rev
Log:
Use local-to-global mapping appropriately for macro definitions in the ASTReader

Modified:
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=136410&r1=136409&r2=136410&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jul 28 17:16:57 2011
@@ -1603,6 +1603,17 @@
   /// \brief Retrieve the macro definition with the given ID.
   MacroDefinition *getMacroDefinition(serialization::MacroID ID);
 
+  /// \brief Retrieve the global macro definition ID that corresponds to the
+  /// local macro definition ID within a given module.
+  serialization::MacroID getGlobalMacroDefinitionID(Module &M, 
+                                                    unsigned LocalID);
+
+  /// \brief Deserialize a macro definition that is local to the given
+  /// module.
+  MacroDefinition *getLocalMacroDefinition(Module &M, unsigned LocalID) {
+    return getMacroDefinition(getGlobalMacroDefinitionID(M, LocalID));
+  }
+  
   /// \brief Retrieve the AST context that this AST reader supplements.
   ASTContext *getContext() { return Context; }
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=136410&r1=136409&r2=136410&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Jul 28 17:16:57 2011
@@ -742,6 +742,9 @@
   
 public:
   /// \brief Pair of begin/end iterators for DeclIDs.
+  ///
+  /// Note that these declaration IDs are local to the module that contains this
+  /// particular lookup t
   typedef std::pair<DeclID *, DeclID *> data_type;
 
   /// \brief Special internal key for declaration names.
@@ -1504,7 +1507,7 @@
       if (NextIndex + 1 == Record.size() && PP->getPreprocessingRecord()) {
         // We have a macro definition. Load it now.
         PP->getPreprocessingRecord()->RegisterMacroDefinition(Macro,
-                                        getMacroDefinition(Record[NextIndex]));
+              getLocalMacroDefinition(F, Record[NextIndex]));
       }
 
       ++NumMacrosRead;
@@ -1574,7 +1577,7 @@
       new (PPRec) MacroExpansion(getLocalIdentifier(F, Record[3]),
                                  SourceRange(ReadSourceLocation(F, Record[1]),
                                              ReadSourceLocation(F, Record[2])),
-                                 getMacroDefinition(Record[4]));
+                                 getLocalMacroDefinition(F, Record[4]));
     PPRec.setLoadedPreallocatedEntity(Record[0], ME);
     return ME;
   }
@@ -1864,6 +1867,11 @@
   return File;
 }
 
+MacroID ASTReader::getGlobalMacroDefinitionID(Module &M, unsigned LocalID) {
+  // FIXME: Local-to-global mapping
+  return LocalID;
+}
+
 /// \brief If we are loading a relocatable PCH file, and the filename is
 /// not an absolute path, add the system root to the beginning of the file
 /// name.





More information about the cfe-commits mailing list