From a41f66064f2a524acb8321b4d8a2e883cd1520b4 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 20 Oct 2010 00:11:15 +0000 Subject: Fix issue with chained PCH where forward references did not pick up later definition in the chained PCH. llvm-svn: 116887 --- clang/lib/Serialization/ASTReaderDecl.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp') 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 PrevRedecls; + PrevRedecls.insert(D); + CXXRecordDecl *Redecl = cast(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(Redecl->RedeclLink.getNext()); + } + } + if (OwnsDefinitionData) { assert(D->DefinitionData); struct CXXRecordDecl::DefinitionData &Data = *D->DefinitionData; -- cgit v1.2.3