@@ -215,7 +215,8 @@ template <typename VisitorT> class template_builder {
215215 * @return Return template argument model
216216 */
217217 template_parameter process_integral_argument (
218- const clang::TemplateArgument &arg);
218+ const clang::TemplateArgument &arg,
219+ const clang::ASTContext &ast_context);
219220
220221#if LLVM_VERSION_MAJOR > 17
221222 /* *
@@ -229,7 +230,8 @@ template <typename VisitorT> class template_builder {
229230 * @return Return template argument model
230231 */
231232 template_parameter process_structural_argument (
232- const clang::TemplateArgument &arg);
233+ const clang::TemplateArgument &arg,
234+ const clang::ASTContext &ast_context);
233235#endif
234236
235237 /* *
@@ -638,7 +640,13 @@ void template_builder<VisitorT>::build_from_template_declaration(
638640 std::optional<std::string> default_arg;
639641 if (template_type_parameter->hasDefaultArgument ()) {
640642 default_arg =
643+ #if LLVM_VERSION_MAJOR > 18
644+ common::to_string (
645+ template_type_parameter->getDefaultArgument (),
646+ template_declaration.getASTContext ());
647+ #else
641648 template_type_parameter->getDefaultArgument ().getAsString ();
649+ #endif
642650 }
643651
644652 auto parameter_name = template_type_parameter->getNameAsString ();
@@ -686,10 +694,17 @@ void template_builder<VisitorT>::build_from_template_declaration(
686694
687695 std::optional<std::string> default_arg;
688696
689- if (template_nontype_parameter->hasDefaultArgument ())
690- default_arg = common::to_string (
691- template_nontype_parameter->getDefaultArgument ());
692-
697+ if (template_nontype_parameter->hasDefaultArgument ()) {
698+ default_arg =
699+ #if LLVM_VERSION_MAJOR > 18
700+ common::to_string (
701+ template_nontype_parameter->getDefaultArgument (),
702+ template_declaration.getASTContext ());
703+ #else
704+ common::to_string (
705+ template_nontype_parameter->getDefaultArgument ());
706+ #endif
707+ }
693708 auto ct = template_parameter::make_non_type_template (
694709 template_nontype_parameter->getType ().getAsString (),
695710 template_nontype_parameter->getNameAsString (), default_arg,
@@ -1046,7 +1061,8 @@ void template_builder<VisitorT>::argument_process_dispatch(
10461061 argument.push_back (process_nullptr_argument (arg));
10471062 break ;
10481063 case clang::TemplateArgument::Integral:
1049- argument.push_back (process_integral_argument (arg));
1064+ argument.push_back (
1065+ process_integral_argument (arg, template_decl->getASTContext ()));
10501066 break ;
10511067 case clang::TemplateArgument::TemplateExpansion:
10521068 argument.push_back (process_template_expansion (arg));
@@ -1226,27 +1242,39 @@ bool template_builder<VisitorT>::
12261242
12271243template <typename VisitorT>
12281244template_parameter template_builder<VisitorT>::process_integral_argument(
1229- const clang::TemplateArgument &arg)
1245+ const clang::TemplateArgument &arg, const clang::ASTContext &ast_context )
12301246{
12311247 assert (arg.getKind () == clang::TemplateArgument::Integral);
12321248
12331249 std::string result;
12341250 llvm::raw_string_ostream ostream (result);
1251+ clang::PrintingPolicy policy (ast_context.getLangOpts ());
1252+
1253+ #if LLVM_VERSION_MAJOR > 18
1254+ arg.print (policy, ostream, false );
1255+ #else
12351256 arg.dump (ostream);
1257+ #endif
12361258
12371259 return template_parameter::make_argument (result);
12381260}
12391261
12401262#if LLVM_VERSION_MAJOR > 17
12411263template <typename VisitorT>
12421264template_parameter template_builder<VisitorT>::process_structural_argument(
1243- const clang::TemplateArgument &arg)
1265+ const clang::TemplateArgument &arg, const clang::ASTContext &ast_context )
12441266{
12451267 assert (arg.getKind () == clang::TemplateArgument::StructuralValue);
12461268
12471269 std::string result;
12481270 llvm::raw_string_ostream ostream (result);
1271+ clang::PrintingPolicy policy (ast_context.getLangOpts ());
1272+
1273+ #if LLVM_VERSION_MAJOR > 18
1274+ arg.print (policy, ostream, false );
1275+ #else
12491276 arg.dump (ostream);
1277+ #endif
12501278
12511279 return template_parameter::make_argument (result);
12521280}
0 commit comments