From: Douglas Gregor Date: Tue, 3 Jan 2012 17:31:38 +0000 (+0000) Subject: Don't attempt to merge a deserialized declaration with existing X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=674949fe3fdd796fc643f0e7660cb973da1dd383;p=clang Don't attempt to merge a deserialized declaration with existing declarations in the AST unless modules are enabled. This case doesn't come up with precompiled headers, and it isn't cheap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147451 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index abab88a9c6..82f6fae4a0 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -1512,6 +1512,10 @@ ASTDeclReader::VisitRedeclarable(Redeclarable *D) { template void ASTDeclReader::mergeRedeclarable(Redeclarable *D, RedeclarableResult &Redecl) { + // If modules are not available, there is no reason to perform this merge. + if (!Reader.getContext().getLangOptions().Modules) + return; + if (FindExistingResult ExistingRes = findExisting(static_cast(D))) { if (T *Existing = ExistingRes) { T *ExistingCanon = Existing->getCanonicalDecl(); diff --git a/test/Modules/redecl-merge.m b/test/Modules/redecl-merge.m index 4ea982b50f..ab264d1c5b 100644 --- a/test/Modules/redecl-merge.m +++ b/test/Modules/redecl-merge.m @@ -1,6 +1,6 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodule-cache-path %t -I %S/Inputs %s -verify -// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -I %S/Inputs %s -verify +// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify +// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify @class C2; @class C3; @class C3;