From 0475cd88c95a6e87c7530f93085e5cbd66c16832 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 22 Dec 2011 19:44:59 +0000 Subject: If we end up merging an Objective-C class with an existing Objective-C class that comes from a different module file, make sure that we load all of the pending declarations for the original declaration. llvm-svn: 147168 --- clang/lib/Serialization/ASTReaderDecl.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp') diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 93ba34bec6a..2c8e6ea4663 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -643,10 +643,13 @@ void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { } void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { + // Record the declaration -> global ID mapping. + Reader.DeclToID[ID] = ThisDeclID; + RedeclarableResult Redecl = VisitRedeclarable(ID); VisitObjCContainerDecl(ID); TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]); - + // Determine whether we need to merge this declaration with another @interface // with the same name. // FIXME: Not needed unless the module file graph is a DAG. @@ -660,6 +663,18 @@ void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { // appropriate canonical declaration. ID->RedeclLink = ObjCInterfaceDecl::PreviousDeclLink(ExistingCanon); + // Don't introduce IDCanon into the set of pending declaration chains. + Redecl.suppress(); + + // Introduce ExistingCanon into the set of pending declaration chains, + // if in fact it came from a module file. + if (ExistingCanon->isFromASTFile()) { + GlobalDeclID ExistingCanonID = Reader.DeclToID[ExistingCanon]; + assert(ExistingCanonID && "Unrecorded canonical declaration ID?"); + if (Reader.PendingDeclChainsKnown.insert(ExistingCanonID)) + Reader.PendingDeclChains.push_back(ExistingCanonID); + } + // If this declaration was the canonical declaration, make a note of // that. if (IDCanon == ID) @@ -2192,7 +2207,6 @@ void ASTReader::loadPendingDeclChain(serialization::GlobalDeclID ID) { if (Chains.empty()) return; - // Capture all of the parsed declarations and put them at the end. Decl *MostRecent = getMostRecentDecl(CanonDecl); Decl *FirstParsed = MostRecent; -- cgit v1.2.3