[llvm-branch-commits] [cfe-branch] r236441 - Merging r232675:

Tom Stellard thomas.stellard at amd.com
Mon May 4 11:23:57 PDT 2015


Author: tstellar
Date: Mon May  4 13:23:57 2015
New Revision: 236441

URL: http://llvm.org/viewvc/llvm-project?rev=236441&view=rev
Log:
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

------------------------------------------------------------------------

Modified:
    cfe/branches/release_36/include/clang/Sema/Template.h
    cfe/branches/release_36/test/SemaCXX/warn-thread-safety-negative.cpp

Modified: cfe/branches/release_36/include/clang/Sema/Template.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/include/clang/Sema/Template.h?rev=236441&r1=236440&r2=236441&view=diff
==============================================================================
--- cfe/branches/release_36/include/clang/Sema/Template.h (original)
+++ cfe/branches/release_36/include/clang/Sema/Template.h Mon May  4 13:23:57 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/branches/release_36/test/SemaCXX/warn-thread-safety-negative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/test/SemaCXX/warn-thread-safety-negative.cpp?rev=236441&r1=236440&r2=236441&view=diff
==============================================================================
--- cfe/branches/release_36/test/SemaCXX/warn-thread-safety-negative.cpp (original)
+++ cfe/branches/release_36/test/SemaCXX/warn-thread-safety-negative.cpp Mon May  4 13:23:57 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 llvm-branch-commits mailing list