Fixed handling of function arguments with template parameter types

This commit is contained in:
Bartek Kryza
2022-04-15 19:22:25 +02:00
parent c0678bc74c
commit 1dcbeb6e9c
2 changed files with 23 additions and 10 deletions

View File

@@ -197,14 +197,16 @@ void translation_unit_visitor::operator()(const cppast::cpp_entity &file)
void translation_unit_visitor::process_type_alias_template( void translation_unit_visitor::process_type_alias_template(
const cppast::cpp_alias_template &at) const cppast::cpp_alias_template &at)
{ {
if (at.type_alias().underlying_type().kind() == auto alias_kind = at.type_alias().underlying_type().kind();
cppast::cpp_type_kind::unexposed_t) { if (alias_kind == cppast::cpp_type_kind::unexposed_t) {
LOG_DBG("Template alias has unexposed underlying type: {}", LOG_DBG("Template alias has unexposed underlying type: {}",
static_cast<const cppast::cpp_unexposed_type &>( static_cast<const cppast::cpp_unexposed_type &>(
at.type_alias().underlying_type()) at.type_alias().underlying_type())
.name()); .name());
} }
else { else {
if (at.type_alias().underlying_type().kind() ==
cppast::cpp_type_kind::template_instantiation_t) {
auto tinst = build_template_instantiation( auto tinst = build_template_instantiation(
static_cast<const cppast::cpp_template_instantiation_type &>( static_cast<const cppast::cpp_template_instantiation_type &>(
resolve_alias(at.type_alias().underlying_type()))); resolve_alias(at.type_alias().underlying_type())));
@@ -213,9 +215,14 @@ void translation_unit_visitor::process_type_alias_template(
cx::util::full_name(ctx.get_namespace(), at), cx::util::full_name(ctx.get_namespace(), at),
type_safe::ref(at.type_alias().underlying_type())); type_safe::ref(at.type_alias().underlying_type()));
if (ctx.diagram().should_include(tinst->get_namespace(), tinst->name())) if (ctx.diagram().should_include(
tinst->get_namespace(), tinst->name()))
ctx.diagram().add_class(std::move(tinst)); ctx.diagram().add_class(std::move(tinst));
} }
else {
LOG_DBG("Unsupported alias target...");
}
}
} }
void translation_unit_visitor::process_type_alias( void translation_unit_visitor::process_type_alias(
@@ -1150,6 +1157,9 @@ void translation_unit_visitor::
for (const auto &template_argument : for (const auto &template_argument :
template_instantiation_type.arguments().value()) { template_instantiation_type.arguments().value()) {
if (!template_argument.type().has_value())
continue;
const auto template_argument_name = const auto template_argument_name =
cppast::to_string(template_argument.type().value()); cppast::to_string(template_argument.type().value());
if (template_parameter_names.count(template_argument_name) > if (template_parameter_names.count(template_argument_name) >

View File

@@ -375,6 +375,9 @@ bool translation_unit_visitor::find_relationships(const cppast::cpp_type &t_,
{ {
bool found{false}; bool found{false};
if (t_.kind() == cppast::cpp_type_kind::template_parameter_t)
return false;
const auto fn = cx::util::full_name( const auto fn = cx::util::full_name(
resolve_alias(cppast::remove_cv(t_)), ctx.entity_index(), false); resolve_alias(cppast::remove_cv(t_)), ctx.entity_index(), false);
auto t_ns = common::model::namespace_{fn}; auto t_ns = common::model::namespace_{fn};