@@ -1073,12 +1073,22 @@ DeclarationFragmentsBuilder::getFragmentsForTemplateArguments(
1073
1073
1074
1074
if (StringRef (ArgumentFragment.begin ()->Spelling )
1075
1075
.starts_with (" type-parameter" )) {
1076
- std::string ProperArgName = TemplateArgumentLocs.value ()[i]
1077
- .getTypeSourceInfo ()
1078
- ->getType ()
1079
- .getAsString ();
1080
- ArgumentFragment.begin ()->Spelling .swap (ProperArgName);
1076
+ if (TemplateArgumentLocs.has_value () &&
1077
+ TemplateArgumentLocs->size () > i) {
1078
+ std::string ProperArgName = TemplateArgumentLocs.value ()[i]
1079
+ .getTypeSourceInfo ()
1080
+ ->getType ()
1081
+ .getAsString ();
1082
+ ArgumentFragment.begin ()->Spelling .swap (ProperArgName);
1083
+ } else {
1084
+ auto &Spelling = ArgumentFragment.begin ()->Spelling ;
1085
+ Spelling.clear ();
1086
+ raw_string_ostream OutStream (Spelling);
1087
+ CTA.print (Context.getPrintingPolicy (), OutStream, false );
1088
+ OutStream.flush ();
1089
+ }
1081
1090
}
1091
+
1082
1092
Fragments.append (std::move (ArgumentFragment));
1083
1093
break ;
1084
1094
}
@@ -1194,9 +1204,9 @@ DeclarationFragmentsBuilder::getFragmentsForClassTemplateSpecialization(
1194
1204
cast<CXXRecordDecl>(Decl)))
1195
1205
.pop_back () // there is an extra semicolon now
1196
1206
.append (" <" , DeclarationFragments::FragmentKind::Text)
1197
- .append (
1198
- getFragmentsForTemplateArguments ( Decl->getTemplateArgs ().asArray (),
1199
- Decl->getASTContext (), std::nullopt ))
1207
+ .append (getFragmentsForTemplateArguments (
1208
+ Decl->getTemplateArgs ().asArray (), Decl-> getASTContext (),
1209
+ Decl->getTemplateArgsAsWritten ()-> arguments () ))
1200
1210
.append (" >" , DeclarationFragments::FragmentKind::Text)
1201
1211
.appendSemicolon ();
1202
1212
}
@@ -1237,9 +1247,9 @@ DeclarationFragmentsBuilder::getFragmentsForVarTemplateSpecialization(
1237
1247
.append (DeclarationFragmentsBuilder::getFragmentsForVarTemplate (Decl))
1238
1248
.pop_back () // there is an extra semicolon now
1239
1249
.append (" <" , DeclarationFragments::FragmentKind::Text)
1240
- .append (
1241
- getFragmentsForTemplateArguments ( Decl->getTemplateArgs ().asArray (),
1242
- Decl->getASTContext (), std::nullopt ))
1250
+ .append (getFragmentsForTemplateArguments (
1251
+ Decl->getTemplateArgs ().asArray (), Decl-> getASTContext (),
1252
+ Decl->getTemplateArgsAsWritten ()-> arguments () ))
1243
1253
.append (" >" , DeclarationFragments::FragmentKind::Text)
1244
1254
.appendSemicolon ();
1245
1255
}
0 commit comments