/// \brief Keeps track of the elements added to PendingDeclChains.
llvm::SmallSet<serialization::DeclID, 16> PendingDeclChainsKnown;
+ /// \brief Reverse mapping from declarations to their global declaration IDs.
+ ///
+ /// FIXME: This data structure is currently only used for ObjCInterfaceDecls,
+ /// support declaration merging. If we must have this for other declarations,
+ /// allocate it along with the Decl itself.
+ llvm::DenseMap<Decl *, serialization::GlobalDeclID> DeclToID;
+
typedef llvm::DenseMap<Decl *, llvm::SmallVector<serialization::DeclID, 2> >
MergedDeclsMap;
}
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.
// 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)
if (Chains.empty())
return;
-
// Capture all of the parsed declarations and put them at the end.
Decl *MostRecent = getMostRecentDecl(CanonDecl);
Decl *FirstParsed = MostRecent;
header "redecl-merge-left.h"
export *
}
+module redecl_merge_left_left {
+ header "redecl-merge-left-left.h"
+ export *
+}
module redecl_merge_right {
header "redecl-merge-right.h"
export *