diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-22 19:44:59 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-22 19:44:59 +0000 |
commit | 0475cd88c95a6e87c7530f93085e5cbd66c16832 (patch) | |
tree | 3926cb397af46d772378260081f83c62b9897396 /clang/lib/Serialization/ASTReaderDecl.cpp | |
parent | 292dc080e06ca46097f300968138140c620faf55 (diff) | |
download | bcm5719-llvm-0475cd88c95a6e87c7530f93085e5cbd66c16832.tar.gz bcm5719-llvm-0475cd88c95a6e87c7530f93085e5cbd66c16832.zip |
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
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
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; |