@@ -1084,12 +1084,22 @@ DeclarationFragmentsBuilder::getFragmentsForTemplateArguments(
1084
1084
1085
1085
if (StringRef (ArgumentFragment.begin ()->Spelling )
1086
1086
.starts_with (" type-parameter" )) {
1087
- std::string ProperArgName = TemplateArgumentLocs.value ()[i]
1088
- .getTypeSourceInfo ()
1089
- ->getType ()
1090
- .getAsString ();
1091
- ArgumentFragment.begin ()->Spelling .swap (ProperArgName);
1087
+ if (TemplateArgumentLocs.has_value () &&
1088
+ TemplateArgumentLocs->size () > i) {
1089
+ std::string ProperArgName = TemplateArgumentLocs.value ()[i]
1090
+ .getTypeSourceInfo ()
1091
+ ->getType ()
1092
+ .getAsString ();
1093
+ ArgumentFragment.begin ()->Spelling .swap (ProperArgName);
1094
+ } else {
1095
+ auto &Spelling = ArgumentFragment.begin ()->Spelling ;
1096
+ Spelling.clear ();
1097
+ raw_string_ostream OutStream (Spelling);
1098
+ CTA.print (Context.getPrintingPolicy (), OutStream, false );
1099
+ OutStream.flush ();
1100
+ }
1092
1101
}
1102
+
1093
1103
Fragments.append (std::move (ArgumentFragment));
1094
1104
break ;
1095
1105
}
@@ -1212,9 +1222,9 @@ DeclarationFragmentsBuilder::getFragmentsForClassTemplateSpecialization(
1212
1222
cast<CXXRecordDecl>(Decl)))
1213
1223
.pop_back () // there is an extra semicolon now
1214
1224
.append (" <" , DeclarationFragments::FragmentKind::Text)
1215
- .append (
1216
- getFragmentsForTemplateArguments ( Decl->getTemplateArgs ().asArray (),
1217
- Decl->getASTContext (), std::nullopt ))
1225
+ .append (getFragmentsForTemplateArguments (
1226
+ Decl->getTemplateArgs ().asArray (), Decl-> getASTContext (),
1227
+ Decl->getTemplateArgsAsWritten ()-> arguments () ))
1218
1228
.append (" >" , DeclarationFragments::FragmentKind::Text)
1219
1229
.appendSemicolon ();
1220
1230
}
@@ -1255,9 +1265,9 @@ DeclarationFragmentsBuilder::getFragmentsForVarTemplateSpecialization(
1255
1265
.append (DeclarationFragmentsBuilder::getFragmentsForVarTemplate (Decl))
1256
1266
.pop_back () // there is an extra semicolon now
1257
1267
.append (" <" , DeclarationFragments::FragmentKind::Text)
1258
- .append (
1259
- getFragmentsForTemplateArguments ( Decl->getTemplateArgs ().asArray (),
1260
- Decl->getASTContext (), std::nullopt ))
1268
+ .append (getFragmentsForTemplateArguments (
1269
+ Decl->getTemplateArgs ().asArray (), Decl-> getASTContext (),
1270
+ Decl->getTemplateArgsAsWritten ()-> arguments () ))
1261
1271
.append (" >" , DeclarationFragments::FragmentKind::Text)
1262
1272
.appendSemicolon ();
1263
1273
}
0 commit comments