Fixed handling of template template default arguments
This commit is contained in:
@@ -1006,11 +1006,11 @@ bool translation_unit_visitor::process_template_parameters(
|
||||
clang::dyn_cast_or_null<clang::TemplateTemplateParmDecl>(
|
||||
parameter);
|
||||
std::optional<std::string> default_arg;
|
||||
if (template_template_parameter->hasDefaultArgument())
|
||||
if (template_template_parameter->hasDefaultArgument()) {
|
||||
default_arg = common::to_string(
|
||||
template_template_parameter->getDefaultArgument()
|
||||
.getArgument()
|
||||
.getAsExpr());
|
||||
.getArgument());
|
||||
}
|
||||
auto ct = template_parameter::make_template_template_type(
|
||||
template_template_parameter->getNameAsString(), default_arg,
|
||||
template_template_parameter->isParameterPack());
|
||||
|
||||
@@ -169,6 +169,24 @@ std::string to_string(const clang::RecordType &type,
|
||||
return to_string(type.desugar(), ctx, try_canonical);
|
||||
}
|
||||
|
||||
std::string to_string(const clang::TemplateArgument &arg)
|
||||
{
|
||||
switch (arg.getKind()) {
|
||||
case clang::TemplateArgument::Expression:
|
||||
return to_string(arg.getAsExpr());
|
||||
case clang::TemplateArgument::Type:
|
||||
return to_string(arg.getAsType());
|
||||
case clang::TemplateArgument::Null:
|
||||
return "";
|
||||
case clang::TemplateArgument::NullPtr:
|
||||
return "nullptr";
|
||||
case clang::TemplateArgument::Integral:
|
||||
return std::to_string(arg.getAsIntegral().getExtValue());
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::string to_string(const clang::Expr *expr)
|
||||
{
|
||||
const clang::LangOptions lang_options;
|
||||
|
||||
@@ -81,6 +81,8 @@ std::string to_string(const clang::QualType &type, const clang::ASTContext &ctx,
|
||||
std::string to_string(const clang::RecordType &type,
|
||||
const clang::ASTContext &ctx, bool try_canonical = true);
|
||||
|
||||
std::string to_string(const clang::TemplateArgument &arg);
|
||||
|
||||
std::string to_string(const clang::Expr *expr);
|
||||
|
||||
std::string to_string(const clang::Stmt *stmt);
|
||||
|
||||
Reference in New Issue
Block a user