Fixed formatting

This commit is contained in:
Bartek Kryza
2022-11-27 15:24:01 +01:00
parent df0163cdbf
commit 93e95613b4
6 changed files with 53 additions and 50 deletions

View File

@@ -646,7 +646,7 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
std::unique_ptr<model::function_template> f_ptr; std::unique_ptr<model::function_template> f_ptr;
if(!get_ast_local_id(callee_function->getID()).has_value()) { if (!get_ast_local_id(callee_function->getID()).has_value()) {
// This is hopefully not an interesting call... // This is hopefully not an interesting call...
return true; return true;
} }
@@ -1016,28 +1016,30 @@ void translation_unit_visitor::
// template arguments // template arguments
if (arg.getAsType()->getAs<clang::FunctionType>()) { if (arg.getAsType()->getAs<clang::FunctionType>()) {
// for (const auto &param_type : // for (const auto &param_type :
// arg.getAsType()->getAs<clang::FunctionProtoType>()->param_types()) { // arg.getAsType()->getAs<clang::FunctionProtoType>()->param_types())
// // {
// if (!param_type->getAs<clang::RecordType>()) //
// continue; // if (!param_type->getAs<clang::RecordType>())
// // continue;
// auto classTemplateSpecialization = //
// llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>( // auto classTemplateSpecialization =
// param_type->getAsRecordDecl()); // llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
// // param_type->getAsRecordDecl());
// if (classTemplateSpecialization) { //
// // Read arg info as needed. // if (classTemplateSpecialization) {
// auto nested_template_instantiation = // // Read arg info as needed.
// build_template_instantiation_from_class_template_specialization( // auto nested_template_instantiation =
// *classTemplateSpecialization, // build_template_instantiation_from_class_template_specialization(
// *param_type->getAs<clang::RecordType>(), // *classTemplateSpecialization,
// diagram().should_include( // *param_type->getAs<clang::RecordType>(),
// full_template_specialization_name) // diagram().should_include(
// ? std::make_optional(&template_instantiation) // full_template_specialization_name)
// : parent); // ?
// } // std::make_optional(&template_instantiation)
// } // : parent);
// }
// }
} }
else if (arg.getAsType()->getAs<clang::TemplateSpecializationType>()) { else if (arg.getAsType()->getAs<clang::TemplateSpecializationType>()) {
const auto *nested_template_type = const auto *nested_template_type =

View File

@@ -176,9 +176,7 @@ public:
clanguml::sequence_diagram::model::diagram &diagram, clanguml::sequence_diagram::model::diagram &diagram,
const clanguml::config::sequence_diagram &config); const clanguml::config::sequence_diagram &config);
bool shouldVisitTemplateInstantiations() { bool shouldVisitTemplateInstantiations() { return true; }
return true;
}
virtual bool VisitCallExpr(clang::CallExpr *expr); virtual bool VisitCallExpr(clang::CallExpr *expr);

View File

@@ -38,13 +38,11 @@ TEST_CASE("t20004", "[test-case][sequence]")
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<unsigned long>()"), "m1")); REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<unsigned long>()"), "m1"));
REQUIRE_THAT(puml, REQUIRE_THAT(puml,
HasCall(_A("m1<unsigned long>()"), _A("m4<unsigned long>()"), HasCall(_A("m1<unsigned long>()"), _A("m4<unsigned long>()"), "m4"));
"m4"));
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<std::string>()"), "m1")); REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<std::string>()"), "m1"));
REQUIRE_THAT(puml, REQUIRE_THAT(
HasCall(_A("m1<std::string>()"), _A("m2<std::string>()"), puml, HasCall(_A("m1<std::string>()"), _A("m2<std::string>()"), "m2"));
"m2"));
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<int>()"), "m1")); REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<int>()"), "m1"));
REQUIRE_THAT(puml, HasCall(_A("m1<int>()"), _A("m2<int>()"), "m2")); REQUIRE_THAT(puml, HasCall(_A("m1<int>()"), _A("m2<int>()"), "m2"));

View File

@@ -23,7 +23,6 @@ template <typename T> struct AA {
void aa2(T t) { } void aa2(T t) { }
}; };
template <typename T, typename F> struct BB { template <typename T, typename F> struct BB {
void bb1(T t, F f) { aa_.aa1(t); } void bb1(T t, F f) { aa_.aa1(t); }
void bb2(T t, F f) { aa_.aa2(t); } void bb2(T t, F f) { aa_.aa2(t); }
@@ -38,7 +37,6 @@ template <typename T> struct BB<T, std::string> {
AA<T> aa_; AA<T> aa_;
}; };
void tmain() void tmain()
{ {
B<int> bint; B<int> bint;

View File

@@ -1,9 +1,8 @@
#include <type_traits>
#include <string> #include <string>
#include <type_traits>
namespace clanguml { namespace clanguml {
namespace t20008 namespace t20008 {
{
template <typename T> struct A { template <typename T> struct A {
void a1(T arg) { } void a1(T arg) { }
@@ -14,25 +13,26 @@ template <typename T> struct A {
template <typename T> struct B { template <typename T> struct B {
A<T> a; A<T> a;
void b(T arg) { void b(T arg)
{
if constexpr (std::is_integral_v<T>) { if constexpr (std::is_integral_v<T>) {
a.a1(arg); a.a1(arg);
} }
else if constexpr(std::is_pointer_v<T>) { else if constexpr (std::is_pointer_v<T>) {
a.a2(arg); a.a2(arg);
} }
else { else {
a.a3(arg); a.a3(arg);
} }
} }
}; };
void tmain() { void tmain()
{
using namespace std::string_literals; using namespace std::string_literals;
B<int> bint; B<int> bint;
B<const char*> bcharp; B<const char *> bcharp;
B<std::string> bstring; B<std::string> bstring;
bint.b(1); bint.b(1);

View File

@@ -79,19 +79,26 @@ template <typename T, typename... Ts> constexpr bool has_type() noexcept
return (std::is_same_v<T, Ts> || ... || false); return (std::is_same_v<T, Ts> || ... || false);
} }
struct Public { }; struct Public {
};
struct Protected { }; struct Protected {
};
struct Private { }; struct Private {
};
struct Abstract { }; struct Abstract {
};
struct Static { }; struct Static {
};
struct Const { }; struct Const {
};
struct Default { }; struct Default {
};
struct HasCallWithResultMatcher : ContainsMatcher { struct HasCallWithResultMatcher : ContainsMatcher {
HasCallWithResultMatcher( HasCallWithResultMatcher(