From c2b83e23963226ce976fc29a274bd775882570ff Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sat, 18 Feb 2023 22:20:28 +0100 Subject: [PATCH 1/3] Updated the clang-uml build path after cmake refactor --- Makefile | 2 +- docs/installation.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 88d266db..033da801 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ document_test_cases: test_plantuml clanguml_diagrams: debug mkdir -p docs/diagrams - debug/clang-uml + debug/src/clang-uml plantuml -tsvg -nometadata docs/diagrams/*.puml python3 util/format_svg.py docs/diagrams/*.svg diff --git a/docs/installation.md b/docs/installation.md index 7c69eadd..0ba4239c 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -68,7 +68,7 @@ git clone https://github.com/bkryza/clang-uml cd clang-uml # Please note that top level Makefile is just a convenience wrapper for CMake make release -release/clang-uml --help +release/src/clang-uml --help # To build using a specific installed version of LLVM use: LLVM_VERSION=14 make release From bdf9a7e18fd0f83579b66c97d3937fe9e1b892e6 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sat, 18 Feb 2023 23:04:32 +0100 Subject: [PATCH 2/3] Fixed generation of class_model_class diagram --- src/CMakeLists.txt | 6 ++++-- src/class_diagram/visitor/translation_unit_visitor.cc | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 290c95f9..15d9b597 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,8 @@ endif(MSVC) target_compile_features(clang-umllib INTERFACE cxx_std_17) target_compile_options(clang-umllib PRIVATE $<$,$>: - -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field> + -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field + -Wno-deprecated-declarations> $<$:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>) target_compile_definitions(clang-umllib PRIVATE $<$: @@ -39,7 +40,8 @@ add_executable(clang-uml ${MAIN_SOURCE_FILE}) target_compile_features(clang-uml PUBLIC cxx_std_17) target_compile_options(clang-uml PRIVATE $<$,$>: - -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field> + -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field + -Wno-deprecated-declarations> $<$:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>) target_link_libraries(clang-uml ${YAML_CPP_LIBRARIES} diff --git a/src/class_diagram/visitor/translation_unit_visitor.cc b/src/class_diagram/visitor/translation_unit_visitor.cc index 0364c88b..99071c7e 100644 --- a/src/class_diagram/visitor/translation_unit_visitor.cc +++ b/src/class_diagram/visitor/translation_unit_visitor.cc @@ -897,8 +897,12 @@ void translation_unit_visitor:: desugared_atsp = deduced_type->getDeducedType(); } - const auto *deduced_record_type = - desugared_atsp->getAs(); + if (desugared_atsp.isNull()) + return; + + const auto *deduced_record_type = desugared_atsp->isRecordType() + ? desugared_atsp->getAs() + : nullptr; if (deduced_record_type != nullptr) { if (auto *deduced_auto_decl = From 35c4c210b1663c656cedc07739adadb096acf0c4 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sun, 19 Feb 2023 00:37:15 +0100 Subject: [PATCH 3/3] Enabled backward-cpp for debug build on Linux --- .github/workflows/build.yml | 2 +- CMakeLists.txt | 15 +++++++++++++++ README.md | 1 + src/CMakeLists.txt | 3 +++ src/main.cc | 6 ++++-- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 562cd3af..59cddc83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: - name: Update package database run: sudo apt -y update - name: Install deps - run: sudo apt -y install git make gcc-10 g++-10 ccache cmake libyaml-cpp-dev llvm-12 clang-12 libclang-12-dev libclang-cpp12-dev clang-format-12 lcov zlib1g-dev + run: sudo apt -y install git make pkg-config gcc-10 g++-10 ccache cmake libyaml-cpp-dev llvm-12 clang-12 libclang-12-dev libclang-cpp12-dev clang-format-12 lcov zlib1g-dev libunwind-dev libdw-dev - name: Select g++ version run: | sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 diff --git a/CMakeLists.txt b/CMakeLists.txt index 15bf1602..5cd3aa10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_VERBOSE_MAKEFILE OFF) set(CMAKE_FIND_DEBUG_MODE OFF) +if(UNIX AND NOT APPLE) + set(LINUX TRUE) +endif() + # # C++ setup # @@ -155,6 +159,17 @@ endif() link_directories(${LLVM_LIBRARY_DIR} ${YAML_CPP_LIBRARY_DIR}) +# +# Setup libdw and libunwind +# +if(LINUX AND (CMAKE_BUILD_TYPE MATCHES Debug)) + find_package(PkgConfig REQUIRED) + pkg_check_modules(DW REQUIRED IMPORTED_TARGET libdw) + pkg_check_modules(UNWIND REQUIRED IMPORTED_TARGET libunwind) + set(BACKWARD_CPP_LIBRARIES PkgConfig::DW PkgConfig::UNWIND) + set(ENABLE_BACKWARD_CPP -DENABLE_BACKWARD_CPP) +endif() + # # Setup thirdparty sources # diff --git a/README.md b/README.md index ffcd882e..c55653d8 100644 --- a/README.md +++ b/README.md @@ -422,6 +422,7 @@ This project relies on the following great tools: * [glob](https://github.com/p-ranav/glob) - Unix style path expansion for C++ * [CLI11](https://github.com/CLIUtils/CLI11) - command line parser for C++ * [inja](https://github.com/pantor/inja) - a template engine for modern C++ +* [backward-cpp](https://github.com/bombela/backward-cpp) - stack trace pretty printer for C++ ## Contributing diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 15d9b597..4e0d83af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,10 +43,13 @@ target_compile_options(clang-uml PRIVATE -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wno-deprecated-declarations> $<$:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>) +target_compile_definitions(clang-uml PRIVATE + ${ENABLE_BACKWARD_CPP}) target_link_libraries(clang-uml ${YAML_CPP_LIBRARIES} ${LIBTOOLING_LIBS} ${MSVC_LIBRARIES} + ${BACKWARD_CPP_LIBRARIES} clang-umllib Threads::Threads) diff --git a/src/main.cc b/src/main.cc index a8e130be..58dc0d2c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -24,7 +24,9 @@ #include "util/util.h" #include "version.h" -#ifndef NDEBUG +#ifdef ENABLE_BACKWARD_CPP +#define BACKWARD_HAS_DW 1 +#define BACKWARD_HAS_LIBUNWIND 1 #include #endif @@ -40,7 +42,7 @@ #include #include -#ifndef NDEBUG +#ifdef ENABLE_BACKWARD_CPP namespace backward { backward::SignalHandling sh; // NOLINT } // namespace backward