summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-03-10 02:57:50 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-03-10 02:57:50 +0000
commit202850a025cb1c47e48c4266a78445e3a771f1bc (patch)
tree2afa16c3de042d3b39a3f8776b1733842c3722ed
parentb54a8d62a4859bf69e9b6e877a6e73fdc67ced40 (diff)
downloadbcm5719-llvm-202850a025cb1c47e48c4266a78445e3a771f1bc.tar.gz
bcm5719-llvm-202850a025cb1c47e48c4266a78445e3a771f1bc.zip
[modules] Don't bother looking up a declaration to merge into if we're not
actually loading a formerly-canonical declaration. llvm-svn: 231742
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 9a382c1659d..0789ba5e3e7 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2114,6 +2114,10 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *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<T>(Existing), Redecl, TemplatePatternID);
@@ -2182,7 +2186,8 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *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
OpenPOWER on IntegriCloud