From: Douglas Gregor Date: Thu, 28 Jul 2011 22:16:57 +0000 (+0000) Subject: Use local-to-global mapping appropriately for macro definitions in the ASTReader X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e144c70d07bf7af6c0337000ac4c4e805fc6d842;p=clang Use local-to-global mapping appropriately for macro definitions in the ASTReader git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136410 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index f64e5eb458..b8da7538d2 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1603,6 +1603,17 @@ public: /// \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; } diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 0fc9d216a0..f268c765ef 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -742,6 +742,9 @@ class ASTDeclContextNameLookupTrait { 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 data_type; /// \brief Special internal key for declaration names. @@ -1504,7 +1507,7 @@ PreprocessedEntity *ASTReader::ReadMacroRecord(Module &F, uint64_t Offset) { 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 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { 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 @@ const FileEntry *ASTReader::getFileEntry(StringRef filenameStrRef) { 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.