[llvm-branch-commits] [cfe-branch] r195901 - Merging r195887:
Bill Wendling
isanbard at gmail.com
Wed Nov 27 16:34:28 PST 2013
Author: void
Date: Wed Nov 27 18:34:28 2013
New Revision: 195901
URL: http://llvm.org/viewvc/llvm-project?rev=195901&view=rev
Log:
Merging r195887:
------------------------------------------------------------------------
r195887 | majnemer | 2013-11-27 14:57:44 -0800 (Wed, 27 Nov 2013) | 9 lines
Sema: Instantiation of variable definitions weren't local enough
We wouldn't properly save and restore the pending local instantiations
we had built up prior to instantiation of a variable definition. This
would lead to us instantiating too much causing crashes and other
general badness.
This fixes PR14374.
------------------------------------------------------------------------
Modified:
cfe/branches/release_34/ (props changed)
cfe/branches/release_34/include/clang/Sema/Sema.h
cfe/branches/release_34/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/branches/release_34/test/SemaTemplate/instantiate-local-class.cpp
Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 27 18:34:28 2013
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195693,195710,195716,195760,195768,195827,195888
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195693,195710,195716,195760,195768,195827,195887-195888
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_34/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/include/clang/Sema/Sema.h?rev=195901&r1=195900&r2=195901&view=diff
==============================================================================
--- cfe/branches/release_34/include/clang/Sema/Sema.h (original)
+++ cfe/branches/release_34/include/clang/Sema/Sema.h Wed Nov 27 18:34:28 2013
@@ -6406,6 +6406,24 @@ public:
/// types, static variables, enumerators, etc.
std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
+ class SavePendingLocalImplicitInstantiationsRAII {
+ public:
+ SavePendingLocalImplicitInstantiationsRAII(Sema &S): S(S) {
+ SavedPendingLocalImplicitInstantiations.swap(
+ S.PendingLocalImplicitInstantiations);
+ }
+
+ ~SavePendingLocalImplicitInstantiationsRAII() {
+ SavedPendingLocalImplicitInstantiations.swap(
+ S.PendingLocalImplicitInstantiations);
+ }
+
+ private:
+ Sema &S;
+ std::deque<PendingImplicitInstantiation>
+ SavedPendingLocalImplicitInstantiations;
+ };
+
void PerformPendingInstantiations(bool LocalOnly = false);
TypeSourceInfo *SubstType(TypeSourceInfo *T,
Modified: cfe/branches/release_34/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=195901&r1=195900&r2=195901&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/branches/release_34/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Nov 27 18:34:28 2013
@@ -3224,10 +3224,8 @@ void Sema::InstantiateFunctionDefinition
// while we're still within our own instantiation context.
SmallVector<VTableUse, 16> SavedVTableUses;
std::deque<PendingImplicitInstantiation> SavedPendingInstantiations;
- std::deque<PendingImplicitInstantiation>
- SavedPendingLocalImplicitInstantiations;
- SavedPendingLocalImplicitInstantiations.swap(
- PendingLocalImplicitInstantiations);
+ SavePendingLocalImplicitInstantiationsRAII
+ SavedPendingLocalImplicitInstantiations(*this);
if (Recursive) {
VTableUses.swap(SavedVTableUses);
PendingInstantiations.swap(SavedPendingInstantiations);
@@ -3308,8 +3306,6 @@ void Sema::InstantiateFunctionDefinition
"PendingInstantiations should be empty before it is discarded.");
PendingInstantiations.swap(SavedPendingInstantiations);
}
- SavedPendingLocalImplicitInstantiations.swap(
- PendingLocalImplicitInstantiations);
}
VarTemplateSpecializationDecl *Sema::BuildVarTemplateInstantiation(
@@ -3727,6 +3723,8 @@ void Sema::InstantiateVariableDefinition
// while we're still within our own instantiation context.
SmallVector<VTableUse, 16> SavedVTableUses;
std::deque<PendingImplicitInstantiation> SavedPendingInstantiations;
+ SavePendingLocalImplicitInstantiationsRAII
+ SavedPendingLocalImplicitInstantiations(*this);
if (Recursive) {
VTableUses.swap(SavedVTableUses);
PendingInstantiations.swap(SavedPendingInstantiations);
Modified: cfe/branches/release_34/test/SemaTemplate/instantiate-local-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/SemaTemplate/instantiate-local-class.cpp?rev=195901&r1=195900&r2=195901&view=diff
==============================================================================
--- cfe/branches/release_34/test/SemaTemplate/instantiate-local-class.cpp (original)
+++ cfe/branches/release_34/test/SemaTemplate/instantiate-local-class.cpp Wed Nov 27 18:34:28 2013
@@ -160,3 +160,23 @@ void call() {
C::func([]() {});
}
}
+
+namespace PR14373 {
+ struct function {
+ template <typename _Functor> function(_Functor __f) { __f(); }
+ };
+ template <typename Func> function exec_func(Func f) {
+ struct functor {
+ functor(Func f) : func(f) {}
+ void operator()() const { func(); }
+ Func func;
+ };
+ return functor(f);
+ }
+ struct Type {
+ void operator()() const {}
+ };
+ int call() {
+ exec_func(Type());
+ }
+}
More information about the llvm-branch-commits
mailing list