aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-10-20 00:11:15 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-10-20 00:11:15 +0000
commit9703b0dd353b928b2312076f13e30950e05d5fa1 (patch)
tree1fe5d495b80664dda735d670df43c49e9c52a238 /lib/Serialization
parentec3683b3f33beda2449b4896b1a9548ab283e0e7 (diff)
Fix issue with chained PCH where forward references did not pick up later definition in the chained PCH.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index bcef244723..38672a6536 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/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;