From 67d49afc70d3810c0699525e964c0ff5762613f3 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 4 May 2015 18:23:57 +0000 Subject: 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 --- clang/include/clang/Sema/Template.h | 7 +++++++ clang/test/SemaCXX/warn-thread-safety-negative.cpp | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index c08a5df..8f0d9da 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 f88233a..f831010 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 +class TemplateClass { + template + static void Function(Foo *F) + EXCLUSIVE_LOCKS_REQUIRED(F->mutex()) UNLOCK_FUNCTION(F->mutex()) {} +}; + +void test() { TemplateClass TC; } + +} // end namespace DoubleAttribute -- cgit v1.1