diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-28 19:11:31 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-28 19:11:31 +0000 |
commit | dfe6543e12eca5c79421378b7fa6b3e8fc403e63 (patch) | |
tree | 082409087a592644bfdeb76f90d84e81dfff9a1e /lib/Sema/SemaDeclCXX.cpp | |
parent | 73cbbc8d786e54a7a61c2880ad1b9a596d235286 (diff) |
Lazily deserialize Sema::VTableUses. Plus, fix the utterly and
completely broken deserialization mapping code we had for VTableUses,
which would have broken horribly as soon as our local-to-global ID
mapping became interesting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index ba00944156..5d81205137 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -8935,6 +8935,30 @@ DeclResult Sema::ActOnCXXConditionDeclaration(Scope *S, Declarator &D) { return Dcl; } +void Sema::LoadExternalVTableUses() { + if (!ExternalSource) + return; + + SmallVector<ExternalVTableUse, 4> VTables; + ExternalSource->ReadUsedVTables(VTables); + SmallVector<VTableUse, 4> NewUses; + for (unsigned I = 0, N = VTables.size(); I != N; ++I) { + llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos + = VTablesUsed.find(VTables[I].Record); + // Even if a definition wasn't required before, it may be required now. + if (Pos != VTablesUsed.end()) { + if (!Pos->second && VTables[I].DefinitionRequired) + Pos->second = true; + continue; + } + + VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired; + NewUses.push_back(VTableUse(VTables[I].Record, VTables[I].Location)); + } + + VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end()); +} + void Sema::MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired) { // Ignore any vtable uses in unevaluated operands or for classes that do @@ -8945,6 +8969,7 @@ void Sema::MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, return; // Try to insert this class into the map. + LoadExternalVTableUses(); Class = cast<CXXRecordDecl>(Class->getCanonicalDecl()); std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator, bool> Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired)); @@ -8970,6 +8995,7 @@ void Sema::MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, } bool Sema::DefineUsedVTables() { + LoadExternalVTableUses(); if (VTableUses.empty()) return false; |