Fixed t00007
This commit is contained in:
@@ -410,7 +410,6 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
|
|||||||
clanguml::common::model::relationship_t relationship_hint)
|
clanguml::common::model::relationship_t relationship_hint)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
std::string type_name = type.getAsString();
|
std::string type_name = type.getAsString();
|
||||||
(void)type_name;
|
(void)type_name;
|
||||||
|
|
||||||
@@ -433,14 +432,21 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
|
|||||||
find_relationships(type->getAsArrayTypeUnsafe()->getElementType(),
|
find_relationships(type->getAsArrayTypeUnsafe()->getElementType(),
|
||||||
relationships, relationship_t::kAggregation);
|
relationships, relationship_t::kAggregation);
|
||||||
}
|
}
|
||||||
else if (type->isClassType()) {
|
else if (type->isRecordType()) {
|
||||||
|
if(type_name.find("std::shared_ptr") == 0)
|
||||||
|
relationship_hint = relationship_t::kAssociation;
|
||||||
|
if(type_name.find("std::weak_ptr") == 0)
|
||||||
|
relationship_hint = relationship_t::kAssociation;
|
||||||
|
|
||||||
const auto *type_instantiation_decl =
|
const auto *type_instantiation_decl =
|
||||||
type->getAs<clang::TemplateSpecializationType>();
|
type->getAs<clang::TemplateSpecializationType>();
|
||||||
|
|
||||||
if (type_instantiation_decl != nullptr) {
|
if (type_instantiation_decl != nullptr) {
|
||||||
for (const auto &template_argument : *type_instantiation_decl) {
|
for (const auto &template_argument : *type_instantiation_decl) {
|
||||||
result = find_relationships(template_argument.getAsType(),
|
if (template_argument.getKind() ==
|
||||||
relationships, relationship_hint);
|
clang::TemplateArgument::ArgKind::Type)
|
||||||
|
result = find_relationships(template_argument.getAsType(),
|
||||||
|
relationships, relationship_hint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -600,12 +606,12 @@ std::unique_ptr<class_> translation_unit_visitor::build_template_instantiation(
|
|||||||
for (const auto &arg : template_type) {
|
for (const auto &arg : template_type) {
|
||||||
auto argument_kind = arg.getKind();
|
auto argument_kind = arg.getKind();
|
||||||
if (argument_kind == clang::TemplateArgument::ArgKind::Type) {
|
if (argument_kind == clang::TemplateArgument::ArgKind::Type) {
|
||||||
const auto *argument_record_decl =
|
// const auto *argument_record_decl =
|
||||||
arg.getAsType()->getAsRecordDecl();
|
// arg.getAsType()->getAsRecordDecl();
|
||||||
template_parameter argument;
|
template_parameter argument;
|
||||||
argument.is_template_parameter(false);
|
argument.is_template_parameter(false);
|
||||||
argument.set_name(to_string(
|
argument.set_name(to_string(
|
||||||
arg.getAsType(), argument_record_decl->getASTContext()));
|
arg.getAsType(), template_record->getASTContext()));
|
||||||
|
|
||||||
template_instantiation.add_template(std::move(argument));
|
template_instantiation.add_template(std::move(argument));
|
||||||
|
|
||||||
@@ -630,36 +636,55 @@ void translation_unit_visitor::process_field(
|
|||||||
detail::access_specifier_to_access_t(field_declaration.getAccess()),
|
detail::access_specifier_to_access_t(field_declaration.getAccess()),
|
||||||
field_declaration.getNameAsString(), type_name};
|
field_declaration.getNameAsString(), type_name};
|
||||||
|
|
||||||
if (field.name() == "e") {
|
|
||||||
LOG_DBG("EEEEEEEEE");
|
|
||||||
}
|
|
||||||
|
|
||||||
process_comment(field_declaration, field);
|
process_comment(field_declaration, field);
|
||||||
set_source_location(field_declaration, field);
|
set_source_location(field_declaration, field);
|
||||||
|
|
||||||
if (field.skip())
|
if (field.skip())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!field.skip_relationship()) {
|
if (field_type->getAs<clang::TemplateSpecializationType>()) {
|
||||||
found_relationships_t relationships;
|
if (diagram().should_include(type_name)) {
|
||||||
// find relationship for the type
|
auto template_specialization_ptr = build_template_instantiation(
|
||||||
find_relationships(field_declaration.getType(), relationships,
|
*field_type->getAs<clang::TemplateSpecializationType>());
|
||||||
relationship_t::kAggregation);
|
|
||||||
|
|
||||||
add_relationships(c, relationships,
|
relationship r{relationship_t::kAggregation,
|
||||||
detail::access_specifier_to_access_t(field_declaration.getAccess()),
|
template_specialization_ptr->id()};
|
||||||
field_declaration.getNameAsString());
|
r.set_label(field_declaration.getNameAsString());
|
||||||
|
r.set_access(detail::access_specifier_to_access_t(
|
||||||
|
field_declaration.getAccess()));
|
||||||
|
|
||||||
|
diagram().add_class(std::move(template_specialization_ptr));
|
||||||
|
|
||||||
|
LOG_DBG("ADDED TEMPLATE SPECIALIZATION TO DIAGRAM");
|
||||||
|
|
||||||
|
c.add_relationship(std::move(r));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!field.skip_relationship()) {
|
||||||
|
found_relationships_t relationships;
|
||||||
|
// find relationship for the type
|
||||||
|
find_relationships(field_declaration.getType(), relationships,
|
||||||
|
relationship_t::kAggregation);
|
||||||
|
|
||||||
|
add_relationships(c, relationships,
|
||||||
|
detail::access_specifier_to_access_t(
|
||||||
|
field_declaration.getAccess()),
|
||||||
|
field_declaration.getNameAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (!field.skip_relationship()) {
|
||||||
|
found_relationships_t relationships;
|
||||||
|
// find relationship for the type
|
||||||
|
find_relationships(field_declaration.getType(), relationships,
|
||||||
|
relationship_t::kAggregation);
|
||||||
|
|
||||||
if (field_type->getAs<clang::TemplateSpecializationType>() &&
|
add_relationships(c, relationships,
|
||||||
diagram().should_include(type_name)) {
|
detail::access_specifier_to_access_t(
|
||||||
|
field_declaration.getAccess()),
|
||||||
auto template_specialization_ptr = build_template_instantiation(
|
field_declaration.getNameAsString());
|
||||||
*field_type->getAs<clang::TemplateSpecializationType>());
|
}
|
||||||
|
|
||||||
diagram().add_class(std::move(template_specialization_ptr));
|
|
||||||
|
|
||||||
LOG_DBG("ADDED TEMPLATE SPECIALIZATION TO DIAGRAM");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ TEST_CASE("t00007", "[test-case][class]")
|
|||||||
|
|
||||||
REQUIRE(diagram->name == "t00007_class");
|
REQUIRE(diagram->name == "t00007_class");
|
||||||
|
|
||||||
auto model = generate_class_diagram(db, diagram);
|
auto model = generate_class_diagram(*db, diagram);
|
||||||
|
|
||||||
REQUIRE(model->name() == "t00007_class");
|
REQUIRE(model->name() == "t00007_class");
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ TEST_CASE("t00008", "[test-case][class]")
|
|||||||
|
|
||||||
REQUIRE(diagram->name == "t00008_class");
|
REQUIRE(diagram->name == "t00008_class");
|
||||||
|
|
||||||
auto model = generate_class_diagram(db, diagram);
|
auto model = generate_class_diagram(*db, diagram);
|
||||||
|
|
||||||
REQUIRE(model->name() == "t00008_class");
|
REQUIRE(model->name() == "t00008_class");
|
||||||
|
|
||||||
|
|||||||
@@ -195,8 +195,8 @@ using namespace clanguml::test::matchers;
|
|||||||
#include "t00004/test_case.h"
|
#include "t00004/test_case.h"
|
||||||
#include "t00005/test_case.h"
|
#include "t00005/test_case.h"
|
||||||
#include "t00006/test_case.h"
|
#include "t00006/test_case.h"
|
||||||
//#include "t00007/test_case.h"
|
#include "t00007/test_case.h"
|
||||||
//#include "t00008/test_case.h"
|
#include "t00008/test_case.h"
|
||||||
//#include "t00009/test_case.h"
|
//#include "t00009/test_case.h"
|
||||||
//#include "t00010/test_case.h"
|
//#include "t00010/test_case.h"
|
||||||
//#include "t00011/test_case.h"
|
//#include "t00011/test_case.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user