summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index bcef2447235..38672a65366 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -788,6 +788,24 @@ void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
VisitRecordDecl(D);
+ if (D->DefinitionData) {
+ // Synchronize the DefinitionData pointer among all redeclarations.
+ // This synchronization ends up being done multiple times but it's necessary
+ // because a chained PCH may introduce a definition that earlier
+ // redeclarations in another PCH have no information about.
+ llvm::SmallPtrSet<CXXRecordDecl *, 16> PrevRedecls;
+ PrevRedecls.insert(D);
+ CXXRecordDecl *Redecl = cast<CXXRecordDecl>(D->RedeclLink.getNext());
+ while (!PrevRedecls.count(Redecl)) {
+ PrevRedecls.insert(Redecl);
+ assert((!Redecl->DefinitionData ||
+ Redecl->DefinitionData == D->DefinitionData) &&
+ "Multiple definitions in the redeclaration chain ?");
+ Redecl->DefinitionData = D->DefinitionData;
+ Redecl = cast<CXXRecordDecl>(Redecl->RedeclLink.getNext());
+ }
+ }
+
if (OwnsDefinitionData) {
assert(D->DefinitionData);
struct CXXRecordDecl::DefinitionData &Data = *D->DefinitionData;
OpenPOWER on IntegriCloud