Added calls through pointers and references in template instantiation sequence diagram test case
This commit is contained in:
@@ -567,7 +567,9 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
|||||||
clang::dyn_cast_or_null<clang::CXXDependentScopeMemberExpr>(
|
clang::dyn_cast_or_null<clang::CXXDependentScopeMemberExpr>(
|
||||||
function_call_expr->getCallee());
|
function_call_expr->getCallee());
|
||||||
|
|
||||||
if (!dependent_member_callee->getBaseType().isNull()) {
|
if (is_callee_valid_template_specialization(
|
||||||
|
dependent_member_callee)) {
|
||||||
|
|
||||||
const auto *primary_template =
|
const auto *primary_template =
|
||||||
dependent_member_callee->getBaseType()
|
dependent_member_callee->getBaseType()
|
||||||
->getAs<clang::TemplateSpecializationType>()
|
->getAs<clang::TemplateSpecializationType>()
|
||||||
@@ -715,6 +717,17 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool translation_unit_visitor::is_callee_valid_template_specialization(
|
||||||
|
const clang::CXXDependentScopeMemberExpr *dependent_member_callee) const
|
||||||
|
{
|
||||||
|
return !dependent_member_callee->getBaseType().isNull() &&
|
||||||
|
dependent_member_callee->getBaseType()
|
||||||
|
->getAs<clang::TemplateSpecializationType>() &&
|
||||||
|
!dependent_member_callee->getBaseType()
|
||||||
|
->getAs<clang::TemplateSpecializationType>()
|
||||||
|
->isPointerType();
|
||||||
|
}
|
||||||
|
|
||||||
bool translation_unit_visitor::is_smart_pointer(
|
bool translation_unit_visitor::is_smart_pointer(
|
||||||
const clang::TemplateDecl *primary_template) const
|
const clang::TemplateDecl *primary_template) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -302,6 +302,10 @@ private:
|
|||||||
|
|
||||||
bool is_smart_pointer(const clang::TemplateDecl *primary_template) const;
|
bool is_smart_pointer(const clang::TemplateDecl *primary_template) const;
|
||||||
|
|
||||||
|
bool is_callee_valid_template_specialization(
|
||||||
|
const clang::CXXDependentScopeMemberExpr *dependent_member_callee)
|
||||||
|
const;
|
||||||
|
|
||||||
// Reference to the output diagram model
|
// Reference to the output diagram model
|
||||||
clanguml::sequence_diagram::model::diagram &diagram_;
|
clanguml::sequence_diagram::model::diagram &diagram_;
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,27 @@ template <typename T, typename F> struct BB {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> struct BB<T, std::string> {
|
template <typename T> struct BB<T, std::string> {
|
||||||
void bb1(T t, std::string f) { aa_.aa2(t); }
|
void bb1(T t, std::string f) { aa_->aa2(t); }
|
||||||
void bb2(T t, std::string f) { aa_.aa1(t); }
|
void bb2(T t, std::string f) { aa_->aa1(t); }
|
||||||
|
|
||||||
AA<T> aa_;
|
BB<T, std::string>(AA<T> *aa)
|
||||||
|
: aa_{aa}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AA<T> *aa_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T> struct BB<T, float> {
|
||||||
|
void bb1(T t, float f) { bb2(t, f); }
|
||||||
|
void bb2(T t, float f) { aa_.aa2(t); }
|
||||||
|
|
||||||
|
BB<T, float>(AA<T> &aa)
|
||||||
|
: aa_{aa}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AA<T> &aa_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void tmain()
|
void tmain()
|
||||||
@@ -46,13 +63,17 @@ void tmain()
|
|||||||
bstring.b("bstring");
|
bstring.b("bstring");
|
||||||
|
|
||||||
BB<int, int> bbint;
|
BB<int, int> bbint;
|
||||||
BB<int, std::string> bbstring;
|
AA<int> aaint;
|
||||||
|
BB<int, std::string> bbstring{&aaint};
|
||||||
|
BB<int, float> bbfloat{aaint};
|
||||||
|
|
||||||
bbint.bb1(1, 1);
|
bbint.bb1(1, 1);
|
||||||
bbint.bb2(2, 2);
|
bbint.bb2(2, 2);
|
||||||
|
|
||||||
bbstring.bb1(1, "calling aa2");
|
bbstring.bb1(1, "calling aa2");
|
||||||
bbstring.bb2(1, "calling aa1");
|
bbstring.bb2(1, "calling aa1");
|
||||||
|
|
||||||
|
bbfloat.bb1(1, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,11 @@ TEST_CASE("t20006", "[test-case][sequence]")
|
|||||||
REQUIRE_THAT(
|
REQUIRE_THAT(
|
||||||
puml, HasCall(_A("BB<int,std::string>"), _A("AA<int>"), "aa1"));
|
puml, HasCall(_A("BB<int,std::string>"), _A("AA<int>"), "aa1"));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, HasCall(_A("tmain()"), _A("BB<int,float>"), "bb1"));
|
||||||
|
REQUIRE_THAT(
|
||||||
|
puml, HasCall(_A("BB<int,float>"), _A("BB<int,float>"), "bb2"));
|
||||||
|
REQUIRE_THAT(puml, HasCall(_A("BB<int,float>"), _A("AA<int>"), "aa2"));
|
||||||
|
|
||||||
save_puml(
|
save_puml(
|
||||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user