]> granicus.if.org Git - clang/commitdiff
Don't attempt to merge a deserialized declaration with existing
authorDouglas Gregor <dgregor@apple.com>
Tue, 3 Jan 2012 17:31:38 +0000 (17:31 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 3 Jan 2012 17:31:38 +0000 (17:31 +0000)
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

lib/Serialization/ASTReaderDecl.cpp
test/Modules/redecl-merge.m

index abab88a9c6c39ca2891a0675cdb16b909f09e792..82f6fae4a034df0f0090714388c39d80b48b57b6 100644 (file)
@@ -1512,6 +1512,10 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
 template<typename T>
 void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *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<T*>(D))) {
     if (T *Existing = ExistingRes) {
       T *ExistingCanon = Existing->getCanonicalDecl();
index 4ea982b50fee9d8e3dc054b303a051b6c76f4149..ab264d1c5b0dc4c4b5ffaf5857a70ec3fded429b 100644 (file)
@@ -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;