diff --git a/src/uml/class_diagram_visitor.h b/src/uml/class_diagram_visitor.h index dc444ff3..0d369ea7 100644 --- a/src/uml/class_diagram_visitor.h +++ b/src/uml/class_diagram_visitor.h @@ -209,21 +209,24 @@ static enum CXChildVisitResult friend_class_visitor( cx::cursor cursor{std::move(cx_cursor)}; cx::cursor parent{std::move(cx_parent)}; - spdlog::info("Visiting friend class declaration{}: {} - {}:{}", - ctx->element.name, cursor.spelling(), cursor.kind()); + spdlog::info("Visiting friend class declaration {}: {} - {}:{}", + ctx->element.name, cursor.spelling(), cursor.kind(), + cursor.referenced()); enum CXChildVisitResult ret = CXChildVisit_Break; switch (cursor.kind()) { + case CXCursor_TemplateRef: + case CXCursor_ClassTemplate: case CXCursor_TypeRef: { + spdlog::info("Analyzing friend declaration: {}, {}", cursor, + cursor.specialized_cursor_template()); + if (!ctx->ctx->config.should_include( cursor.referenced().fully_qualified())) { ret = CXChildVisit_Continue; break; } - spdlog::info("Adding friend declaration: {}, {}", cursor, - cursor.referenced()); - class_relationship r; r.type = relationship_t::kFriendship; r.label = "<>"; diff --git a/tests/t00011/t00011.cc b/tests/t00011/t00011.cc index 73c0c6e4..bb1138ce 100644 --- a/tests/t00011/t00011.cc +++ b/tests/t00011/t00011.cc @@ -8,11 +8,17 @@ namespace t00011 { class B; +template class D { + T value; +}; + class A { private: void foo() {} friend class B; friend class external::C; + template friend class D; + // TODO: Add friend for a template specialization }; class B { diff --git a/tests/t00011/test_case.h b/tests/t00011/test_case.h index 619efe90..04ab3e08 100644 --- a/tests/t00011/test_case.h +++ b/tests/t00011/test_case.h @@ -46,8 +46,10 @@ TEST_CASE("Test t00011", "[unit-test]") REQUIRE_THAT(puml, EndsWith("@enduml\n")); REQUIRE_THAT(puml, IsClass(_A("A"))); REQUIRE_THAT(puml, IsClass(_A("B"))); + REQUIRE_THAT(puml, IsClass(_A("D"))); REQUIRE_THAT(puml, IsFriend(_A("A"), _A("B"))); + REQUIRE_THAT(puml, IsFriend(_A("A"), _A("D"))); save_puml( "./" + config.output_directory + "/" + diagram->name + ".puml", puml);