diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-28 22:39:26 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-28 22:39:26 +0000 |
commit | 86c67d8802a9e0887c31c850188991465ac3c1bd (patch) | |
tree | 38778746b610eb0736d8a058e053f1587afdf5a2 | |
parent | e144c70d07bf7af6c0337000ac4c4e805fc6d842 (diff) |
Introduce the local-global mapping for preprocessed entities, and use
it appropriately. Also, patch up a place where we were failing to map
local macro definition IDs into global macro definition IDs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136411 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Serialization/ASTBitCodes.h | 4 | ||||
-rw-r--r-- | include/clang/Serialization/ASTReader.h | 5 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 36 |
3 files changed, 32 insertions, 13 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 4e7b0faebf..908aa4b070 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -134,6 +134,10 @@ namespace clang { /// AST file. typedef uint32_t CXXBaseSpecifiersID; + /// \brief An ID number that refers to an entity in the detailed + /// preprocessing record. + typedef uint32_t PreprocessedEntityID; + /// \brief Describes the various kinds of blocks that occur within /// an AST file. enum BlockIDs { diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index b8da7538d2..13fec48f69 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1584,6 +1584,11 @@ public: /// position. PreprocessedEntity *LoadPreprocessedEntity(Module &F); + /// \brief Determine the global preprocessed entity ID that corresponds to + /// the given local ID within the given module. + serialization::PreprocessedEntityID + getGlobalPreprocessedEntityID(Module &M, unsigned LocalID); + /// \brief Note that the identifier is a macro whose record will be loaded /// from the given AST file at the given (file-local) offset. void SetIdentifierIsMacro(IdentifierInfo *II, Module &F, diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index f268c765ef..ce81dddc5d 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1570,7 +1570,8 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { Code, Record, BlobStart, BlobLen); switch (RecType) { case PPD_MACRO_EXPANSION: { - if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(Record[0])) + PreprocessedEntityID GlobalID = getGlobalPreprocessedEntityID(F, Record[0]); + if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID)) return PE; MacroExpansion *ME = @@ -1578,15 +1579,17 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { SourceRange(ReadSourceLocation(F, Record[1]), ReadSourceLocation(F, Record[2])), getLocalMacroDefinition(F, Record[4])); - PPRec.setLoadedPreallocatedEntity(Record[0], ME); + PPRec.setLoadedPreallocatedEntity(GlobalID, ME); return ME; } case PPD_MACRO_DEFINITION: { - if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(Record[0])) + PreprocessedEntityID GlobalID = getGlobalPreprocessedEntityID(F, Record[0]); + if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID)) return PE; - - if (Record[1] > MacroDefinitionsLoaded.size()) { + + unsigned MacroDefID = getGlobalMacroDefinitionID(F, Record[1]); + if (MacroDefID > MacroDefinitionsLoaded.size()) { Error("out-of-bounds macro definition record"); return 0; } @@ -1594,7 +1597,7 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { // Decode the identifier info and then check again; if the macro is // still defined and associated with the identifier, IdentifierInfo *II = getLocalIdentifier(F, Record[4]); - if (!MacroDefinitionsLoaded[Record[1] - 1]) { + if (!MacroDefinitionsLoaded[MacroDefID - 1]) { MacroDefinition *MD = new (PPRec) MacroDefinition(II, ReadSourceLocation(F, Record[5]), @@ -1602,24 +1605,25 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { ReadSourceLocation(F, Record[2]), ReadSourceLocation(F, Record[3]))); - PPRec.setLoadedPreallocatedEntity(Record[0], MD); - MacroDefinitionsLoaded[Record[1] - 1] = MD; + PPRec.setLoadedPreallocatedEntity(GlobalID, MD); + MacroDefinitionsLoaded[MacroDefID - 1] = MD; if (DeserializationListener) - DeserializationListener->MacroDefinitionRead(Record[1], MD); + DeserializationListener->MacroDefinitionRead(MacroDefID, MD); } - return MacroDefinitionsLoaded[Record[1] - 1]; + return MacroDefinitionsLoaded[MacroDefID - 1]; } case PPD_INCLUSION_DIRECTIVE: { - if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(Record[0])) + PreprocessedEntityID GlobalID = getGlobalPreprocessedEntityID(F, Record[0]); + if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID)) return PE; const char *FullFileNameStart = BlobStart + Record[3]; const FileEntry *File = PP->getFileManager().getFile(StringRef(FullFileNameStart, - BlobLen - Record[3])); + BlobLen - Record[3])); // FIXME: Stable encoding InclusionDirective::InclusionKind Kind @@ -1631,7 +1635,7 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { File, SourceRange(ReadSourceLocation(F, Record[1]), ReadSourceLocation(F, Record[2]))); - PPRec.setLoadedPreallocatedEntity(Record[0], ID); + PPRec.setLoadedPreallocatedEntity(GlobalID, ID); return ID; } } @@ -1640,6 +1644,12 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { return 0; } +PreprocessedEntityID +ASTReader::getGlobalPreprocessedEntityID(Module &M, unsigned LocalID) { + // FIXME: Local-to-global mapping + return LocalID; +} + namespace { /// \brief Trait class used to search the on-disk hash table containing all of /// the header search information. |