Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ Checks: >
google-explicit-constructor,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-command-processor,
-bugprone-easily-swappable-parameters,
-bugprone-empty-catch,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-signed-char-misuse,
-bugprone-switch-missing-default-case,
-bugprone-throwing-static-initialization,
-bugprone-unchecked-optional-access,
-clang-analyzer-*,
-concurrency-mt-unsafe,
Expand All @@ -37,11 +39,12 @@ Checks: >
-misc-non-private-member-variables-in-classes,
-misc-throw-by-value-catch-by-reference,
-misc-use-anonymous-namespace,
-misc-use-internal-linkage,
-modernize-avoid-c-arrays,
-modernize-deprecated-ios-base-aliases,
-misc-include-cleaner,
-misc-multiple-inheritance,
-misc-unused-using-decls,
-modernize-avoid-c-style-cast,
-modernize-loop-convert,
-modernize-macro-to-enum,
-modernize-raw-string-literal,
Expand All @@ -67,9 +70,10 @@ Checks: >
-readability-identifier-length,
-readability-identifier-naming,
-readability-implicit-bool-conversion,
-readability-inconsistent-ifelse-braces,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-math-missing-parentheses,
-readability-redundant-parentheses,
-readability-suspicious-call-argument,
-readability-uppercase-literal-suffix,
-readability-use-concise-preprocessor-directives,
Expand All @@ -84,3 +88,7 @@ CheckOptions:
value: '0'
- key: modernize-use-trailing-return-type.TransformFunctions
value: false
- key: misc-override-with-different-visibility.DisallowedVisibilityChange
value: widening
- key: misc-use-internal-linkage.AnalyzeTypes
value: false
6 changes: 3 additions & 3 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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 21
sudo ./llvm.sh 22

- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v4
Expand All @@ -76,8 +76,8 @@ jobs:
run: |
cmake -S . -B cmake.output -Werror=dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=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_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang-21
CXX: clang++-21
CC: clang-22
CXX: clang++-22

- name: Build cppcheck
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,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 21
sudo apt-get install -y clang-tidy-21
sudo ./llvm.sh 22
sudo apt-get install -y clang-tidy-22

- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v4
Expand All @@ -57,14 +57,14 @@ jobs:

- name: Verify clang-tidy configuration
run: |
clang-tidy-21 --verify-config
clang-tidy-22 --verify-config

- name: Prepare CMake
run: |
cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_COMPILE_WARNING_AS_ERROR=On
env:
CC: clang-21
CXX: clang++-21
CC: clang-22
CXX: clang++-22

- name: Prepare CMake dependencies
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ 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 21
sudo apt-get install -y clang-tools-21
sudo ./llvm.sh 22
sudo apt-get install -y clang-tools-22

- name: Install libc++
if: matrix.stdlib == 'libc++'
run: |
sudo apt-get install -y libc++-21-dev
sudo apt-get install -y libc++-22-dev

- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v4
Expand All @@ -238,8 +238,8 @@ jobs:
run: |
cmake -S . -B cmake.output -Werror=dev -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=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-21
CXX: clang++-21
CC: clang-22
CXX: clang++-22

- name: Prepare CMake dependencies
run: |
Expand All @@ -256,7 +256,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-21 --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-22 --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()
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 21
sudo ./llvm.sh 22

- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v4
Expand All @@ -75,8 +75,8 @@ jobs:
run: |
cmake -S . -B cmake.output -Werror=dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=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_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang-21
CXX: clang++-21
CC: clang-22
CXX: clang++-22

- name: Build cppcheck
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 21
sudo ./llvm.sh 22

- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v4
Expand All @@ -75,8 +75,8 @@ jobs:
run: |
cmake -S . -B cmake.output -Werror=dev -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=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_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang-21
CXX: clang++-21
CC: clang-22
CXX: clang++-22

- name: Build cppcheck
run: |
Expand Down
13 changes: 13 additions & 0 deletions clang-tidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Does not improve the readability.
`misc-unconventional-assign-operator`<br/>
`bugprone-throwing-static-initialization`<br/>
`bugprone-command-processor`<br/>
`misc-multiple-inheritance`<br/>

To be evaluated (need to remove exclusion).

Expand Down Expand Up @@ -163,6 +164,18 @@ We are not interested in this.

Reports false positives - see https://github.com/llvm/llvm-project/issues/164125.

`readability-inconsistent-ifelse-braces`<br/>

The suggestions are too intrusive.

`modernize-avoid-c-style-cast`<br/>

Currently flags functional casts - see https://github.com/llvm/llvm-project/issues/186784.

`misc-use-internal-linkage.AnalyzeTypes`<br/>

Adding anonymous namespaces requires identation which is too instrusive right now. Would require changes to our fomatting configuration.

### Disabled for performance reasons

`portability-std-allocator-const`<br/>
Expand Down
6 changes: 6 additions & 0 deletions cmake/clang_tidy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ if(RUN_CLANG_TIDY_NAMES)
endif()
message(STATUS "NPROC=${NPROC}")

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 22)
set(CLANG_TIDY_CONFIG "-enable-check-profile")
else()
set(CLANG_TIDY_CONFIG "")
endif()

# most of these are disabled because they are too noisy in our code
# clang-analyzer-core.CallAndMessage
# clang-analyzer-core.NonNullParamChecker
Expand Down
6 changes: 6 additions & 0 deletions cmake/compileroptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-weak-vtables)
add_compile_options(-Wno-multichar)

# FIXME: only reported when running clang-tidy
# /home/runner/work/cppcheck/cppcheck/tools/triage/mainwindow.cpp:19:10: error: multiple candidates for header 'mainwindow.h' found; directory '/home/runner/work/cppcheck/cppcheck/tools/triage' chosen, ignoring others including '/home/runner/work/cppcheck/cppcheck/gui' [clang-diagnostic-shadow-header]
# 19 | #include "mainwindow.h"
# | ^
add_compile_options_safe(-Wno-shadow-header)

if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
message(FATAL_ERROR "Do not use clang to generate code coverage. Use GCC instead.")
endif()
Expand Down
2 changes: 1 addition & 1 deletion lib/vf_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace ValueFlow
return value;

const MathLib::biguint unsignedMaxValue = std::numeric_limits<MathLib::biguint>::max() >> ((sizeof(unsignedMaxValue) - value_size) * 8);
const MathLib::biguint signBit = 1ULL << (value_size * 8 - 1);
const MathLib::biguint signBit = 1ULL << ((value_size * 8) - 1);
value &= unsignedMaxValue;
if (dst_sign == ValueType::Sign::SIGNED && (value & signBit))
value |= ~unsignedMaxValue;
Expand Down
2 changes: 1 addition & 1 deletion test/testcheckersreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestCheckersReport : public TestFixture {
public:
TestCheckersReport() : TestFixture("TestCheckersReport") {}


private:
void run() final {
// AddonInfo::checkers
TEST_CASE(addonInfoCheckers);
Expand Down
1 change: 1 addition & 0 deletions tools/triage/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ MainWindow::MainWindow(QWidget *parent) :
srcFiles{"*.cpp", "*.cxx", "*.cc", "*.c++", "*.C", "*.c", "*.cl"}
{
ui->setupUi(this);
// NOLINTNEXTLINE(bugprone-random-generator-seed) - the random numbers are not used in a security context so this should be sufficient
std::srand(static_cast<unsigned int>(std::time(nullptr)));
QDir workFolder(WORK_FOLDER);
if (!workFolder.exists()) {
Expand Down
Loading