summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorFaisal Vali <faisalv@yahoo.com>2013-10-03 05:32:48 +0000
committerFaisal Vali <faisalv@yahoo.com>2013-10-03 05:32:48 +0000
commitba78d3434744a26a3f330151548a4386f2ca3c1f (patch)
tree9f79b9a0112f4fca962dee422d0f4f4d71ed18e4 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parent9e3e38ae3f002191ac171d41b15ca0c7608c646c (diff)
downloadbcm5719-llvm-ba78d3434744a26a3f330151548a4386f2ca3c1f.tar.gz
bcm5719-llvm-ba78d3434744a26a3f330151548a4386f2ca3c1f.zip
Teach TreeTransform and family how to transform generic lambdas within templates and nested within themselves.
This does not yet include capturing (that is next). Please see test file for examples. This patch was LGTM'd by Doug: http://llvm-reviews.chandlerc.com/D1784 llvm-svn: 191875
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 35f3616db6a..359fb73166d 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4171,6 +4171,30 @@ DeclContext *Sema::FindInstantiatedContext(SourceLocation Loc, DeclContext* DC,
NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
const MultiLevelTemplateArgumentList &TemplateArgs) {
DeclContext *ParentDC = D->getDeclContext();
+
+ // If we have a parameter from a non-dependent context with a non-dependent
+ // type it obviously can not be mapped to a different instantiated decl.
+ // Consider the code below, with explicit return types, when N gets
+ // specialized ...:
+ // template<class T> void fooT(T t) {
+ // auto L = [](auto a) -> void {
+ // auto M = [](char b) -> void {
+ // auto N = [](auto c) -> void {
+ // int x = sizeof(a) + sizeof(b) +
+ // sizeof(c);
+ // };
+ // N('a');
+ // };
+ // };
+ // L(3.14);
+ // }
+ // fooT('a');
+ // ... without this check below, findInstantiationOf fails with
+ // an assertion violation.
+ if (isa<ParmVarDecl>(D) && !ParentDC->isDependentContext() &&
+ !cast<ParmVarDecl>(D)->getType()->isInstantiationDependentType())
+ return D;
+
if (isa<ParmVarDecl>(D) || isa<NonTypeTemplateParmDecl>(D) ||
isa<TemplateTypeParmDecl>(D) || isa<TemplateTemplateParmDecl>(D) ||
(ParentDC->isFunctionOrMethod() && ParentDC->isDependentContext()) ||
OpenPOWER on IntegriCloud