From 07584c86166dc3f6c0461696006811f7d82e32c1 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sun, 25 Dec 2022 21:30:01 +0100 Subject: [PATCH] Fixed building on macos with LLVM 15 --- CMakeLists.txt | 3 +++ .../visitor/translation_unit_visitor.cc | 14 ++++++++++++++ .../visitor/translation_unit_visitor.h | 9 +++++++++ .../visitor/translation_unit_visitor.cc | 3 --- tests/t00039/.clang-uml | 1 + tests/t00049/test_case.h | 2 +- tests/t40001/.clang-uml | 3 +-- tests/t40001/test_case.h | 2 +- tests/t40002/.clang-uml | 5 +++-- tests/t40002/test_case.h | 2 +- tests/t40003/.clang-uml | 4 ++-- tests/t40003/test_case.h | 2 +- 12 files changed, 37 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 373b82c4..cd5d69a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_VERBOSE_MAKEFILE OFF) set(CMAKE_FIND_DEBUG_MODE OFF) +if(APPLE) + set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) +endif(APPLE) # # clang-uml custom defines diff --git a/src/include_diagram/visitor/translation_unit_visitor.cc b/src/include_diagram/visitor/translation_unit_visitor.cc index 3bffdeb7..214f22d9 100644 --- a/src/include_diagram/visitor/translation_unit_visitor.cc +++ b/src/include_diagram/visitor/translation_unit_visitor.cc @@ -43,6 +43,15 @@ translation_unit_visitor::include_visitor::include_visitor( { } +#if LLVM_VERSION_MAJOR > 14 +void translation_unit_visitor::include_visitor::InclusionDirective( + clang::SourceLocation hash_loc, const clang::Token & /*include_tok*/, + clang::StringRef /*file_name*/, bool is_angled, + clang::CharSourceRange /*filename_range*/, clang::Optional file, + clang::StringRef /*search_path*/, clang::StringRef relative_path, + const clang::Module * /*imported*/, + clang::SrcMgr::CharacteristicKind file_type) +#else void translation_unit_visitor::include_visitor::InclusionDirective( clang::SourceLocation hash_loc, const clang::Token & /*include_tok*/, clang::StringRef /*file_name*/, bool is_angled, @@ -50,6 +59,7 @@ void translation_unit_visitor::include_visitor::InclusionDirective( clang::StringRef /*search_path*/, clang::StringRef relative_path, const clang::Module * /*imported*/, clang::SrcMgr::CharacteristicKind file_type) +#endif { using common::model::relationship; using common::model::source_file; @@ -66,7 +76,11 @@ void translation_unit_visitor::include_visitor::InclusionDirective( assert(diagram().get(current_file_id.value())); +#if LLVM_VERSION_MAJOR > 14 + auto include_path = std::filesystem::path(file->getDir().getName().str()); +#else auto include_path = std::filesystem::path(file->getDir()->getName().str()); +#endif include_path = include_path / file->getName().str(); include_path = include_path.lexically_normal(); diff --git a/src/include_diagram/visitor/translation_unit_visitor.h b/src/include_diagram/visitor/translation_unit_visitor.h index 3fe0cde4..d7c7a79a 100644 --- a/src/include_diagram/visitor/translation_unit_visitor.h +++ b/src/include_diagram/visitor/translation_unit_visitor.h @@ -47,12 +47,21 @@ public: clanguml::include_diagram::model::diagram &diagram, const clanguml::config::include_diagram &config); +#if LLVM_VERSION_MAJOR > 14 + void InclusionDirective(clang::SourceLocation hash_loc, + const clang::Token &include_tok, clang::StringRef file_name, + bool is_angled, clang::CharSourceRange filename_range, + clang::Optional file, clang::StringRef search_path, + clang::StringRef relative_path, const clang::Module *imported, + clang::SrcMgr::CharacteristicKind file_type) override; +#else void InclusionDirective(clang::SourceLocation hash_loc, const clang::Token &include_tok, clang::StringRef file_name, bool is_angled, clang::CharSourceRange filename_range, const clang::FileEntry *file, clang::StringRef search_path, clang::StringRef relative_path, const clang::Module *imported, clang::SrcMgr::CharacteristicKind file_type) override; +#endif std::optional process_internal_header( const std::filesystem::path &include_path, bool is_system, diff --git a/src/sequence_diagram/visitor/translation_unit_visitor.cc b/src/sequence_diagram/visitor/translation_unit_visitor.cc index d7569a19..76f8814d 100644 --- a/src/sequence_diagram/visitor/translation_unit_visitor.cc +++ b/src/sequence_diagram/visitor/translation_unit_visitor.cc @@ -1461,7 +1461,6 @@ void translation_unit_visitor:: const std::string &full_template_specialization_name, const clang::TemplateDecl *template_decl) { - auto arg_index = 0U; for (const auto &arg : template_args) { const auto argument_kind = arg.getKind(); class_diagram::model::template_parameter argument; @@ -1490,8 +1489,6 @@ void translation_unit_visitor:: argument, argument.to_string(config().using_namespace(), false)); template_instantiation.add_template(argument); - - arg_index++; } } diff --git a/tests/t00039/.clang-uml b/tests/t00039/.clang-uml index e16ac2f2..4ba5bdca 100644 --- a/tests/t00039/.clang-uml +++ b/tests/t00039/.clang-uml @@ -19,5 +19,6 @@ diagrams: - inheritance exclude: namespaces: + - std - clanguml::t00039::detail - clanguml::t00039::ns3::detail \ No newline at end of file diff --git a/tests/t00049/test_case.h b/tests/t00049/test_case.h index 55dbae28..91e392a8 100644 --- a/tests/t00049/test_case.h +++ b/tests/t00049/test_case.h @@ -53,7 +53,7 @@ TEST_CASE("t00049", "[test-case][class]") // Check if all relationships exist REQUIRE_THAT( - puml, IsInstantiation(_A("A"), _A("A>"))); + puml, IsInstantiation(_A("A"), _A("A"))); REQUIRE_THAT(puml, IsInstantiation(_A("A"), _A("A"))); REQUIRE_THAT(puml, IsInstantiation(_A("A"), _A("A"))); diff --git a/tests/t40001/.clang-uml b/tests/t40001/.clang-uml index ef2a4a41..c4c549b5 100644 --- a/tests/t40001/.clang-uml +++ b/tests/t40001/.clang-uml @@ -6,8 +6,7 @@ diagrams: # Provide the files to parse in order to look # for #include directives glob: - - ../../tests/t40001/**/*.cc - - ../../tests/t40001/**/*.h + - ../../tests/t40001/src/t40001.cc # Render the paths relative to this directory relative_to: ../../../tests/t40001 # Include also external system headers diff --git a/tests/t40001/test_case.h b/tests/t40001/test_case.h index 31240a19..569f01c4 100644 --- a/tests/t40001/test_case.h +++ b/tests/t40001/test_case.h @@ -16,7 +16,7 @@ * limitations under the License. */ -TEST_CASE("t40001", "[test-case][package]") +TEST_CASE("t40001", "[test-case][include]") { auto [config, db] = load_config("t40001"); diff --git a/tests/t40002/.clang-uml b/tests/t40002/.clang-uml index 7a96f63b..84c790a2 100644 --- a/tests/t40002/.clang-uml +++ b/tests/t40002/.clang-uml @@ -6,8 +6,9 @@ diagrams: # Provide the files to parse in order to look # for #include directives glob: - - ../../tests/t40002/**/*.cc - - ../../tests/t40002/**/*.h + - ../../tests/t40002/src/t40002.cc + - ../../tests/t40002/src/lib1/lib1.cc + - ../../tests/t40002/src/lib2/lib2.cc # Render the paths relative to this directory relative_to: ../../../tests/t40002 include: diff --git a/tests/t40002/test_case.h b/tests/t40002/test_case.h index 15aa503a..f8048c49 100644 --- a/tests/t40002/test_case.h +++ b/tests/t40002/test_case.h @@ -16,7 +16,7 @@ * limitations under the License. */ -TEST_CASE("t40002", "[test-case][package]") +TEST_CASE("t40002", "[test-case][include]") { auto [config, db] = load_config("t40002"); diff --git a/tests/t40003/.clang-uml b/tests/t40003/.clang-uml index 4e28cc22..be81eb3a 100644 --- a/tests/t40003/.clang-uml +++ b/tests/t40003/.clang-uml @@ -6,8 +6,8 @@ diagrams: # Provide the files to parse in order to look # for #include directives glob: - - ../../tests/t40003/include/**/*.h - - ../../tests/t40003/src/**/*.cc + - ../../tests/t40003/src/dependants/t1.cc + - ../../tests/t40003/src/dependencies/t2.cc # Render the paths relative to this directory relative_to: ../../../tests/t40003 include: diff --git a/tests/t40003/test_case.h b/tests/t40003/test_case.h index 9ad79ce2..4e9915ec 100644 --- a/tests/t40003/test_case.h +++ b/tests/t40003/test_case.h @@ -16,7 +16,7 @@ * limitations under the License. */ -TEST_CASE("t40003", "[test-case][package]") +TEST_CASE("t40003", "[test-case][include]") { auto [config, db] = load_config("t40003");