From f73c93fea0d4b447585bc7459499ba6b822e045c Mon Sep 17 00:00:00 2001 From: Sebastian Redl Date: Wed, 15 Sep 2010 19:54:06 +0000 Subject: [PATCH] Macro definitions in AST files have their own IDs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114014 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Serialization/ASTBitCodes.h | 7 +++++-- include/clang/Serialization/ASTReader.h | 2 +- include/clang/Serialization/ASTWriter.h | 6 +++--- lib/Serialization/ASTReader.cpp | 2 +- lib/Serialization/ASTWriter.cpp | 8 ++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 3714b77f2b..8628d74ff1 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -112,10 +112,13 @@ namespace clang { typedef llvm::DenseMap TypeIdxMap; - /// \brief An ID number that refers to an identifier in an AST - /// file. + /// \brief An ID number that refers to an identifier in an AST file. typedef uint32_t IdentID; + /// \brief An ID number that refers to a macro in an AST file. + typedef uint32_t MacroID; + + /// \brief An ID number that refers to an ObjC selctor in an AST file. typedef uint32_t SelectorID; /// \brief Describes the various kinds of blocks that occur within diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index d31be88a3e..f1801f4943 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1028,7 +1028,7 @@ public: virtual void ReadDefinedMacros(); /// \brief Retrieve the macro definition with the given ID. - MacroDefinition *getMacroDefinition(serialization::IdentID ID); + MacroDefinition *getMacroDefinition(serialization::MacroID ID); /// \brief Retrieve the AST context that this AST reader supplements. ASTContext *getContext() { return Context; } diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 426fc47801..95964e0ea5 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -173,8 +173,8 @@ private: llvm::DenseMap MacroOffsets; /// \brief Mapping from macro definitions (as they occur in the preprocessing - /// record) to the index into the macro definitions table. - llvm::DenseMap + /// record) to the macro IDs. + llvm::DenseMap MacroDefinitions; /// \brief Mapping from the macro definition indices in \c MacroDefinitions @@ -353,7 +353,7 @@ public: /// \brief Retrieve the ID number corresponding to the given macro /// definition. - serialization::IdentID getMacroDefinitionID(MacroDefinition *MD); + serialization::MacroID getMacroDefinitionID(MacroDefinition *MD); /// \brief Emit a reference to a type. void AddTypeRef(QualType T, RecordData &Record); diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 6e79eb22bd..18df3359f3 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1545,7 +1545,7 @@ void ASTReader::ReadDefinedMacros() { } } -MacroDefinition *ASTReader::getMacroDefinition(IdentID ID) { +MacroDefinition *ASTReader::getMacroDefinition(MacroID ID) { if (ID == 0 || ID >= MacroDefinitionsLoaded.size()) return 0; diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index f661b45df0..b32354b46c 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1349,7 +1349,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP) { if (MacroDefinition *MD = dyn_cast(*E)) { // Record this macro definition's location. - IdentID ID = getMacroDefinitionID(MD); + MacroID ID = getMacroDefinitionID(MD); if (ID != MacroDefinitionOffsets.size()) { if (ID > MacroDefinitionOffsets.size()) MacroDefinitionOffsets.resize(ID + 1); @@ -2717,11 +2717,11 @@ IdentID ASTWriter::getIdentifierRef(const IdentifierInfo *II) { return ID; } -IdentID ASTWriter::getMacroDefinitionID(MacroDefinition *MD) { +MacroID ASTWriter::getMacroDefinitionID(MacroDefinition *MD) { if (MD == 0) return 0; - - IdentID &ID = MacroDefinitions[MD]; + + MacroID &ID = MacroDefinitions[MD]; if (ID == 0) ID = MacroDefinitions.size(); return ID; -- 2.40.0