From b1cc13a28464ea937e62f57b20caf67a8570d0b4 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 30 Jul 2024 14:40:33 +0200 Subject: [PATCH 1/4] clang_tidy.cmake: added `run-clang-tidy-20` to binaries to look for --- cmake/clang_tidy.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/clang_tidy.cmake b/cmake/clang_tidy.cmake index c7a23818d2b..60640e1de0e 100644 --- a/cmake/clang_tidy.cmake +++ b/cmake/clang_tidy.cmake @@ -11,7 +11,7 @@ if(NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) message(STATUS "Cannot use non-Clang compiler with clang-tidy when precompiled headers are enabled - skipping 'run-clang-tidy' target generation") endif() else() - set(RUN_CLANG_TIDY_NAMES run-clang-tidy run-clang-tidy-19 run-clang-tidy-18 run-clang-tidy-17 run-clang-tidy-16 run-clang-tidy-15 run-clang-tidy-14 run-clang-tidy-13 run-clang-tidy-12 run-clang-tidy-11 run-clang-tidy-10 run-clang-tidy-9 run-clang-tidy-8) + set(RUN_CLANG_TIDY_NAMES run-clang-tidy run-clang-tidy-20 run-clang-tidy-19 run-clang-tidy-18 run-clang-tidy-17 run-clang-tidy-16 run-clang-tidy-15 run-clang-tidy-14 run-clang-tidy-13 run-clang-tidy-12 run-clang-tidy-11 run-clang-tidy-10 run-clang-tidy-9 run-clang-tidy-8) endif() if(RUN_CLANG_TIDY_NAMES) From 1190e184375275af74e6987ee4d49fb7a28ef0a9 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 30 Jul 2024 14:40:47 +0200 Subject: [PATCH 2/4] updated CI to Clang 20 --- .github/workflows/asan.yml | 6 +++--- .github/workflows/clang-tidy.yml | 10 +++++----- .github/workflows/iwyu.yml | 10 +++++----- .github/workflows/tsan.yml | 6 +++--- .github/workflows/ubsan.yml | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index bbe52682512..d1efccfbd88 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -53,7 +53,7 @@ jobs: sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 19 + sudo ./llvm.sh 20 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -75,8 +75,8 @@ jobs: run: | cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_ADDRESS=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache env: - CC: clang-19 - CXX: clang++-19 + CC: clang-20 + CXX: clang++-20 - name: Build cppcheck run: | diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index f42a7340a54..f6f4c3651df 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -40,8 +40,8 @@ jobs: sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 19 - sudo apt-get install -y clang-tidy-19 + sudo ./llvm.sh 20 + sudo apt-get install -y clang-tidy-20 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -53,14 +53,14 @@ jobs: - name: Verify clang-tidy configuration run: | - clang-tidy-19 --verify-config + clang-tidy-20 --verify-config - name: Prepare CMake run: | cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCPPCHK_GLIBCXX_DEBUG=Off -DWARNINGS_ARE_ERRORS=On env: - CC: clang-19 - CXX: clang++-19 + CC: clang-20 + CXX: clang++-20 - name: Prepare CMake dependencies run: | diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 82760fb35cb..899469ba424 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -182,8 +182,8 @@ jobs: sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 19 - sudo apt-get install -y clang-tools-19 + sudo ./llvm.sh 20 + sudo apt-get install -y clang-tools-20 - name: Install libc++ if: matrix.stdlib == 'libc++' @@ -203,8 +203,8 @@ jobs: # TODO: why does it build dmake in the next step? cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCPPCHK_GLIBCXX_DEBUG=Off -DUSE_MATCHCOMPILER=Off -DEXTERNALS_AS_SYSTEM=On -DUSE_LIBCXX=${{ matrix.use_libcxx }} env: - CC: clang-19 - CXX: clang++-19 + CC: clang-20 + CXX: clang++-20 - name: Prepare CMake dependencies run: | @@ -221,7 +221,7 @@ jobs: - name: clang-include-cleaner run: | # TODO: run multi-threaded - find $PWD/cli $PWD/lib $PWD/test $PWD/gui -maxdepth 1 -name "*.cpp" | xargs -t -n 1 clang-include-cleaner-19 --print=changes --extra-arg=-w --extra-arg=-stdlib=${{ matrix.stdlib }} -p cmake.output > clang-include-cleaner.log 2>&1 + find $PWD/cli $PWD/lib $PWD/test $PWD/gui -maxdepth 1 -name "*.cpp" | xargs -t -n 1 clang-include-cleaner-20 --print=changes --extra-arg=-w --extra-arg=-stdlib=${{ matrix.stdlib }} -p cmake.output > clang-include-cleaner.log 2>&1 - uses: actions/upload-artifact@v4 if: success() || failure() diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml index e8d4ea45fca..389a738eebf 100644 --- a/.github/workflows/tsan.yml +++ b/.github/workflows/tsan.yml @@ -53,7 +53,7 @@ jobs: sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 19 + sudo ./llvm.sh 20 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -74,8 +74,8 @@ jobs: run: | cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=Off -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache env: - CC: clang-19 - CXX: clang++-19 + CC: clang-20 + CXX: clang++-20 - name: Build cppcheck run: | diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index 83fb5d15287..351ee813491 100644 --- a/.github/workflows/ubsan.yml +++ b/.github/workflows/ubsan.yml @@ -53,7 +53,7 @@ jobs: sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 19 + sudo ./llvm.sh 20 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -75,8 +75,8 @@ jobs: run: | cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_UNDEFINED=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache env: - CC: clang-19 - CXX: clang++-19 + CC: clang-20 + CXX: clang++-20 - name: Build cppcheck run: | From 7c522dbe691eeb3216b664a61d343ae36c694f71 Mon Sep 17 00:00:00 2001 From: firewave Date: Sat, 21 Dec 2024 12:48:13 +0100 Subject: [PATCH 3/4] added CMake option `ANALYZE_TYPE` to use the TypeSanitizer --- cmake/dynamic_analyzer_options.cmake | 6 ++++++ cmake/options.cmake | 1 + cmake/printInfo.cmake | 1 + 3 files changed, 8 insertions(+) diff --git a/cmake/dynamic_analyzer_options.cmake b/cmake/dynamic_analyzer_options.cmake index 1d82fc2dbf4..45d4674c3a3 100644 --- a/cmake/dynamic_analyzer_options.cmake +++ b/cmake/dynamic_analyzer_options.cmake @@ -31,3 +31,9 @@ if(ANALYZE_UNDEFINED) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=nullability") endif() endif() + +if(ANALYZE_TYPE) + add_compile_options(-fsanitize=type) + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=type") +endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index 35550edb154..5794594dda1 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -20,6 +20,7 @@ endif() option(ANALYZE_ADDRESS "Build with AddressSanitzer to detect memory error" OFF) option(ANALYZE_THREAD "Build with ThreadSanitizer to detect data races" OFF) option(ANALYZE_UNDEFINED "Build with UndefinedBehaviorSanitizer to detect undefined behavior" OFF) +option(ANALYZE_TYPE "Build with TypeSanitizer to detect aliasing issues" OFF) option(WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF) if(WARNINGS_ARE_ERRORS) diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index 7feaf60f603..3869629f7a3 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -30,6 +30,7 @@ message(STATUS "ANALYZE_MEMORY = ${ANALYZE_MEMORY}") message(STATUS "ANALYZE_ADDRESS = ${ANALYZE_ADDRESS}") message(STATUS "ANALYZE_THREAD = ${ANALYZE_THREAD}") message(STATUS "ANALYZE_UNDEFINED = ${ANALYZE_UNDEFINED}") +message(STATUS "ANALYZE_TYPE = ${ANALYZE_TYPE}") message(STATUS) message(STATUS "WARNINGS_ARE_ERRORS = ${WARNINGS_ARE_ERRORS}") message(STATUS "EXTERNALS_AS_SYSTEM = ${EXTERNALS_AS_SYSTEM}") From 3d3c04401cd55bd075cd539d9ca552e5abfb06fd Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 10 Jan 2025 16:21:25 +0100 Subject: [PATCH 4/4] library.cpp: fixed `bugprone-unhandled-self-assignment` clang-tidy warning --- lib/library.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/library.cpp b/lib/library.cpp index 80f70e3f141..98b3c0e0317 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -157,6 +157,9 @@ Library::Library(const Library& other) Library& Library::operator=(const Library& other) & { + if (this == &other) + return *this; + mData.reset(new LibraryData(*other.mData)); return *this; }