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;
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...
return true;
}
@@ -1016,28 +1016,30 @@ void translation_unit_visitor::
// template arguments
if (arg.getAsType()->getAs<clang::FunctionType>()) {
// for (const auto &param_type :
// arg.getAsType()->getAs<clang::FunctionProtoType>()->param_types()) {
//
// if (!param_type->getAs<clang::RecordType>())
// continue;
//
// auto classTemplateSpecialization =
// llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
// param_type->getAsRecordDecl());
//
// if (classTemplateSpecialization) {
// // Read arg info as needed.
// auto nested_template_instantiation =
// build_template_instantiation_from_class_template_specialization(
// *classTemplateSpecialization,
// *param_type->getAs<clang::RecordType>(),
// diagram().should_include(
// full_template_specialization_name)
// ? std::make_optional(&template_instantiation)
// : parent);
// }
// }
// for (const auto &param_type :
// arg.getAsType()->getAs<clang::FunctionProtoType>()->param_types())
// {
//
// if (!param_type->getAs<clang::RecordType>())
// continue;
//
// auto classTemplateSpecialization =
// llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
// param_type->getAsRecordDecl());
//
// if (classTemplateSpecialization) {
// // Read arg info as needed.
// auto nested_template_instantiation =
// build_template_instantiation_from_class_template_specialization(
// *classTemplateSpecialization,
// *param_type->getAs<clang::RecordType>(),
// diagram().should_include(
// full_template_specialization_name)
// ?
// std::make_optional(&template_instantiation)
// : parent);
// }
// }
}
else if (arg.getAsType()->getAs<clang::TemplateSpecializationType>()) {
const auto *nested_template_type =

View File

@@ -176,9 +176,7 @@ public:
clanguml::sequence_diagram::model::diagram &diagram,
const clanguml::config::sequence_diagram &config);
bool shouldVisitTemplateInstantiations() {
return true;
}
bool shouldVisitTemplateInstantiations() { return true; }
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("m1<unsigned long>()"), _A("m4<unsigned long>()"),
"m4"));
HasCall(_A("m1<unsigned long>()"), _A("m4<unsigned long>()"), "m4"));
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<std::string>()"), "m1"));
REQUIRE_THAT(puml,
HasCall(_A("m1<std::string>()"), _A("m2<std::string>()"),
"m2"));
REQUIRE_THAT(
puml, HasCall(_A("m1<std::string>()"), _A("m2<std::string>()"), "m2"));
REQUIRE_THAT(puml, HasCall(_A("main()"), _A("m1<int>()"), "m1"));
REQUIRE_THAT(puml, HasCall(_A("m1<int>()"), _A("m2<int>()"), "m2"));

View File

@@ -19,11 +19,10 @@ template <> struct B<std::string> {
};
template <typename T> struct AA {
void aa1(T t) { }
void aa2(T t) { }
void aa1(T t) { }
void aa2(T t) { }
};
template <typename T, typename F> struct BB {
void bb1(T t, F f) { aa_.aa1(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_;
};
void tmain()
{
B<int> bint;

View File

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