[modules] Don't bother looking up a declaration to merge into if we're not

actually loading a formerly-canonical declaration.

llvm-svn: 231742
This commit is contained in:
Richard Smith 2015-03-10 02:57:50 +00:00
parent b54a8d62a4
commit 202850a025
1 changed files with 6 additions and 1 deletions

View File

@ -2114,6 +2114,10 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase,
if (!Reader.getContext().getLangOpts().Modules) if (!Reader.getContext().getLangOpts().Modules)
return; return;
// If we're not the canonical declaration, we don't need to merge.
if (!DBase->isFirstDecl())
return;
if (auto *Existing = Redecl.getKnownMergeTarget()) if (auto *Existing = Redecl.getKnownMergeTarget())
// We already know of an existing declaration we should merge with. // We already know of an existing declaration we should merge with.
mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID); mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID);
@ -2182,7 +2186,8 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase, T *Existing,
T *ExistingCanon = Existing->getCanonicalDecl(); T *ExistingCanon = Existing->getCanonicalDecl();
T *DCanon = D->getCanonicalDecl(); T *DCanon = D->getCanonicalDecl();
if (ExistingCanon != DCanon) { 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 // Have our redeclaration link point back at the canonical declaration
// of the existing declaration, so that this declaration has the // of the existing declaration, so that this declaration has the