summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2015-03-18 21:52:47 +0000
committerRichard Trieu <rtrieu@google.com>2015-03-18 21:52:47 +0000
commit948bd5e2316e647f83c30a0016c3749cb72eb0df (patch)
treeaff881beaa87b1a762ff1bf38f3f2b67427fa348
parent2cf4d5f31204c873d76953bfe3c8b5602b29e789 (diff)
downloadbcm5719-llvm-948bd5e2316e647f83c30a0016c3749cb72eb0df.tar.gz
bcm5719-llvm-948bd5e2316e647f83c30a0016c3749cb72eb0df.zip
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: 232675
-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 6c34e5862f7..b822b11126e 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 f88233a60b2..f831010293b 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
OpenPOWER on IntegriCloud