diff --git a/.clang-tidy b/.clang-tidy
index d5054062dac..66e05bc8677 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -30,6 +30,7 @@ Checks: >
-bugprone-signed-char-misuse,
-bugprone-switch-missing-default-case,
-bugprone-unchecked-optional-access,
+ -bugprone-unused-return-value,
-clang-analyzer-*,
-concurrency-mt-unsafe,
-misc-const-correctness,
@@ -48,6 +49,7 @@ Checks: >
-modernize-return-braced-init-list,
-modernize-type-traits,
-modernize-use-auto,
+ -modernize-use-designated-initializers,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-avoid-endl,
@@ -60,6 +62,7 @@ Checks: >
-readability-avoid-nested-conditional-operator,
-readability-braces-around-statements,
-readability-container-data-pointer,
+ -readability-enum-initial-value,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml
index 942f6e454d4..9297b2f2d5e 100644
--- a/.github/workflows/asan.yml
+++ b/.github/workflows/asan.yml
@@ -49,7 +49,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 18
+ sudo ./llvm.sh 19
- name: Install Qt ${{ env.QT_VERSION }}
if: false
@@ -71,8 +71,8 @@ jobs:
run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -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=Off -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
- CC: clang-18
- CXX: clang++-18
+ CC: clang-19
+ CXX: clang++-19
- name: Build cppcheck
run: |
diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml
index 27857e09af0..f934f2bb16b 100644
--- a/.github/workflows/clang-tidy.yml
+++ b/.github/workflows/clang-tidy.yml
@@ -37,8 +37,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 18
- sudo apt-get install -y clang-tidy-18
+ sudo ./llvm.sh 19
+ sudo apt-get install -y clang-tidy-19
- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
@@ -49,14 +49,14 @@ jobs:
- name: Verify clang-tidy configuration
run: |
- clang-tidy-18 --verify-config
+ clang-tidy-19 --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 -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCPPCHK_GLIBCXX_DEBUG=Off
env:
- CC: clang-18
- CXX: clang++-18
+ CC: clang-19
+ CXX: clang++-19
- name: Prepare CMake dependencies
run: |
diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml
index a7d2f253667..2baded1f6cd 100644
--- a/.github/workflows/iwyu.yml
+++ b/.github/workflows/iwyu.yml
@@ -147,8 +147,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 18
- sudo apt-get install -y clang-tools-18
+ sudo ./llvm.sh 19
+ sudo apt-get install -y clang-tools-19
- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
@@ -162,8 +162,8 @@ jobs:
run: |
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 -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
env:
- CC: clang-18
- CXX: clang++-18
+ CC: clang-19
+ CXX: clang++-19
- name: Prepare CMake dependencies
run: |
@@ -180,7 +180,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-18 --print=changes --extra-arg=-w -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-19 --print=changes --extra-arg=-w -p cmake.output > clang-include-cleaner.log 2>&1
- uses: actions/upload-artifact@v4
with:
diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml
index c9c4c224d34..d18ca317bc9 100644
--- a/.github/workflows/tsan.yml
+++ b/.github/workflows/tsan.yml
@@ -49,7 +49,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 18
+ sudo ./llvm.sh 19
- name: Install Qt ${{ env.QT_VERSION }}
if: false
@@ -70,8 +70,8 @@ jobs:
run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -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-18
- CXX: clang++-18
+ CC: clang-19
+ CXX: clang++-19
- name: Build cppcheck
run: |
diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml
index b2c57126873..41ff8a62fe8 100644
--- a/.github/workflows/ubsan.yml
+++ b/.github/workflows/ubsan.yml
@@ -49,7 +49,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 18
+ sudo ./llvm.sh 19
- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
@@ -70,8 +70,8 @@ jobs:
run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=ON -DWITH_QCHART=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-18
- CXX: clang++-18
+ CC: clang-19
+ CXX: clang++-19
- name: Build cppcheck
run: |
diff --git a/clang-tidy.md b/clang-tidy.md
index dce24786dcb..55e68de2979 100644
--- a/clang-tidy.md
+++ b/clang-tidy.md
@@ -125,7 +125,9 @@ We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as
`performance-noexcept-swap`
`bugprone-switch-missing-default-case`
`bugprone-empty-catch`
-`readability-avoid-nested-conditional-operator`
+`readability-avoid-nested-conditional-operator`
+`modernize-use-designated-initializers`
+`readability-enum-initial-value`
To be evaluated (need to remove exclusion).
@@ -140,11 +142,12 @@ To be evaluated (need to remove exclusion).
`cert-err33-c`
`google-readability-namespace-comments`
`cppcoreguidelines-special-member-functions`
+`bugprone-unused-return-value`
To be evaluated (need to enable explicitly).
-`modernize-type-traits`
-`modernize-use-nodiscard`
+`modernize-type-traits`
+`modernize-use-nodiscard`
These apply to codebases which use later standards then C++11 (C++17 is used when building with Qt6) so we cannot simply apply them.
diff --git a/cli/signalhandler.cpp b/cli/signalhandler.cpp
index 8d67b4a683a..15dda424de0 100644
--- a/cli/signalhandler.cpp
+++ b/cli/signalhandler.cpp
@@ -50,7 +50,7 @@
// TODO: __USE_DYNAMIC_STACK_SIZE is dependent on the features.h include and not a built-in compiler define, so it might be problematic to depend on it
#ifdef __USE_DYNAMIC_STACK_SIZE
-static constexpr size_t MYSTACKSIZE = 16*1024+32768; // wild guess about a reasonable buffer
+static constexpr size_t MYSTACKSIZE = (16*1024)+32768; // wild guess about a reasonable buffer
#else
static constexpr size_t MYSTACKSIZE = 16*1024+SIGSTKSZ; // wild guess about a reasonable buffer
#endif
diff --git a/cmake/clang_tidy.cmake b/cmake/clang_tidy.cmake
index 4964954a29c..06f65e32a49 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-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-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)
diff --git a/gui/codeeditor.cpp b/gui/codeeditor.cpp
index 07620ea3cec..ecc3575bc26 100644
--- a/gui/codeeditor.cpp
+++ b/gui/codeeditor.cpp
@@ -368,9 +368,9 @@ int CodeEditor::lineNumberAreaWidth()
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
- const int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
+ const int space = 3 + (fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits);
#else
- const int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
+ const int space = 3 + (fontMetrics().width(QLatin1Char('9')) * digits);
#endif
return space;
}
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index a510fbd1233..e73d48d3e53 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -1200,9 +1200,7 @@ QPair MainWindow::getCppcheckSettings()
result.standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString());
result.enforcedLang = (Standards::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();
- if (result.jobs <= 1) {
- result.jobs = 1;
- }
+ result.jobs = std::max(result.jobs, 1u);
Settings::terminate(false);
@@ -2169,7 +2167,7 @@ static int getVersion(const QString& nameWithVersion) {
break;
if (c == ' ') {
if (ret > 0 && dot == 1 && nameWithVersion.endsWith(" dev"))
- return ret * 1000000 + v * 1000 + 500;
+ return (ret * 1000000) + (v * 1000) + 500;
dot = ret = v = 0;
}
else if (c == '.') {
diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp
index 69babe4007b..bfe67c6b2f6 100644
--- a/gui/projectfiledialog.cpp
+++ b/gui/projectfiledialog.cpp
@@ -323,7 +323,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
mUI->mBtnSafeClasses->setChecked(projectFile->safeChecks.classes);
setExcludedPaths(projectFile->getExcludedPaths());
setLibraries(projectFile->getLibraries());
- const QString platform = projectFile->getPlatform();
+ const QString& platform = projectFile->getPlatform();
if (platform.endsWith(".xml")) {
int i;
for (i = numberOfBuiltinPlatforms; i < mUI->mComboBoxPlatform->count(); ++i) {
diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp
index c5e2b729966..9d1c16d0962 100644
--- a/gui/resultstree.cpp
+++ b/gui/resultstree.cpp
@@ -33,6 +33,7 @@
#include "threadhandler.h"
#include "xmlreportv2.h"
+#include
#include
#include
@@ -849,8 +850,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
if (mContextItem && mApplications->getApplicationCount() > 0 && mContextItem->parent()) {
//Create an action for the application
int defaultApplicationIndex = mApplications->getDefaultApplication();
- if (defaultApplicationIndex < 0)
- defaultApplicationIndex = 0;
+ defaultApplicationIndex = std::max(defaultApplicationIndex, 0);
const Application& app = mApplications->getApplication(defaultApplicationIndex);
auto *start = new QAction(app.getName(), &menu);
if (multipleSelection)
diff --git a/gui/statsdialog.cpp b/gui/statsdialog.cpp
index e4e19f5a58d..35fb1fef36b 100644
--- a/gui/statsdialog.cpp
+++ b/gui/statsdialog.cpp
@@ -22,6 +22,8 @@
#include "projectfile.h"
#include "showtypes.h"
+#include
+
#include "ui_statsdialog.h"
#include
@@ -409,8 +411,8 @@ QChartView *createChart(const QString &statsFile, const QString &tool)
s->attachAxis(axisY);
if (const auto *ls = dynamic_cast(s)) {
for (QPointF p : ls->points()) {
- if (p.y() > maxY)
- maxY = p.y();
+ // cppcheck-suppress useStlAlgorithm - this would reduce the readability of the code
+ maxY = std::max(p.y(), maxY);
}
}
}
diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp
index b6fd53d251f..d69f2db0fed 100644
--- a/gui/threadhandler.cpp
+++ b/gui/threadhandler.cpp
@@ -23,6 +23,7 @@
#include "resultsview.h"
#include "settings.h"
+#include
#include
#include
#include
@@ -92,10 +93,7 @@ void ThreadHandler::check(const Settings &settings)
setThreadCount(settings.jobs);
mRunningThreadCount = mThreads.size();
-
- if (mResults.getFileCount() < mRunningThreadCount) {
- mRunningThreadCount = mResults.getFileCount();
- }
+ mRunningThreadCount = std::min(mResults.getFileCount(), mRunningThreadCount);
QStringList addonsAndTools = mAddonsAndTools;
for (const std::string& addon: settings.addons) {
diff --git a/lib/astutils.cpp b/lib/astutils.cpp
index 08a0a046cd1..d5db7ab7334 100644
--- a/lib/astutils.cpp
+++ b/lib/astutils.cpp
@@ -464,7 +464,7 @@ bool isTemporary(const Token* tok, const Library* library, bool unknown)
if (ftok->type())
return true;
if (library) {
- std::string returnType = library->returnValueType(ftok);
+ const std::string& returnType = library->returnValueType(ftok);
return !returnType.empty() && returnType.back() != '&';
}
return unknown;
diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp
index 144ae310919..204b2b974c2 100644
--- a/lib/checkbufferoverrun.cpp
+++ b/lib/checkbufferoverrun.cpp
@@ -158,13 +158,11 @@ static int getMinFormatStringOutputLength(const std::vector ¶m
if (formatString[i] == 's') {
// For strings, the length after the dot "%.2s" will limit
// the length of the string.
- if (parameterLength > maxLen)
- parameterLength = maxLen;
+ parameterLength = std::min(parameterLength, maxLen);
} else {
// For integers, the length after the dot "%.2d" can
// increase required length
- if (tempDigits < maxLen)
- tempDigits = maxLen;
+ tempDigits = std::max(tempDigits, maxLen);
}
}
diff --git a/lib/checkersreport.cpp b/lib/checkersreport.cpp
index f6b7c2e8c0b..3391a8edfd8 100644
--- a/lib/checkersreport.cpp
+++ b/lib/checkersreport.cpp
@@ -22,6 +22,7 @@
#include "errortypes.h"
#include "settings.h"
+#include
#include