diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2015-05-04 18:23:57 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2015-05-04 18:23:57 +0000 |
commit | b5bd437007c19841a8754db8c89c7a093d7c5e76 (patch) | |
tree | e32866354ff2981d0e84723364565f79916bb931 | |
parent | e4983b9522b4bb9638581fab0af186bc11c589ab (diff) |
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
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_36@236441 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Sema/Template.h | 7 | ||||
-rw-r--r-- | test/SemaCXX/warn-thread-safety-negative.cpp | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/include/clang/Sema/Template.h b/include/clang/Sema/Template.h index c08a5df00b..8f0d9da73e 100644 --- a/include/clang/Sema/Template.h +++ b/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/test/SemaCXX/warn-thread-safety-negative.cpp b/test/SemaCXX/warn-thread-safety-negative.cpp index f88233a60b..f831010293 100644 --- a/test/SemaCXX/warn-thread-safety-negative.cpp +++ b/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 |