Fixed handling of relationships to nested structs

This commit is contained in:
Bartek Kryza
2024-06-18 22:00:50 +02:00
parent fa94022c58
commit 9a43ebe739
4 changed files with 16 additions and 7 deletions

View File

@@ -241,10 +241,17 @@ void diagram::remove_redundant_dependencies()
}
util::erase_if(c.get().relationships(),
[&dependency_relationships_to_remove](const auto &r) {
return r.type() == relationship_t::kDependency &&
[&dependency_relationships_to_remove, &c](const auto &r) {
if (r.type() != relationship_t::kDependency)
return false;
auto has_another_relationship_to_destination =
dependency_relationships_to_remove.count(r.destination()) >
0;
auto is_self_dependency = r.destination() == c.get().id();
return has_another_relationship_to_destination ||
is_self_dependency;
});
}
}

View File

@@ -1433,13 +1433,13 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
}
}
else if (type->getAsCXXRecordDecl() != nullptr) {
const auto target_id = common::to_id(*type->getAsCXXRecordDecl());
relationships.emplace_back(target_id, relationship_hint);
relationships.emplace_back(
type->getAsCXXRecordDecl()->getID(), relationship_hint);
result = true;
}
else {
const auto target_id = common::to_id(*type->getAsRecordDecl());
relationships.emplace_back(target_id, relationship_hint);
relationships.emplace_back(
type->getAsRecordDecl()->getID(), relationship_hint);
result = true;
}
}

View File

@@ -43,5 +43,7 @@ TEST_CASE("t00076")
REQUIRE(!IsClass(src, "H"));
REQUIRE(!IsClass(src, "EE"));
REQUIRE(!IsClass(src, "GGG"));
REQUIRE(IsAssociation<Public>(src, "B", "B::BB"));
});
}

View File

@@ -668,7 +668,7 @@ int main(int argc, char *argv[])
std::vector<const char *> argvv = {
"clang-uml", "--config", "./test_config_data/simple.yml"};
argvv.push_back("-vvv");
argvv.push_back("-q");
clih.handle_options(argvv.size(), argvv.data());