From: Richard Smith Date: Tue, 10 Mar 2015 02:57:50 +0000 (+0000) Subject: [modules] Don't bother looking up a declaration to merge into if we're not X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=533e8193ca398e0e0317bf43a337b4864dd9412a;p=clang [modules] Don't bother looking up a declaration to merge into if we're not actually loading a formerly-canonical declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231742 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 9a382c1659..0789ba5e3e 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -2114,6 +2114,10 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable *DBase, if (!Reader.getContext().getLangOpts().Modules) return; + // If we're not the canonical declaration, we don't need to merge. + if (!DBase->isFirstDecl()) + return; + if (auto *Existing = Redecl.getKnownMergeTarget()) // We already know of an existing declaration we should merge with. mergeRedeclarable(D, cast(Existing), Redecl, TemplatePatternID); @@ -2182,7 +2186,8 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable *DBase, T *Existing, T *ExistingCanon = Existing->getCanonicalDecl(); T *DCanon = D->getCanonicalDecl(); if (ExistingCanon != DCanon) { - assert(DCanon->getGlobalID() == Redecl.getFirstID()); + assert(DCanon->getGlobalID() == Redecl.getFirstID() && + "already merged this declaration"); // Have our redeclaration link point back at the canonical declaration // of the existing declaration, so that this declaration has the