diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-04-08 20:53:26 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-04-08 20:53:26 +0000 |
| commit | 1e8e91b3795b7c2cebab909fd979dce21768a755 (patch) | |
| tree | 5842a300bdaf71a3ade90842443d440810f92ecb /clang/lib | |
| parent | 1f492893ac015ed6aae8427a6de4f30dd9d2feb8 (diff) | |
| download | bcm5719-llvm-1e8e91b3795b7c2cebab909fd979dce21768a755.tar.gz bcm5719-llvm-1e8e91b3795b7c2cebab909fd979dce21768a755.zip | |
PR25501: Delay loading visible updates for a declaration until after we've
processed update records. If an update record adds a definition, we need to
merge that with any pre-existing definition to determine which the canonical
definition is before we apply the visible update, otherwise we wouldn't know
where to apply it.
Thanks to Vassil Vassilev for help reducing this and tracking down the problem.
llvm-svn: 265848
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 47ac4076757..efb7793ef61 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -3436,20 +3436,6 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { } void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) { - // Load the pending visible updates for this decl context, if it has any. - auto I = PendingVisibleUpdates.find(ID); - if (I != PendingVisibleUpdates.end()) { - auto VisibleUpdates = std::move(I->second); - PendingVisibleUpdates.erase(I); - - auto *DC = cast<DeclContext>(D)->getPrimaryContext(); - for (const PendingVisibleUpdate &Update : VisibleUpdates) - Lookups[DC].Table.add( - Update.Mod, Update.Data, - reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod)); - DC->setHasExternalVisibleStorage(true); - } - // The declaration may have been modified by files later in the chain. // If this is the case, read the record containing the updates from each file // and pass it to ASTDeclReader to make the modifications. @@ -3485,6 +3471,20 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) { } } } + + // Load the pending visible updates for this decl context, if it has any. + auto I = PendingVisibleUpdates.find(ID); + if (I != PendingVisibleUpdates.end()) { + auto VisibleUpdates = std::move(I->second); + PendingVisibleUpdates.erase(I); + + auto *DC = cast<DeclContext>(D)->getPrimaryContext(); + for (const PendingVisibleUpdate &Update : VisibleUpdates) + Lookups[DC].Table.add( + Update.Mod, Update.Data, + reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod)); + DC->setHasExternalVisibleStorage(true); + } } void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) { @@ -3757,7 +3757,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: { auto *RD = cast<CXXRecordDecl>(D); - auto *OldDD = RD->DefinitionData.getNotUpdated(); + auto *OldDD = RD->getCanonicalDecl()->DefinitionData.getNotUpdated(); bool HadRealDefinition = OldDD && (OldDD->Definition != RD || !Reader.PendingFakeDefinitionData.count(OldDD)); |

