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/trunk@232675
91177308-0d34-0410-b5e6-
96231b3b80d8
/// 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);
newScope->ArgumentPacks.push_back(NewPack);
}
}
+ // Restore the saved scope to SemaRef
+ SemaRef.CurrentInstantiationScope = oldScope;
return newScope;
}
};
} // 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