All test cases passing
This commit is contained in:
@@ -219,12 +219,18 @@ void diagram::get_parents(
|
||||
bool found_new{false};
|
||||
for (const auto &parent : parents) {
|
||||
for (const auto &pp : parent.get().parents()) {
|
||||
LOG_DBG("=-=-=-=-=-=-= {} HAS PARENT {} [{}]",
|
||||
parent.get().full_name(false), pp.name(), pp.id());
|
||||
auto p = get_class(pp.id());
|
||||
|
||||
if (p.has_value()) {
|
||||
auto [it, found] = parents.emplace(std::ref(p.value()));
|
||||
if (found)
|
||||
found_new = true;
|
||||
}
|
||||
else {
|
||||
LOG_DBG("=-=-=-=-=-=-= {} NOT FOUND IN DIAGRAM", pp.id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -583,7 +583,7 @@ void translation_unit_visitor::process_record_containment(
|
||||
}
|
||||
|
||||
void translation_unit_visitor::process_class_bases(
|
||||
const clang::CXXRecordDecl *cls, class_ &c) const
|
||||
const clang::CXXRecordDecl *cls, class_ &c)
|
||||
{
|
||||
for (auto &base : cls->bases()) {
|
||||
class_parent cp;
|
||||
@@ -597,8 +597,12 @@ void translation_unit_visitor::process_class_bases(
|
||||
*base.getType()->getAs<clang::RecordType>()->getDecl()));
|
||||
else if (base.getType()->getAs<clang::TemplateSpecializationType>() !=
|
||||
nullptr) {
|
||||
cp.set_id(common::to_id(
|
||||
*base.getType()->getAs<clang::TemplateSpecializationType>()));
|
||||
auto template_specialization_ptr = build_template_instantiation(
|
||||
*base.getType()->getAs<clang::TemplateSpecializationType>(),
|
||||
{});
|
||||
if (template_specialization_ptr) {
|
||||
cp.set_id(template_specialization_ptr->id());
|
||||
}
|
||||
}
|
||||
else
|
||||
// This could be a template parameter - we don't want it here
|
||||
@@ -1000,26 +1004,19 @@ void translation_unit_visitor::
|
||||
.getAsTemplateDecl()
|
||||
->getQualifiedNameAsString();
|
||||
|
||||
auto template_specialization_ptr =
|
||||
build_template_instantiation(template_instantiation_type);
|
||||
|
||||
if (diagram().should_include(template_field_decl_name)) {
|
||||
if (template_instantiation_type.isDependentType()) {
|
||||
if (get_ast_local_id(template_instantiation_type.getTemplateName()
|
||||
.getAsTemplateDecl()
|
||||
->getID())
|
||||
.has_value()) {
|
||||
if (template_specialization_ptr) {
|
||||
relationship r{relationship_t::kDependency,
|
||||
get_ast_local_id(
|
||||
template_instantiation_type.getTemplateName()
|
||||
.getAsTemplateDecl()
|
||||
->getID())
|
||||
.value()};
|
||||
template_specialization_ptr->id()};
|
||||
|
||||
c.add_relationship(std::move(r));
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto template_specialization_ptr =
|
||||
build_template_instantiation(template_instantiation_type);
|
||||
|
||||
if (template_specialization_ptr) {
|
||||
relationship r{relationship_t::kDependency,
|
||||
template_specialization_ptr->id()};
|
||||
@@ -1470,8 +1467,6 @@ std::unique_ptr<class_> translation_unit_visitor::build_template_instantiation(
|
||||
ns.pop_back();
|
||||
template_instantiation.set_name(template_decl->getNameAsString());
|
||||
template_instantiation.set_namespace(ns);
|
||||
template_instantiation.set_id(template_decl->getID() +
|
||||
(std::hash<std::string>{}(full_template_specialization_name) >> 4));
|
||||
|
||||
// TODO: Refactor handling of base parameters to a separate method
|
||||
|
||||
@@ -1584,6 +1579,9 @@ std::unique_ptr<class_> translation_unit_visitor::build_template_instantiation(
|
||||
template_instantiation_ptr->full_name(false));
|
||||
}
|
||||
|
||||
template_instantiation.set_id(
|
||||
common::to_id(template_instantiation_ptr->full_name(false)));
|
||||
|
||||
return template_instantiation_ptr;
|
||||
}
|
||||
|
||||
@@ -2058,7 +2056,7 @@ void translation_unit_visitor::add_incomplete_forward_declarations()
|
||||
|
||||
void translation_unit_visitor::finalize()
|
||||
{
|
||||
// add_incomplete_forward_declarations();
|
||||
add_incomplete_forward_declarations();
|
||||
}
|
||||
|
||||
bool translation_unit_visitor::simplify_system_template(
|
||||
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
clanguml::class_diagram::model::class_ &c);
|
||||
|
||||
void process_class_bases(const clang::CXXRecordDecl *cls,
|
||||
clanguml::class_diagram::model::class_ &c) const;
|
||||
clanguml::class_diagram::model::class_ &c);
|
||||
|
||||
void process_class_children(const clang::CXXRecordDecl *cls,
|
||||
clanguml::class_diagram::model::class_ &c);
|
||||
|
||||
@@ -52,10 +52,7 @@ template <> id_t to_id(const clang::CXXRecordDecl &declaration)
|
||||
|
||||
template <> id_t to_id(const clang::EnumType &t) { return to_id(*t.getDecl()); }
|
||||
|
||||
template <> id_t to_id(const clang::TemplateSpecializationType &t)
|
||||
{
|
||||
return t.getTemplateName().getAsTemplateDecl()->getID();
|
||||
}
|
||||
// template <> id_t to_id(const clang::TemplateSpecializationType &t);
|
||||
|
||||
template <> id_t to_id(const std::filesystem::path &file)
|
||||
{
|
||||
|
||||
@@ -229,15 +229,25 @@ tvl::value_t subclass_filter::match(const diagram &d, const element &e) const
|
||||
if (!class_ref.has_value())
|
||||
return false;
|
||||
|
||||
LOG_DBG("====================== LOOKING FOR PARENTS OF {} ===========", fn);
|
||||
|
||||
parents.emplace(class_ref.value());
|
||||
|
||||
cd.get_parents(parents);
|
||||
|
||||
std::vector<std::string> parents_names;
|
||||
for (const auto p : parents)
|
||||
parents_names.push_back(p.get().full_name(false));
|
||||
|
||||
LOG_DBG("====================== FOUND PARENTS {} ==========",
|
||||
fmt::join(parents_names, ", "));
|
||||
|
||||
// Now check if any of the parents matches the roots specified in the
|
||||
// filter config
|
||||
for (const auto &root : roots_) {
|
||||
for (const auto &parent : parents) {
|
||||
auto full_name = parent.get().full_name(false);
|
||||
LOG_DBG("+++ COMPARING {} WITH {}", root, full_name);
|
||||
if (root == full_name)
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user