Fix handling of template template arguments which are not expressions (#199)
This commit is contained in:
@@ -238,6 +238,11 @@ std::string to_string(const clang::Expr *expr)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string to_string(const clang::ValueDecl *val)
|
||||
{
|
||||
return val->getQualifiedNameAsString();
|
||||
}
|
||||
|
||||
std::string to_string(const clang::Stmt *stmt)
|
||||
{
|
||||
const clang::LangOptions lang_options;
|
||||
|
||||
@@ -111,6 +111,8 @@ std::string to_string(
|
||||
|
||||
std::string to_string(const clang::Expr *expr);
|
||||
|
||||
std::string to_string(const clang::ValueDecl *val);
|
||||
|
||||
std::string to_string(const clang::Stmt *stmt);
|
||||
|
||||
std::string to_string(const clang::FunctionTemplateDecl *decl);
|
||||
|
||||
@@ -76,7 +76,7 @@ clang::ASTContext *call_expression_context::get_ast_context() const
|
||||
}
|
||||
|
||||
if (current_method_decl_ != nullptr) {
|
||||
return ¤t_function_decl_->getASTContext();
|
||||
return ¤t_method_decl_->getASTContext();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -1601,11 +1601,20 @@ 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())
|
||||
default_arg = common::to_string(
|
||||
if (template_template_parameter->hasDefaultArgument()) {
|
||||
const auto &def_arg =
|
||||
template_template_parameter->getDefaultArgument()
|
||||
.getArgument()
|
||||
.getAsExpr());
|
||||
.getArgument();
|
||||
if (def_arg.getKind() ==
|
||||
clang::TemplateArgument::ArgKind::Expression) {
|
||||
default_arg = common::to_string(def_arg.getAsExpr());
|
||||
}
|
||||
else if (def_arg.getKind() ==
|
||||
clang::TemplateArgument::ArgKind::Declaration) {
|
||||
default_arg = common::to_string(def_arg.getAsDecl());
|
||||
}
|
||||
}
|
||||
|
||||
auto ct = template_parameter::make_template_template_type(
|
||||
template_template_parameter->getNameAsString(), default_arg,
|
||||
template_template_parameter->isParameterPack());
|
||||
|
||||
Reference in New Issue
Block a user