From d25a2522123f069d0fb29c2fdf1fac3f2f5096af Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Tue, 30 Mar 2021 00:39:23 +0200 Subject: [PATCH] Fixed template template example --- src/uml/class_diagram_visitor.cc | 5 ++++- tests/t00008/t00008.cc | 13 ++++++------- tests/t00008/test_case.h | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/uml/class_diagram_visitor.cc b/src/uml/class_diagram_visitor.cc index 76cb18b9..82b71fe7 100644 --- a/src/uml/class_diagram_visitor.cc +++ b/src/uml/class_diagram_visitor.cc @@ -306,7 +306,10 @@ void tu_visitor::process_field(const cppast::cpp_member_variable &mv, class_ &c, spdlog::debug( "Processing field with unreferenced type of kind {}", tr.kind()); - if (tr.kind() == cppast::cpp_type_kind::template_instantiation_t) { + if (tr.kind() == cppast::cpp_type_kind::builtin_t) { + spdlog::debug("Builtin type found for field: {}", m.name); + } + else if (tr.kind() == cppast::cpp_type_kind::template_instantiation_t) { spdlog::debug("Processing field with template instatiation type {}", cppast::to_string(tr)); diff --git a/tests/t00008/t00008.cc b/tests/t00008/t00008.cc index 0c171258..9987e03c 100644 --- a/tests/t00008/t00008.cc +++ b/tests/t00008/t00008.cc @@ -17,19 +17,18 @@ public: CMP comparator; }; -/* - * TODO: Handle template template properly. - * +template struct Vector { + std::vector values; +}; + template typename C> struct B { C template_template; }; struct D { - // libclang claims that the type spelling of 'ints' is 'int'... - B ints; + B ints; - void add(int i) { ints.template_template.push_back(i); } + void add(int i) { ints.template_template.values.push_back(i); } }; -*/ } } diff --git a/tests/t00008/test_case.h b/tests/t00008/test_case.h index 66e289a4..678048c5 100644 --- a/tests/t00008/test_case.h +++ b/tests/t00008/test_case.h @@ -43,6 +43,7 @@ TEST_CASE("t00008", "[test-case][class]") REQUIRE_THAT(puml, StartsWith("@startuml")); REQUIRE_THAT(puml, EndsWith("@enduml\n")); REQUIRE_THAT(puml, IsClassTemplate("A", "T, P, bool (*)(int, int), int N")); + REQUIRE_THAT(puml, IsClassTemplate("B", "T, C<>")); REQUIRE_THAT(puml, IsField(Public("T value"))); REQUIRE_THAT(puml, IsField(Public("T * pointer")));