r232675 - When cloning LocalInstantiationScope's, don't update the current scope in Sema.
Richard Trieu
rtrieu at google.com
Wed Mar 18 14:52:47 PDT 2015
Author: rtrieu
Date: Wed Mar 18 16:52:47 2015
New Revision: 232675
URL: http://llvm.org/viewvc/llvm-project?rev=232675&view=rev
Log:
When cloning LocalInstantiationScope's, don't update the current scope in Sema.
Construction of LocalInstantiationScope automatically updates the current scope
inside Sema. However, when cloning a scope, the current scope does not change.
Change the cloning function to preserve the current scope.
Review: http://reviews.llvm.org/D8407
BUG: https://llvm.org/bugs/show_bug.cgi?id=22931
Modified:
cfe/trunk/include/clang/Sema/Template.h
cfe/trunk/test/SemaCXX/warn-thread-safety-negative.cpp
Modified: cfe/trunk/include/clang/Sema/Template.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Template.h?rev=232675&r1=232674&r2=232675&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Template.h (original)
+++ cfe/trunk/include/clang/Sema/Template.h Wed Mar 18 16:52:47 2015
@@ -273,6 +273,11 @@ namespace clang {
/// outermost scope.
LocalInstantiationScope *cloneScopes(LocalInstantiationScope *Outermost) {
if (this == Outermost) return this;
+
+ // Save the current scope from SemaRef since the LocalInstantiationScope
+ // will overwrite it on construction
+ LocalInstantiationScope *oldScope = SemaRef.CurrentInstantiationScope;
+
LocalInstantiationScope *newScope =
new LocalInstantiationScope(SemaRef, CombineWithOuterScope);
@@ -299,6 +304,8 @@ namespace clang {
newScope->ArgumentPacks.push_back(NewPack);
}
}
+ // Restore the saved scope to SemaRef
+ SemaRef.CurrentInstantiationScope = oldScope;
return newScope;
}
Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-negative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-negative.cpp?rev=232675&r1=232674&r2=232675&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-negative.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-negative.cpp Wed Mar 18 16:52:47 2015
@@ -102,3 +102,20 @@ public:
};
} // end namespace SimpleTest
+
+namespace DoubleAttribute {
+
+struct Foo {
+ Mutex &mutex();
+};
+
+template <typename A>
+class TemplateClass {
+ template <typename B>
+ static void Function(Foo *F)
+ EXCLUSIVE_LOCKS_REQUIRED(F->mutex()) UNLOCK_FUNCTION(F->mutex()) {}
+};
+
+void test() { TemplateClass<int> TC; }
+
+} // end namespace DoubleAttribute
More information about the cfe-commits
mailing list