diff options
author | Faisal Vali <faisalv@yahoo.com> | 2013-06-26 02:34:24 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2013-06-26 02:34:24 +0000 |
commit | 18d3598ed0eb8b459a446cac037206caa4066208 (patch) | |
tree | 55a1a62286aeb8f093da09a7d20c0feca6ca8a42 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 358256c77ad41d3502b4bdbc820a9598bc610ac7 (diff) | |
download | bcm5719-llvm-18d3598ed0eb8b459a446cac037206caa4066208.tar.gz bcm5719-llvm-18d3598ed0eb8b459a446cac037206caa4066208.zip |
Fix PCH bug with member templates of local classes in nontemplate functions.
As noted by Richard in the post:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130624/082605.html, the following code should not add an entry
into PendingLocalImplicitInstantiations, since local instantiations
should only occur within the context of other instantiations:
int foo(double y) {
struct Lambda {
template<class T> T operator()(T t) const { return t; };
} lambda;
return lambda(y);
}
Hence the attached code does the following:
1) In MarkFunctionReferenced, check if ActiveInstantiations.size()
is non-zero before adding to PendingLocalImplicitInstantiations.
2) In InstantiateFunctionDefinition, we swap out/in
PendingLocalImplicitInstantiations so that only those
pending local instantiations that are added during the instantiation
of the current function are instantiated recursively.
llvm-svn: 184903
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index c947bcc9f2a..21a4cb12591 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2918,6 +2918,10 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // while we're still within our own instantiation context. SmallVector<VTableUse, 16> SavedVTableUses; std::deque<PendingImplicitInstantiation> SavedPendingInstantiations; + std::deque<PendingImplicitInstantiation> + SavedPendingLocalImplicitInstantiations; + SavedPendingLocalImplicitInstantiations.swap( + PendingLocalImplicitInstantiations); if (Recursive) { VTableUses.swap(SavedVTableUses); PendingInstantiations.swap(SavedPendingInstantiations); @@ -2998,6 +3002,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, "PendingInstantiations should be empty before it is discarded."); PendingInstantiations.swap(SavedPendingInstantiations); } + SavedPendingLocalImplicitInstantiations.swap( + PendingLocalImplicitInstantiations); } /// \brief Instantiate the definition of the given variable from its |