From 9fb69cd3b8aea83f982d580be44b0b133d615335 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 4 Sep 2019 22:14:50 +0000 Subject: [PATCH] For PR43213, track whether template parameters are implicit through template instantiation so we know whether to mangle them in lambda-expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370991 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplateInstantiateDecl.cpp | 3 +++ test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 6e4f9b9947..5ef16b4a37 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2337,6 +2337,7 @@ Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl( D->getDepth() - TemplateArgs.getNumSubstitutedLevels(), D->getIndex(), D->getIdentifier(), D->wasDeclaredWithTypename(), D->isParameterPack()); Inst->setAccess(AS_public); + Inst->setImplicit(D->isImplicit()); if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) { TypeSourceInfo *InstantiatedDefaultArg = @@ -2483,6 +2484,7 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( D->getPosition(), D->getIdentifier(), T, D->isParameterPack(), DI); Param->setAccess(AS_public); + Param->setImplicit(D->isImplicit()); if (Invalid) Param->setInvalidDecl(); @@ -2626,6 +2628,7 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( D->getDefaultArgument().getTemplateNameLoc())); } Param->setAccess(AS_public); + Param->setImplicit(D->isImplicit()); // Introduce this template parameter's instantiation into the instantiation // scope. diff --git a/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp b/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp index 3bec64156a..b88b0d56fd 100644 --- a/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp +++ b/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp @@ -32,3 +32,10 @@ inline void inline_func() { void call_inline_func() { inline_func(); } + +template void f() { + // CHECK: define linkonce_odr {{.*}} @_ZZ1fIiEvvENKUlT_E_clIiEEDaS0_( + auto x = [](auto){}; + x(0); +} +void use_f() { f(); } -- 2.40.0