From bf64b75bdda9a6f62f96eaa449278ef94f873cf4 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Thu, 11 Mar 2021 18:20:02 +0100 Subject: [PATCH] Skip friends outside of included scope --- src/uml/class_diagram_visitor.h | 7 +++++++ tests/t00011/t00011.cc | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/uml/class_diagram_visitor.h b/src/uml/class_diagram_visitor.h index 86a1ffb6..dc444ff3 100644 --- a/src/uml/class_diagram_visitor.h +++ b/src/uml/class_diagram_visitor.h @@ -215,8 +215,15 @@ static enum CXChildVisitResult friend_class_visitor( enum CXChildVisitResult ret = CXChildVisit_Break; switch (cursor.kind()) { case CXCursor_TypeRef: { + 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 9aeec4cf..73c0c6e4 100644 --- a/tests/t00011/t00011.cc +++ b/tests/t00011/t00011.cc @@ -1,3 +1,8 @@ +namespace external { +class C { +}; +} + namespace clanguml { namespace t00011 { @@ -7,6 +12,7 @@ class A { private: void foo() {} friend class B; + friend class external::C; }; class B {