Fixed generation of dependent template argument names (#146)

This commit is contained in:
Bartek Kryza
2023-05-20 11:40:12 +02:00
parent bca1162b16
commit 044c9ced19
3 changed files with 29 additions and 7 deletions

View File

@@ -484,10 +484,9 @@ void template_builder::argument_process_dispatch(
template_parameter template_builder::process_template_argument(
const clang::TemplateArgument &arg)
{
LOG_DBG("Processing template argument: {}", common::to_string(arg));
auto arg_name = common::to_string(arg);
auto arg_name =
arg.getAsTemplate().getAsTemplateDecl()->getQualifiedNameAsString();
LOG_DBG("Processing template argument: {}", arg_name);
return template_parameter::make_template_type(arg_name);
}
@@ -495,11 +494,14 @@ template_parameter template_builder::process_template_argument(
template_parameter template_builder::process_template_expansion(
const clang::TemplateArgument &arg)
{
LOG_DBG(
"Processing template expansion argument: {}", common::to_string(arg));
auto arg_name = common::to_string(arg);
auto arg_name =
arg.getAsTemplate().getAsTemplateDecl()->getQualifiedNameAsString();
LOG_DBG("Processing template expansion argument: {}", arg_name);
util::apply_if_not_null(
arg.getAsTemplate().getAsTemplateDecl(), [&arg_name](const auto *decl) {
arg_name = decl->getQualifiedNameAsString();
});
auto param = template_parameter::make_template_type(arg_name);
param.is_variadic(true);

View File

@@ -205,11 +205,29 @@ std::string to_string(
return "nullptr";
case clang::TemplateArgument::Integral:
return std::to_string(arg.getAsIntegral().getExtValue());
case clang::TemplateArgument::Template:
return to_string(arg.getAsTemplate());
case clang::TemplateArgument::TemplateExpansion:
return to_string(arg.getAsTemplateOrTemplatePattern());
default:
return "";
}
}
std::string to_string(const clang::TemplateName &templ)
{
if (templ.getAsTemplateDecl() != nullptr) {
return templ.getAsTemplateDecl()->getQualifiedNameAsString();
}
std::string result;
const clang::LangOptions lang_options;
llvm::raw_string_ostream ostream(result);
templ.print(ostream, clang::PrintingPolicy(lang_options));
return result;
}
std::string to_string(const clang::Expr *expr)
{
const clang::LangOptions lang_options;

View File

@@ -92,6 +92,8 @@ std::string to_string(const clang::FunctionTemplateDecl *decl);
std::string to_string(const clang::TypeConstraint *tc);
std::string to_string(const clang::TemplateName &templ);
std::string get_source_text_raw(
clang::SourceRange range, const clang::SourceManager &sm);