diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-24 15:24:38 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-24 15:24:38 +0000 |
commit | 247afcc6a904afff18e67154bda85930523dfb88 (patch) | |
tree | a35f156c6f8b68f2293779e96f63ee621355f0ce /clang/lib/Serialization/ASTReader.cpp | |
parent | 38f3981a99073a0b6a491a0d3d3d2b87ba819c31 (diff) | |
download | bcm5719-llvm-247afcc6a904afff18e67154bda85930523dfb88.tar.gz bcm5719-llvm-247afcc6a904afff18e67154bda85930523dfb88.zip |
Only mark an IdentifierInfo as having changed since deserialization
when it actually has changed (and not, e.g., when we've simply attached a
deserialized macro definition). Good for ~1.5% reduction in module
file size, mostly in the identifier table.
llvm-svn: 148808
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 5842bbb468e..683bc379cb9 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -510,8 +510,10 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k, // For uninteresting identifiers, just build the IdentifierInfo // and associate it with the persistent ID. IdentifierInfo *II = KnownII; - if (!II) + if (!II) { II = &Reader.getIdentifierTable().getOwn(StringRef(k.first, k.second)); + KnownII = II; + } Reader.SetIdentifierInfo(ID, II); II->setIsFromAST(); Reader.markIdentifierUpToDate(II); @@ -538,8 +540,10 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k, // Build the IdentifierInfo itself and link the identifier ID with // the new IdentifierInfo. IdentifierInfo *II = KnownII; - if (!II) + if (!II) { II = &Reader.getIdentifierTable().getOwn(StringRef(k.first, k.second)); + KnownII = II; + } Reader.markIdentifierUpToDate(II); II->setIsFromAST(); @@ -1362,7 +1366,7 @@ void ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) { } // Finally, install the macro. - PP.setMacroInfo(II, MI); + PP.setMacroInfo(II, MI, /*LoadedFromAST=*/true); // Remember that we saw this macro last so that we add the tokens that // form its body to it. @@ -1541,7 +1545,7 @@ void ASTReader::ReadDefinedMacros() { } void ASTReader::LoadMacroDefinition( - llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos) { + llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos) { assert(Pos != UnreadMacroRecordOffsets.end() && "Unknown macro definition"); uint64_t Offset = Pos->second; UnreadMacroRecordOffsets.erase(Pos); @@ -1579,9 +1583,12 @@ namespace { if (!IdTable) return false; + ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(), + M, This->Found); + std::pair<const char*, unsigned> Key(This->Name.begin(), This->Name.size()); - ASTIdentifierLookupTable::iterator Pos = IdTable->find(Key); + ASTIdentifierLookupTable::iterator Pos = IdTable->find(Key, &Trait); if (Pos == IdTable->end()) return false; |