[cfe-commits] r165001 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTReaderDecl.cpp test/Modules/Inputs/templates-left.h test/Modules/Inputs/templates-right.h test/Modules/templates.mm
Axel Naumann
Axel.Naumann at cern.ch
Tue Oct 2 05:18:46 PDT 2012
Author: axel
Date: Tue Oct 2 07:18:46 2012
New Revision: 165001
URL: http://llvm.org/viewvc/llvm-project?rev=165001&view=rev
Log:
Only those InterestingDecls that got added to the AST should be passed to the ASTConsumer.
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Modules/Inputs/templates-left.h
cfe/trunk/test/Modules/Inputs/templates-right.h
cfe/trunk/test/Modules/templates.mm
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=165001&r1=165000&r2=165001&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Oct 2 07:18:46 2012
@@ -687,6 +687,12 @@
/// Objective-C protocols.
std::deque<Decl *> InterestingDecls;
+ /// \brief Redecls that have been added to the AST
+ ///
+ /// Redecls that are deserialized but not in RedeclsAddedToAST must
+ /// not be passed to the ASTConsumers, even if they are InterestignDecls.
+ llvm::SmallPtrSet<Decl *, 16> RedeclsAddedToAST;
+
/// \brief The set of redeclarable declarations that have been deserialized
/// since the last time the declaration chains were linked.
llvm::SmallPtrSet<Decl *, 16> RedeclsDeserialized;
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=165001&r1=165000&r2=165001&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Oct 2 07:18:46 2012
@@ -6509,4 +6509,5 @@
J != F; ++J)
delete J->first;
}
+ assert(RedeclsAddedToAST.empty() && "RedeclsAddedToAST not empty!");
}
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=165001&r1=165000&r2=165001&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Oct 2 07:18:46 2012
@@ -1777,9 +1777,11 @@
DeclContext *DC = New->getDeclContext()->getRedeclContext();
if (DC->isTranslationUnit() && Reader.SemaObj) {
- Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName());
+ if (Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName()))
+ Reader.RedeclsAddedToAST.insert(New);
} else if (DC->isNamespace()) {
DC->addDecl(New);
+ Reader.RedeclsAddedToAST.insert(New);
}
}
@@ -2154,7 +2156,13 @@
// AST consumer might need to know about, queue it.
// We don't pass it to the consumer immediately because we may be in recursive
// loading, and some declarations may still be initializing.
- if (isConsumerInterestedIn(D))
+ if (getContext().getLangOpts().Modules) {
+ if (RedeclsAddedToAST.count(D)) {
+ RedeclsAddedToAST.erase(D);
+ if (isConsumerInterestedIn(D))
+ InterestingDecls.push_back(D);
+ }
+ } else if (isConsumerInterestedIn(D))
InterestingDecls.push_back(D);
return D;
Modified: cfe/trunk/test/Modules/Inputs/templates-left.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/templates-left.h?rev=165001&r1=165000&r2=165001&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/templates-left.h (original)
+++ cfe/trunk/test/Modules/Inputs/templates-left.h Tue Oct 2 07:18:46 2012
@@ -20,8 +20,10 @@
}
template <typename T>
-void pendingInstantiation(T) {}
+void pendingInstantiationEmit(T) {}
void triggerPendingInstantiation() {
- pendingInstantiation(12);
- pendingInstantiation(42.);
+ pendingInstantiationEmit(12);
+ pendingInstantiationEmit(42.);
}
+
+void redeclDefinitionEmit(){}
Modified: cfe/trunk/test/Modules/Inputs/templates-right.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/templates-right.h?rev=165001&r1=165000&r2=165001&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/templates-right.h (original)
+++ cfe/trunk/test/Modules/Inputs/templates-right.h Tue Oct 2 07:18:46 2012
@@ -19,7 +19,9 @@
}
template <typename T>
-void pendingInstantiation(T) {}
+void pendingInstantiationEmit(T) {}
void triggerPendingInstantiationToo() {
- pendingInstantiation(12);
+ pendingInstantiationEmit(12);
}
+
+void redeclDefinitionEmit(){}
Modified: cfe/trunk/test/Modules/templates.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/templates.mm?rev=165001&r1=165000&r2=165001&view=diff
==============================================================================
--- cfe/trunk/test/Modules/templates.mm (original)
+++ cfe/trunk/test/Modules/templates.mm Tue Oct 2 07:18:46 2012
@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs -verify %s -Wno-objc-root-class
-// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class | grep pendingInstantiation | FileCheck %s
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class | grep Emit | FileCheck %s
@__experimental_modules_import templates_left;
@__experimental_modules_import templates_right;
@@ -18,11 +18,18 @@
}
void testPendingInstantiations() {
- // CHECK: call
- // CHECK: call
- // CHECK: {{define .*pendingInstantiation.*[(]i}}
- // CHECK: {{define .*pendingInstantiation.*[(]double}}
- // CHECK: call
+ // CHECK: call {{.*pendingInstantiationEmit}}
+ // CHECK: call {{.*pendingInstantiationEmit}}
+ // CHECK: define {{.*pendingInstantiationEmit.*[(]i}}
+ // CHECK: define {{.*pendingInstantiationEmit.*[(]double}}
triggerPendingInstantiation();
triggerPendingInstantiationToo();
}
+
+void testRedeclDefinition() {
+ // CHECK: define {{.*redeclDefinitionEmit}}
+ redeclDefinitionEmit();
+}
+
+// CHECK: call {{.*pendingInstantiation}}
+// CHECK: call {{.*redeclDefinitionEmit}}
More information about the cfe-commits
mailing list