Fix crash mangling an explicit lambda non-type template parameter pack

that is not a pack expansion.

llvm-svn: 371476
This commit is contained in:
Richard Smith 2019-09-10 00:39:53 +00:00
parent 79707ecd7d
commit ae6f7bcb36
2 changed files with 8 additions and 1 deletions

View File

@ -1704,7 +1704,8 @@ void CXXNameMangler::mangleTemplateParamDecl(const NamedDecl *Decl) {
QualType T = Tn->getType();
if (Tn->isParameterPack()) {
Out << "Tp";
T = T->castAs<PackExpansionType>()->getPattern();
if (auto *PackExpansion = T->getAs<PackExpansionType>())
T = PackExpansion->getPattern();
}
Out << "Tn";
mangleType(T);

View File

@ -54,6 +54,12 @@ inline void collision() {
}
void use_collision() { collision(); }
namespace pack_not_pack_expansion {
template<typename T, int, T...> struct X;
// CHECK: @_ZNK23pack_not_pack_expansion1xMUlTyTtTyTnT_TpTnTL0__ETpTyvE_clIiNS_1XEJfEEEDav
inline auto x = []<typename T, template<typename U, T, U...> typename, typename ...V>(){}; void f() { x.operator()<int, X, float>(); }
}
template<typename> void f() {
// CHECK: define linkonce_odr {{.*}} @_ZZ1fIiEvvENKUlT_E_clIiEEDaS0_(
auto x = [](auto){};