Added filtering of nested template dependencies

This commit is contained in:
Bartek Kryza
2021-08-07 21:02:17 +02:00
parent 0d0f93164d
commit cef3a2df67

View File

@@ -1259,51 +1259,56 @@ class_ tu_visitor::build_template_instantiation(
LOG_DBG("Template argument is a type {}", ct.type); LOG_DBG("Template argument is a type {}", ct.type);
if (targ.type().value().kind() == auto fn = cx::util::full_name(
cppast::cpp_type_kind::template_instantiation_t) { cppast::remove_cv(cx::util::unreferenced(targ.type().value())),
class_ nested_tinst = build_template_instantiation(static_cast< ctx.entity_index, false);
const cppast::cpp_template_instantiation_type &>(
targ.type().value()));
auto fn = cx::util::full_name( if (ctx.config.should_include(fn)) {
cppast::remove_cv(
cx::util::unreferenced(targ.type().value())),
ctx.entity_index, false);
fn = util::split(fn, "<")[0];
class_relationship tinst_dependency; if (targ.type().value().kind() ==
tinst_dependency.type = relationship_t::kDependency; cppast::cpp_type_kind::template_instantiation_t) {
tinst_dependency.label = ""; class_ nested_tinst =
build_template_instantiation(static_cast<
const cppast::cpp_template_instantiation_type &>(
targ.type().value()));
tinst_dependency.destination = fn = util::split(fn, "<")[0];
nested_tinst.full_name(ctx.config.using_namespace);
LOG_DBG("Creating nested template dependency to template " class_relationship tinst_dependency;
"instantiation {} -> {}", tinst_dependency.type = relationship_t::kDependency;
tinst.full_name(ctx.config.using_namespace), tinst_dependency.label = "";
tinst_dependency.destination);
tinst.add_relationship(std::move(tinst_dependency)); tinst_dependency.destination =
nested_tinst.full_name(ctx.config.using_namespace);
ctx.d.add_class(std::move(nested_tinst)); LOG_DBG("Creating nested template dependency to template "
} "instantiation {} -> {}",
else if (targ.type().value().kind() == tinst.full_name(ctx.config.using_namespace),
cppast::cpp_type_kind::user_defined_t) { tinst_dependency.destination);
class_relationship tinst_dependency;
tinst_dependency.type = relationship_t::kDependency;
tinst_dependency.label = "";
tinst_dependency.destination = cx::util::full_name( tinst.add_relationship(std::move(tinst_dependency));
cppast::remove_cv(
cx::util::unreferenced(targ.type().value())),
ctx.entity_index, false);
LOG_DBG("Creating nested template dependency to user defined " ctx.d.add_class(std::move(nested_tinst));
}
else if (targ.type().value().kind() ==
cppast::cpp_type_kind::user_defined_t) {
class_relationship tinst_dependency;
tinst_dependency.type = relationship_t::kDependency;
tinst_dependency.label = "";
tinst_dependency.destination = cx::util::full_name(
cppast::remove_cv(
cx::util::unreferenced(targ.type().value())),
ctx.entity_index, false);
LOG_DBG(
"Creating nested template dependency to user defined "
"type {} -> {}", "type {} -> {}",
tinst.full_name(ctx.config.using_namespace), tinst.full_name(ctx.config.using_namespace),
tinst_dependency.destination); tinst_dependency.destination);
tinst.add_relationship(std::move(tinst_dependency)); tinst.add_relationship(std::move(tinst_dependency));
}
} }
} }
else if (targ.expression()) { else if (targ.expression()) {