summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2015-05-04 18:23:57 +0000
committerTom Stellard <thomas.stellard@amd.com>2015-05-04 18:23:57 +0000
commit67d49afc70d3810c0699525e964c0ff5762613f3 (patch)
tree3d0d55eca7865f2b9f823460c9f80f3d350fe12d
parented4cd4295595411a56fb16b4c9cc415167af6ee5 (diff)
downloadllvm-67d49afc70d3810c0699525e964c0ff5762613f3.tar.gz
Merging r232675:
------------------------------------------------------------------------ r232675 | rtrieu | 2015-03-18 17:52:47 -0400 (Wed, 18 Mar 2015) | 9 lines 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 ------------------------------------------------------------------------ llvm-svn: 236441
-rw-r--r--clang/include/clang/Sema/Template.h7
-rw-r--r--clang/test/SemaCXX/warn-thread-safety-negative.cpp17
2 files changed, 24 insertions, 0 deletions
diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h
index c08a5df00b36..8f0d9da73ecb 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -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;
}
diff --git a/clang/test/SemaCXX/warn-thread-safety-negative.cpp b/clang/test/SemaCXX/warn-thread-safety-negative.cpp
index f88233a60b27..f831010293b6 100644
--- a/clang/test/SemaCXX/warn-thread-safety-negative.cpp
+++ b/clang/test/SemaCXX/warn-thread-safety-negative.cpp
@@ -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