r231742 - [modules] Don't bother looking up a declaration to merge into if we're not
Richard Smith
richard-llvm at metafoo.co.uk
Mon Mar 9 19:57:50 PDT 2015
Author: rsmith
Date: Mon Mar 9 21:57:50 2015
New Revision: 231742
URL: http://llvm.org/viewvc/llvm-project?rev=231742&view=rev
Log:
[modules] Don't bother looking up a declaration to merge into if we're not
actually loading a formerly-canonical declaration.
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=231742&r1=231741&r2=231742&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Mar 9 21:57:50 2015
@@ -2114,6 +2114,10 @@ void ASTDeclReader::mergeRedeclarable(Re
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<T>(Existing), Redecl, TemplatePatternID);
@@ -2182,7 +2186,8 @@ void ASTDeclReader::mergeRedeclarable(Re
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
More information about the cfe-commits
mailing list