@@ -616,8 +616,6 @@ static Decl* GetScopeFromType(QualType QT) {
616
616
Type = Type->getUnqualifiedDesugaredType ();
617
617
if (auto * ET = llvm::dyn_cast<EnumType>(Type))
618
618
return ET->getDecl ();
619
- if (auto * FnType = llvm::dyn_cast<FunctionProtoType>(Type))
620
- Type = const_cast <clang::Type*>(FnType->getReturnType ().getTypePtr ());
621
619
return Type->getAsCXXRecordDecl ();
622
620
}
623
621
return 0 ;
@@ -1689,6 +1687,10 @@ std::string GetTypeAsString(TCppType_t var) {
1689
1687
PrintingPolicy Policy ((LangOptions ()));
1690
1688
Policy.Bool = true ; // Print bool instead of _Bool.
1691
1689
Policy.SuppressTagKeyword = true ; // Do not print `class std::string`.
1690
+ #if CLANG_VERSION_MAJOR > 16
1691
+ Policy.SuppressElaboration = true ;
1692
+ #endif
1693
+ Policy.FullyQualifiedName = true ;
1692
1694
return compat::FixTypeName (QT.getAsString (Policy));
1693
1695
}
1694
1696
@@ -2103,6 +2105,30 @@ void make_narg_call(const FunctionDecl* FD, const std::string& return_type,
2103
2105
std::string template_args = complete_name.substr (idx);
2104
2106
name = name_without_template_args +
2105
2107
(template_args.empty () ? " " : " " + template_args);
2108
+
2109
+ // If a template has consecutive parameter packs, then it is impossible to
2110
+ // use the explicit name in the wrapper, since the type deduction is what
2111
+ // determines the split of the packs. Instead, we'll revert to the
2112
+ // non-templated function name and hope that the type casts in the wrapper
2113
+ // will suffice.
2114
+ if (FD->isTemplateInstantiation () && FD->getPrimaryTemplate ()) {
2115
+ const FunctionTemplateDecl* FTDecl =
2116
+ llvm::dyn_cast<FunctionTemplateDecl>(FD->getPrimaryTemplate ());
2117
+ if (FTDecl) {
2118
+ auto * templateParms = FTDecl->getTemplateParameters ();
2119
+ int numPacks = 0 ;
2120
+ for (size_t iParam = 0 , nParams = templateParms->size ();
2121
+ iParam < nParams; ++iParam) {
2122
+ if (templateParms->getParam (iParam)->isTemplateParameterPack ())
2123
+ numPacks += 1 ;
2124
+ else
2125
+ numPacks = 0 ;
2126
+ }
2127
+ if (numPacks > 1 ) {
2128
+ name = name_without_template_args;
2129
+ }
2130
+ }
2131
+ }
2106
2132
}
2107
2133
if (op_flag || N <= 1 )
2108
2134
callbuf << name;
@@ -3422,6 +3448,8 @@ static Decl* InstantiateTemplate(TemplateDecl* TemplateD,
3422
3448
// This will instantiate tape<T> type and return it.
3423
3449
SourceLocation noLoc;
3424
3450
QualType TT = S.CheckTemplateIdType (TemplateName (TemplateD), noLoc, TLI);
3451
+ if (TT.isNull ())
3452
+ return nullptr ;
3425
3453
3426
3454
// Perhaps we can extract this into a new interface.
3427
3455
S.RequireCompleteType (fakeLoc, TT, diag::err_tentative_def_incomplete_type);
0 commit comments