diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 26 |
3 files changed, 24 insertions, 7 deletions
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 344c4eb18dc..8b74b20032a 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -42,6 +42,8 @@ IdentifierInfo::IdentifierInfo() { IdentifierInfoLookup::~IdentifierInfoLookup() {} +ExternalIdentifierLookup::~ExternalIdentifierLookup() {} + IdentifierTable::IdentifierTable(const LangOptions &LangOpts, IdentifierInfoLookup* externalLookup) : HashTable(8192), // Start with space for 8K identifiers. diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index 40e5c0d6030..c351a24118e 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -1717,7 +1717,7 @@ bool PCHReader::ReadPreprocessorBlock() { HFI.isImport = Record[0]; HFI.DirInfo = Record[1]; HFI.NumIncludes = Record[2]; - HFI.ControllingMacro = DecodeIdentifierInfo(Record[3]); + HFI.ControllingMacroID = Record[3]; PP.getHeaderSearchInfo().setHeaderFileInfoForUID(HFI, NumHeaderInfos++); break; } @@ -1854,6 +1854,7 @@ PCHReader::ReadPCHBlock(uint64_t &PreprocessorBlockOffset) { } IdentifierOffsets = (const uint32_t *)BlobStart; IdentifiersLoaded.resize(Record[0]); + PP.getHeaderSearchInfo().SetExternalLookup(this); break; case pch::EXTERNAL_DEFINITIONS: diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index ddea8e52a02..129fa1ae35f 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -20,10 +20,23 @@ #include <cstdio> using namespace clang; +const IdentifierInfo * +HeaderFileInfo::getControllingMacro(ExternalIdentifierLookup *External) { + if (ControllingMacro) + return ControllingMacro; + + if (!ControllingMacroID || !External) + return 0; + + ControllingMacro = External->GetIdentifier(ControllingMacroID); + return ControllingMacro; +} + HeaderSearch::HeaderSearch(FileManager &FM) : FileMgr(FM), FrameworkMap(64) { SystemDirIdx = 0; NoCurDirSearch = false; - + + ExternalLookup = 0; NumIncluded = 0; NumMultiIncludeFileOptzn = 0; NumFrameworkLookups = NumSubFrameworkLookups = 0; @@ -417,11 +430,12 @@ bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){ // Next, check to see if the file is wrapped with #ifndef guards. If so, and // if the macro that guards it is defined, we know the #include has no effect. - if (FileInfo.ControllingMacro && - FileInfo.ControllingMacro->hasMacroDefinition()) { - ++NumMultiIncludeFileOptzn; - return false; - } + if (const IdentifierInfo *ControllingMacro + = FileInfo.getControllingMacro(ExternalLookup)) + if (ControllingMacro->hasMacroDefinition()) { + ++NumMultiIncludeFileOptzn; + return false; + } // Increment the number of times this file has been included. ++FileInfo.NumIncludes; |