From 0725556ea15836cf04d14ce2ba658d04c0da634c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 29 Dec 2025 19:31:09 +0100 Subject: [PATCH 001/675] Fix #14344 FP containerOutOfBounds when passing lambda (#8065) Co-authored-by: chrchr-github --- lib/tokenlist.cpp | 2 -- test/testtokenize.cpp | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 2953b0c895d..ff9218433be 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -573,8 +573,6 @@ static bool iscpp11init_impl(const Token * const tok) if (nameToken->isCpp11init() != Token::Cpp11init::UNKNOWN) return nameToken->isCpp11init() == Token::Cpp11init::CPP11INIT; nameToken = nameToken->previous(); - if (nameToken && nameToken->str() == "," && Token::simpleMatch(nameToken->previous(), "} ,")) - nameToken = nameToken->linkAt(-1); } if (!nameToken) return false; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index c9d1b8336ab..02b4b64a8ed 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8493,6 +8493,10 @@ class TestTokenizer : public TestFixture { "{ } } {", Token::Cpp11init::CPP11INIT); + testIsCpp11init("void f() { g([]() {}, { 1 }); }\n", + "{ 1", + Token::Cpp11init::CPP11INIT); + ASSERT_NO_THROW(tokenizeAndStringify("template struct X {};\n" // don't crash "template auto f(T t) -> X {}\n")); ASSERT_EQUALS("[test.cpp:2:22]: (debug) auto token with no type. [autoNoType]\n", errout_str()); From ad9563f1b46b16fc6222e7736b57b2048834943b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 29 Dec 2025 19:37:48 +0100 Subject: [PATCH 002/675] fixed #14267 - fixed compilation with C++17 / use `simplecpp::View` (#7962) --- .github/workflows/CI-unixish.yml | 54 ++++++++++++++++++++++++++++++++ .github/workflows/CI-windows.yml | 31 +++++++++++++++--- cmake/cxx11.cmake | 6 ++++ democlient/democlient.cpp | 2 +- gui/mainwindow.cpp | 2 +- lib/cppcheck.cpp | 6 ++-- lib/cppcheck.h | 4 +-- lib/tokenlist.cpp | 13 +++++--- lib/tokenlist.h | 10 +++--- oss-fuzz/main.cpp | 2 +- test/helpers.cpp | 2 +- test/testpreprocessor.cpp | 9 +++--- test/testsuppressions.cpp | 4 +-- 13 files changed, 116 insertions(+), 29 deletions(-) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 4478f1b762d..68d4c867367 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -191,6 +191,60 @@ jobs: run: | cmake -S . -B cmake.output_nocli_nogui -G "Unix Makefiles" -DBUILD_GUI=Off + build_cmake_cxxstd: + + strategy: + matrix: + os: [ubuntu-22.04, macos-15] + cxxstd: [14, 17] + fail-fast: false # Prefer quick result + + runs-on: ${{ matrix.os }} + + env: + # TODO: figure out why there are cache misses with PCH enabled + CCACHE_SLOPPINESS: pch_defines,time_macros + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}-${{ matrix.cxxstd }} + + - name: Install missing software on ubuntu + if: contains(matrix.os, 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install libxml2-utils + # qt6-tools-dev-tools for lprodump + # qt6-l10n-tools for lupdate + sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev + + # coreutils contains "nproc" + - name: Install missing software on macos + if: contains(matrix.os, 'macos') + run: | + # pcre was removed from runner images in November 2022 + brew install coreutils qt@6 pcre + + - name: Run CMake on ubuntu (with GUI) + if: contains(matrix.os, 'ubuntu') + run: | + cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + + - name: Run CMake on macos (with GUI) + if: contains(matrix.os, 'macos') + run: | + cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + + - name: Run CMake build + run: | + cmake --build cmake.output -- -j$(nproc) + build_uchar: strategy: diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index 55be78ee06e..1c572a9dc3d 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -19,8 +19,6 @@ defaults: run: shell: cmd -# TODO: choose/add a step to bail out on compiler warnings (maybe even the release build) - jobs: build_qt: @@ -73,6 +71,33 @@ jobs: run: | cmake --build build --target install + build_cmake_cxxstd: + strategy: + matrix: + os: [windows-2022, windows-2025] + cxxstd: [14, 17] + fail-fast: false + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Set up Visual Studio environment + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + + - name: Run CMake + run: | + cmake -S . -B build.cxxstd -G "Visual Studio 17 2022" -A x64 -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + + - name: Build + run: | + cmake --build build.cxxstd --config Debug || exit /b !errorlevel! + build: strategy: matrix: @@ -142,8 +167,6 @@ jobs: python -m pip install pytest-xdist || exit /b !errorlevel! python -m pip install psutil || exit /b !errorlevel! - # TODO: build with CMake - - name: Build CLI debug configuration using MSBuild if: matrix.config == 'debug' run: | diff --git a/cmake/cxx11.cmake b/cmake/cxx11.cmake index 2deba34edaa..99e94ea4d23 100644 --- a/cmake/cxx11.cmake +++ b/cmake/cxx11.cmake @@ -1,6 +1,12 @@ macro(use_cxx11) + if(CMAKE_CXX_STANDARD EQUAL 98) + message(FATAL_ERROR "C++ standard was set to ${CMAKE_CXX_STANDARD} but 11 is required as minimum") + endif() if(USE_BOOST AND USE_BOOST_INT128) # Boost.Math requires C++14 + if(CMAKE_CXX_STANDARD LESS 14) + message(FATAL_ERROR "C++ standard was set to ${CMAKE_CXX_STANDARD} but 14 is required as minimum") + endif() set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to use") else() set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use") diff --git a/democlient/democlient.cpp b/democlient/democlient.cpp index a8317c2da4b..e45baf51cbd 100644 --- a/democlient/democlient.cpp +++ b/democlient/democlient.cpp @@ -67,7 +67,7 @@ class CppcheckExecutor : public ErrorLogger { {} void run(const char* code) { - cppcheck.checkBuffer(FileWithDetails("test.cpp", Standards::Language::CPP, 0), reinterpret_cast(code), strlen(code)); + cppcheck.checkBuffer(FileWithDetails("test.cpp", Standards::Language::CPP, 0), code, strlen(code)); } void reportOut(const std::string & /*outmsg*/, Color /*c*/) override {} diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 96dadb86374..9603a3ebb97 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -736,7 +736,7 @@ void MainWindow::analyzeCode(const QString& code, const QString& filename) { const std::string code_s = code.toStdString(); // TODO: apply enforcedLanguage? - cppcheck.checkBuffer(FileWithDetails(filename.toStdString(), Path::identify(filename.toStdString(), false), 0), reinterpret_cast(code_s.data()), code_s.size()); + cppcheck.checkBuffer(FileWithDetails(filename.toStdString(), Path::identify(filename.toStdString(), false), 0), code_s.data(), code_s.size()); } analysisDone(); diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 11d15521ec4..0fb23203718 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -799,7 +799,7 @@ unsigned int CppCheck::check(const FileWithDetails &file) return returnValue; } -unsigned int CppCheck::checkBuffer(const FileWithDetails &file, const uint8_t* data, std::size_t size) +unsigned int CppCheck::checkBuffer(const FileWithDetails &file, const char* data, std::size_t size) { return checkBuffer(file, "", 0, data, size); } @@ -874,10 +874,10 @@ std::size_t CppCheck::calculateHash(const Preprocessor& preprocessor, const std: return preprocessor.calculateHash(toolinfo.str()); } -unsigned int CppCheck::checkBuffer(const FileWithDetails &file, const std::string &cfgname, int fileIndex, const uint8_t* data, std::size_t size) +unsigned int CppCheck::checkBuffer(const FileWithDetails &file, const std::string &cfgname, int fileIndex, const char* data, std::size_t size) { const auto f = [&file, data, size](std::vector& files, simplecpp::OutputList* outputList) { - return simplecpp::TokenList{data, size, files, file.spath(), outputList}; + return simplecpp::TokenList{{data, size}, files, file.spath(), outputList}; }; return checkInternal(file, cfgname, fileIndex, f); } diff --git a/lib/cppcheck.h b/lib/cppcheck.h index b001749ded7..44286c294d2 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -108,7 +108,7 @@ class CPPCHECKLIB CppCheck { * @note You must set settings before calling this function (by calling * settings()). */ - unsigned int checkBuffer(const FileWithDetails &file, const uint8_t* data, std::size_t size); + unsigned int checkBuffer(const FileWithDetails &file, const char* data, std::size_t size); /** * @brief Returns current version number as a string. @@ -194,7 +194,7 @@ class CPPCHECKLIB CppCheck { * @param size the size of the data to be read * @return number of errors found */ - unsigned int checkBuffer(const FileWithDetails& file, const std::string &cfgname, int fileIndex, const uint8_t* data, std::size_t size); + unsigned int checkBuffer(const FileWithDetails& file, const std::string &cfgname, int fileIndex, const char* data, std::size_t size); // TODO: should use simplecpp::OutputList using CreateTokenListFn = std::function&, std::list*)>; diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index ff9218433be..2ed39b82f43 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -321,17 +321,17 @@ void TokenList::insertTokens(Token *dest, const Token *src, nonneg int n) //--------------------------------------------------------------------------- -bool TokenList::createTokensFromBuffer(const uint8_t* data, size_t size) +bool TokenList::createTokensFromBuffer(const char* data, size_t size) { return createTokensFromBufferInternal(data, size, mFiles.empty() ? "" : *mFiles.cbegin()); } //--------------------------------------------------------------------------- -bool TokenList::createTokensFromBufferInternal(const uint8_t* data, size_t size, const std::string& file0) +bool TokenList::createTokensFromBufferInternal(const char* data, size_t size, const std::string& file0) { simplecpp::OutputList outputList; - simplecpp::TokenList tokens(data, size, mFiles, file0, &outputList); + simplecpp::TokenList tokens({data, size}, mFiles, file0, &outputList); createTokens(std::move(tokens)); @@ -1866,7 +1866,12 @@ namespace { ~OnException() { #ifndef _MSC_VER - if (std::uncaught_exception()) +#if defined(__cpp_lib_uncaught_exceptions) + const bool b = std::uncaught_exceptions() > 0; +#else + const bool b = std::uncaught_exception(); +#endif + if (b) f(); #endif } diff --git a/lib/tokenlist.h b/lib/tokenlist.h index 23a3acd6f6e..764eb67bdee 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -99,14 +99,14 @@ class CPPCHECKLIB TokenList { * - UTF in the code are not handled. * - comments are not handled. */ - bool createTokensFromBuffer(const uint8_t* data, size_t size); - bool createTokensFromBuffer(const char* data, size_t size) { - return createTokensFromBuffer(reinterpret_cast(data), size); + bool createTokensFromBuffer(const uint8_t* data, size_t size) { + return createTokensFromBuffer(reinterpret_cast(data), size); } + bool createTokensFromBuffer(const char* data, size_t size); template // cppcheck-suppress unusedFunction - used in tests only bool createTokensFromString(const char (&data)[size]) { - return createTokensFromBuffer(reinterpret_cast(data), size-1); + return createTokensFromBuffer(data, size-1); } void createTokens(simplecpp::TokenList&& tokenList); @@ -216,7 +216,7 @@ class CPPCHECKLIB TokenList { } private: - bool createTokensFromBufferInternal(const uint8_t* data, std::size_t size, const std::string& file0); + bool createTokensFromBufferInternal(const char* data, std::size_t size, const std::string& file0); /** Token list */ std::shared_ptr mTokensFrontBack; diff --git a/oss-fuzz/main.cpp b/oss-fuzz/main.cpp index a5c717da776..65c350c920a 100644 --- a/oss-fuzz/main.cpp +++ b/oss-fuzz/main.cpp @@ -64,7 +64,7 @@ static void doCheck(const uint8_t *data, size_t dataSize) { Suppressions supprs; CppCheck cppcheck(s_settings, supprs, s_errorLogger, false, nullptr); - cppcheck.checkBuffer(s_file, data, dataSize); + cppcheck.checkBuffer(s_file, reinterpret_cast(data), dataSize); } #ifndef NO_FUZZ diff --git a/test/helpers.cpp b/test/helpers.cpp index 780d189f649..25b4564ed38 100644 --- a/test/helpers.cpp +++ b/test/helpers.cpp @@ -114,7 +114,7 @@ ScopedFile::~ScopedFile() { void SimpleTokenizer2::preprocess(const char* code, std::size_t size, std::vector &files, const std::string& file0, Tokenizer& tokenizer, ErrorLogger& errorlogger) { simplecpp::OutputList outputList; - simplecpp::TokenList tokens1(code, size, files, file0, &outputList); + simplecpp::TokenList tokens1({code, size}, files, file0, &outputList); Preprocessor preprocessor(tokens1, tokenizer.getSettings(), errorlogger, Path::identify(tokens1.getFiles()[0], false)); (void)preprocessor.loadFiles(files); // TODO: check result diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 369de0d2640..796c03b9a7f 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -120,7 +120,8 @@ class TestPreprocessor : public TestFixture { simplecpp::OutputList outputList; std::vector files; - simplecpp::TokenList tokens(code, size, files, Path::simplifyPath(filename), &outputList); + simplecpp::TokenList tokens({code, size}, files, Path::simplifyPath(filename), &outputList); + // TODO: we should be using the actual Preprocessor implementation Preprocessor preprocessor(tokens, settings, errorlogger, Path::identify(tokens.getFiles()[0], false)); @@ -372,8 +373,7 @@ class TestPreprocessor : public TestFixture { ASSERT(settings.library.load("", library, false).errorcode == Library::ErrorCode::OK); std::vector files; simplecpp::OutputList outputList; - // TODO: this adds an empty filename - simplecpp::TokenList tokens(code,files,"",&outputList); + simplecpp::TokenList tokens(code,files,"test.c",&outputList); Preprocessor preprocessor(tokens, settings, *this, Standards::Language::C); // TODO: do we need to consider #file? ASSERT(preprocessor.loadFiles(files)); ASSERT(!preprocessor.reportOutput(outputList, true)); @@ -388,8 +388,7 @@ class TestPreprocessor : public TestFixture { template std::size_t getHash(const char (&code)[size]) { std::vector files; - // TODO: this adds an empty filename - simplecpp::TokenList tokens(code,files,""); + simplecpp::TokenList tokens(code,files,"test.c"); Preprocessor preprocessor(tokens, settingsDefault, *this, Standards::Language::C); // TODO: do we need to consider #file? ASSERT(preprocessor.loadFiles(files)); preprocessor.removeComments(); diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index f946461ff89..77032c50c69 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -1312,7 +1312,7 @@ class TestSuppressions : public TestFixture { CppCheck cppCheck(settings, supprs, *this, false, nullptr); // <- do not "use global suppressions". pretend this is a thread that just checks a file. const char code[] = "int f() { int a; return a; }"; - ASSERT_EQUALS(0, cppCheck.checkBuffer(FileWithDetails("test.c", Standards::Language::C, 0), reinterpret_cast(code), sizeof(code))); // <- no unsuppressed error is seen + ASSERT_EQUALS(0, cppCheck.checkBuffer(FileWithDetails("test.c", Standards::Language::C, 0),code, sizeof(code))); // <- no unsuppressed error is seen ASSERT_EQUALS("[test.c:1:25]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); // <- report error so ThreadExecutor can suppress it and make sure the global suppression is matched. } @@ -1352,7 +1352,7 @@ class TestSuppressions : public TestFixture { " int y;\n" "};"; CppCheck cppCheck(settings, supprs, *this, true, nullptr); - ASSERT_EQUALS(0, cppCheck.checkBuffer(FileWithDetails("/somewhere/test.cpp", Standards::Language::CPP, 0), reinterpret_cast(code), sizeof(code))); + ASSERT_EQUALS(0, cppCheck.checkBuffer(FileWithDetails("/somewhere/test.cpp", Standards::Language::CPP, 0), code, sizeof(code))); ASSERT_EQUALS("",errout_str()); } From 58c6d2cd97c6799a282899606a2f7760dd8eda31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 29 Dec 2025 19:52:35 +0100 Subject: [PATCH 003/675] refs #1059 - extract configurations for `#if x <= y` and `#if x >= y` (#8037) --- lib/preprocessor.cpp | 2 +- test/testpreprocessor.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 5979dc4b45a..b10ff859ad6 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -410,7 +410,7 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::setstr(); } - if (len == 3 && cond->name && next1->str() == "==" && next2->number) { + if (len == 3 && cond->name && (next1->str() == "==" || next1->str() == "<=" || next1->str() == ">=") && next2->number) { if (defined.find(cond->str()) == defined.end()) return cond->str() + '=' + cond->next->next->str(); } diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 796c03b9a7f..781f6b6cf35 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -317,6 +317,8 @@ class TestPreprocessor : public TestFixture { TEST_CASE(getConfigs11); // #9832 - include guards TEST_CASE(getConfigs12); // #14222 TEST_CASE(getConfigs13); // #14222 + TEST_CASE(getConfigs14); // #1059 + TEST_CASE(getConfigs15); // #1059 TEST_CASE(getConfigsError); TEST_CASE(getConfigsD1); @@ -2288,6 +2290,20 @@ class TestPreprocessor : public TestFixture { ASSERT_EQUALS("\n", getConfigsStr(filedata, nullptr, "gnu.cfg")); } + void getConfigs14() { // #1059 + const char filedata[] = "#if A >= 1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata)); + } + + void getConfigs15() { // #1059 + const char filedata[] = "#if A <= 1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata)); + } + void getConfigsError() { const char filedata1[] = "#ifndef X\n" "#error \"!X\"\n" From 41fa8a9c20774dfb5873d4d52fc68aa816e37909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Mon, 29 Dec 2025 19:58:15 +0100 Subject: [PATCH 004/675] Add some of the missing German translations (#8063) --- gui/cppcheck_de.ts | 116 +++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 68 deletions(-) diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index 3dbebdaabd2..0197f93c728 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -40,7 +40,7 @@ der GNU General Public License Version 3 lizenziert <html><head/><body><p>Many thanks to these libraries that we use:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">PCRE</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">PicoJSON</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">TinyXML2</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Boost</li></ul></body></html> <html><head/><body><p>Many thanks to these libraries that we use:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">pcre</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">picojson</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qt</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">tinyxml2</li></ul></body></html> - + <html><head/><body><p>Vielen Dank den Bibliotheken die wir nutzen:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">PCRE</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">PicoJSON</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">TinyXML2</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Boost</li></ul></body></html> @@ -63,7 +63,7 @@ The following texts in parameters are replaced with appropriate values when appl Example opening a file with Kate and make Kate scroll to the correct line: Executable: kate Parameters: -l(line) (file) - Hier können Sie Anwendungen hinzufügen, die Codedateien öffnen können. Geben Sie den Namen der Anwendung, deren ausführbare Datei und Kommandozeilenparameter für die Ausführung an. + Hier können Sie Anwendungen hinzufügen, die Codedateien öffnen können. Geben Sie den Namen der Anwendung, deren ausführbare Datei und Kommandozeilenparameter für die Ausführung, an. Die folgenden Texte in Parametern werden durch die passenden Werte ersetzt, wenn die Anwendung ausgeführt wird: (file) - Name der Datei, die den Fehler enthält @@ -122,63 +122,63 @@ Parameter: -l(line) (file) Compliance Report - + Compliance-Report Project name - + Projektname Project version - + Projekt-Version Coding Standard - + Programmierstandards Misra C - + Misra C Cert C - + Cert C Cert C++ - + Cert C++ List of files with md5 checksums - + Datei-Listen mit MD5-Prüfsummen Compliance report - + Compliance-Report HTML files (*.html) - + HTML-Dateien (*.html) Save compliance report - + Compliance-Report speichern Failed to import '%1' (%2), can not show files in compliance report - + Import von '%1' (%2) fehlgeschlagen, Compliance-Report kann nicht angezeigt werden @@ -205,27 +205,27 @@ Parameter: -l(line) (file) Cppcheck GUI help - + Cppcheck GUI Hilfe Contents - + Inhalt Index - + Index Helpfile '%1' was not found - + Hilfedatei '%1' nicht gefunden Cppcheck - Cppcheck + Cppcheck @@ -1021,7 +1021,7 @@ Parameter: -l(line) (file) Misra C - + Misra C @@ -1031,12 +1031,12 @@ Parameter: -l(line) (file) Cert C - + Cert C Cert C++ - + Cert C++ @@ -1671,7 +1671,7 @@ Options: Selected VS Configurations - + Ausgewählte VS-Konfiguration @@ -1774,7 +1774,7 @@ Options: Check code in unused templates (should be ON normally, however in theory you can safely ignore warnings in unused templates) Check code in unused templates (slower and less accurate analysis) - Prüfe Code in ungenutzten Templates (langsamere und weniger genaue Analyse) + Prüfe Code in ungenutzten Templates (normalerweise AN, theoretisch können Warnungen in ungenutzten Templates gefahrlos ignoriert werden) @@ -1814,7 +1814,7 @@ Options: Enable inline suppressions - Inline-Fehlerunterdrückung aktivieren + Inline-Fehlerunterdrückung aktivieren @@ -1834,7 +1834,7 @@ Options: Cert C - + Cert C @@ -1955,7 +1955,7 @@ Options: Misra C - + Misra C @@ -1971,7 +1971,7 @@ Options: Cert C++ - + Cert C++ @@ -2019,7 +2019,7 @@ Options: Note: Open source Cppcheck does not fully implement Misra C 2012 - + Hinweis: Open-Source Cppcheck implementiert Misra C 2012 nicht vollständig @@ -2054,17 +2054,17 @@ Options: Source files - + Quelltext-Dateien All files - + Alle Dateien Exclude file - + Datei ausschließen @@ -2074,7 +2074,7 @@ Options: MISRA rule texts file (%1) - MISRA-Regeltext-Datei + MISRA-Regeltext-Datei (%1) @@ -2378,7 +2378,7 @@ Options: Please select the directory where file is located. - Bitte wählen Sie das Verzeichnis, wo sich die Datei befindet + Bitte wählen Sie das Verzeichnis, in dem sich die Datei befindet. @@ -2390,14 +2390,6 @@ Options: note Anmerkung - - Recheck - Erneut prüfen - - - Hide - Verstecken - Hide all with id @@ -2416,17 +2408,17 @@ Options: internal - + Intern Recheck %1 file(s) - + Erneut %1 Datei(en) prüfen Hide %1 result(s) - + Verstecke %1 Ergebnis(se) @@ -2481,18 +2473,6 @@ Bitte überprüfen Sie ob der Pfad und die Parameter der Anwendung richtig einge Select Directory Wähle Verzeichnis - - Id - Id - - - Inconclusive - Unklar - - - Since date - Seit Datum - style @@ -2598,27 +2578,27 @@ Legen Sie unter dem Menü Ansicht fest, welche Arten von Fehlern angezeigt werde Analysis was stopped - + Analyse wurde gestoppt There was a critical error with id '%1' - + Kritischer Fehler mit ID '%1' aufgetreten when checking %1 - + beim Prüfen von %1 when checking a file - + beim Prüfen einer Datei Analysis was aborted. - + Analyse abgebrochen. @@ -2634,7 +2614,7 @@ Legen Sie unter dem Menü Ansicht fest, welche Arten von Fehlern angezeigt werde Critical errors - + Kritische Fehler @@ -2739,7 +2719,7 @@ Legen Sie unter dem Menü Ansicht fest, welche Arten von Fehlern angezeigt werde Check for updates - + Auf Updates prüfen @@ -2836,7 +2816,7 @@ Legen Sie unter dem Menü Ansicht fest, welche Arten von Fehlern angezeigt werde Max count: - + Maximalzahl: @@ -2884,7 +2864,7 @@ Legen Sie unter dem Menü Ansicht fest, welche Arten von Fehlern angezeigt werde The executable file "%1" is not available - + Die ausführbare Datei "%1" ist nicht verfügbar @@ -3017,12 +2997,12 @@ Legen Sie unter dem Menü Ansicht fest, welche Arten von Fehlern angezeigt werde Active checkers: - + Aktive Checker: Checkers - + Checker From 69a2d17faf7abadceec3c2254c6b285498ae8f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Mon, 29 Dec 2025 20:08:48 +0100 Subject: [PATCH 005/675] readme.md: Adjust minimum required Python to 3.7 [skip ci] (#8060) CMake checks for Python 3.7, see https://github.com/danmar/cppcheck/blob/b66f900e2067006ca81eaa7648bdae9a5a7d6466/cmake/findDependencies.cmake#L58 --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a902f9fd2ef..a5f40486719 100644 --- a/readme.md +++ b/readme.md @@ -46,7 +46,7 @@ There are multiple compilation choices: * (Windows) Qt Creator + MinGW * GNU compilers - via make or directly -The minimum required Python version is 3.6. +The minimum required Python version is 3.7. ### CMake From dd01ff17ff1726d640348ba31cbc2be7e7eae6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 31 Dec 2025 14:42:51 +0100 Subject: [PATCH 006/675] fix #14315: FP knownConditionTrueFalse with constant in assert() (#8064) --- lib/checkother.cpp | 4 +++- test/testother.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index df842260906..53257591273 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2948,7 +2948,9 @@ void CheckOther::checkDuplicateExpression() while (parent && parent->astParent()) { parent = parent->astParent(); } - if (parent && parent->previous() && isStaticAssert(*mSettings, parent->previous())) { + if (parent && parent->previous() && + (isStaticAssert(*mSettings, parent->previous()) || + Token::simpleMatch(parent->previous(), "assert"))) { continue; } } diff --git a/test/testother.cpp b/test/testother.cpp index 6b1ae634d26..a54ee364366 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -195,6 +195,7 @@ class TestOther : public TestFixture { TEST_CASE(duplicateExpression16); // #10569 TEST_CASE(duplicateExpression17); // #12036 TEST_CASE(duplicateExpression18); + TEST_CASE(duplicateExpression19); TEST_CASE(duplicateExpressionLoop); TEST_CASE(duplicateValueTernary); TEST_CASE(duplicateValueTernarySizeof); // #13773 @@ -7988,6 +7989,14 @@ class TestOther : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void duplicateExpression19() { + checkP("const int i = 0;\n" + "void f() {\n" + " assert(i == 0);\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + } + void duplicateExpressionLoop() { check("void f() {\n" " int a = 1;\n" From d9f5fc0dfb4d6b4875719af5e1a1b25d59104137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 2 Jan 2026 12:08:32 +0100 Subject: [PATCH 007/675] Fix #14360 (CI: Update Cppcheck Premium license) (#8078) --- .github/workflows/cppcheck-premium.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cppcheck-premium.yml b/.github/workflows/cppcheck-premium.yml index 42bca8a6ebb..5cb63ca4d5e 100644 --- a/.github/workflows/cppcheck-premium.yml +++ b/.github/workflows/cppcheck-premium.yml @@ -45,9 +45,9 @@ jobs: - name: Generate a license file run: | echo cppcheck > cppcheck.lic - echo 251231 >> cppcheck.lic + echo 261231 >> cppcheck.lic echo 80000 >> cppcheck.lic - echo 4f8dc8e7c8bb288f >> cppcheck.lic + echo 4b64673f03fb6230 >> cppcheck.lic echo path:lib >> cppcheck.lic - name: Check From fe537a7375de1ef47b2ef06c2ccc10f2134e57d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 2 Jan 2026 13:59:40 +0100 Subject: [PATCH 008/675] Fix #14359 (GUI: Duplicate warnings are not filtered out) (#8077) --- gui/resultstree.cpp | 9 +++++++++ gui/resultstree.h | 3 +++ gui/test/resultstree/testresultstree.cpp | 13 +++++++++++++ gui/test/resultstree/testresultstree.h | 1 + 4 files changed, 26 insertions(+) diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 53f4a5f9ab9..78d56929b48 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -239,6 +239,11 @@ bool ResultsTree::addErrorItem(const ErrorItem& errorItem) if (errorItem.errorPath.isEmpty()) return false; + const QString s = errorItem.toString(); + if (mErrorList.contains(s)) + return false; + mErrorList.append(s); + QSharedPointer errorItemPtr{new ErrorItem(errorItem)}; if (mReportType != ReportType::normal) { @@ -393,6 +398,8 @@ ResultItem *ResultsTree::findFileItem(const QString &name) const void ResultsTree::clear() { + mErrorList.clear(); + mModel->removeRows(0, mModel->rowCount()); if (const ProjectFile *activeProject = ProjectFile::getActiveProject()) { @@ -419,6 +426,7 @@ void ResultsTree::clear(const QString &filename) if (stripped == fileItem->text() || filename == fileItem->errorItem->file0) { mModel->removeRow(i); + mErrorList.removeAll(fileItem->errorItem->toString()); break; } } @@ -436,6 +444,7 @@ void ResultsTree::clearRecheckFile(const QString &filename) storedfile = ((!mCheckPath.isEmpty() && storedfile.startsWith(mCheckPath)) ? storedfile.mid(mCheckPath.length() + 1) : storedfile); if (actualfile == storedfile) { mModel->removeRow(i); + mErrorList.removeAll(fileItem->errorItem->toString()); break; } } diff --git a/gui/resultstree.h b/gui/resultstree.h index 9537d6d929a..87907bc5d95 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -568,6 +568,9 @@ protected slots: QStringList mHiddenMessageId; + // List of existing errors so we can avoid duplicates + QStringList mErrorList; + QItemSelectionModel* mSelectionModel{}; ThreadHandler *mThread{}; diff --git a/gui/test/resultstree/testresultstree.cpp b/gui/test/resultstree/testresultstree.cpp index be09034609f..8208ca0343e 100644 --- a/gui/test/resultstree/testresultstree.cpp +++ b/gui/test/resultstree/testresultstree.cpp @@ -134,6 +134,19 @@ void TestResultsTree::test1() const QCOMPARE(tree.isRowHidden(0,QModelIndex()), false); // Show item } +void TestResultsTree::duplicateResults() const +{ + // #14359 - filter out duplicate warnings + ResultsTree tree(nullptr); + + ErrorItem errorItem; + errorItem.summary = errorItem.message = "test"; + errorItem.severity = Severity::error; + errorItem.errorPath << QErrorPathItem(); + QVERIFY(tree.addErrorItem(errorItem)); + QVERIFY(!tree.addErrorItem(errorItem)); +} + static QErrorPathItem createErrorPathItem(QString file, int line, int column, QString info) { QErrorPathItem ret; ret.file = std::move(file); diff --git a/gui/test/resultstree/testresultstree.h b/gui/test/resultstree/testresultstree.h index 1e743581bac..108ed098eb5 100644 --- a/gui/test/resultstree/testresultstree.h +++ b/gui/test/resultstree/testresultstree.h @@ -23,6 +23,7 @@ class TestResultsTree : public QObject { private slots: void test1() const; + void duplicateResults() const; void multiLineResult() const; void resultsInSameFile() const; void testReportType() const; From 269c6367d160815738b17028eff61385258b545d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 2 Jan 2026 15:28:07 +0100 Subject: [PATCH 009/675] Fix #13877 FP constParameterReference when casting to derived class (#8041) --- lib/astutils.cpp | 3 +++ test/testother.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index d5d38bc3453..c91f41d9651 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2943,6 +2943,9 @@ static bool isExpressionChangedAt(const F& getExprTok, auto expr = getExprTok(); if (!expr && !(tok->valueType() && tok->valueType()->pointer == 0 && tok->valueType()->reference == Reference::None)) aliased = true; + if (!aliased && expr && expr->varId() && tok->isCast() && tok->valueType() && tok->valueType()->reference != Reference::None && + Token::Match(tok->astOperand2() ? tok->astOperand2() : tok->astOperand1(), "%varid%", expr->varId())) + aliased = true; if (!aliased) aliased = isAliasOf(tok, expr, &i); if (!aliased) diff --git a/test/testother.cpp b/test/testother.cpp index a54ee364366..50581a332c5 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3982,6 +3982,19 @@ class TestOther : public TestFixture { " t.s->i = 0;\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("struct B {};\n" // #13877 + "struct D : B { int i; };\n" + "void f(B& b) {\n" + " static_cast(b).i = 0;\n" + "}\n" + "void g(B& b) {\n" + " std::cin >> static_cast(b).i;\n" + "}\n" + "int h(B& b) {\n" + " return static_cast(b).i;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:9:10]: (style) Parameter 'b' can be declared as reference to const [constParameterReference]\n", errout_str()); } void constParameterCallback() { From 81966c862ba2048e75d02ef26f8acb87d1ab8a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 2 Jan 2026 17:43:56 +0100 Subject: [PATCH 010/675] refs #1059 - extract configurations for `#if x < y` and `#if x > y` (#8038) --- lib/preprocessor.cpp | 11 +++++++++++ test/testpreprocessor.cpp | 18 +++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index b10ff859ad6..93a7ce62bf1 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -415,6 +415,17 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::setstr() + '=' + cond->next->next->str(); } + if (len == 3 && cond->name && (next1->op == '<' || next1->op == '>') && next2->number) { + if (defined.find(cond->str()) == defined.end()) { + int v = strToInt(cond->next->next->str()); + if (next1->op == '<') + v -= 1; + else + v += 1; + return cond->str() + '=' + std::to_string(v); + } + } + std::set configset; for (; sameline(iftok,cond); cond = cond->next) { if (cond->op == '!') { diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 781f6b6cf35..2ab97638407 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -319,6 +319,8 @@ class TestPreprocessor : public TestFixture { TEST_CASE(getConfigs13); // #14222 TEST_CASE(getConfigs14); // #1059 TEST_CASE(getConfigs15); // #1059 + TEST_CASE(getConfigs16); // #1059 + TEST_CASE(getConfigs17); // #1059 TEST_CASE(getConfigsError); TEST_CASE(getConfigsD1); @@ -653,7 +655,7 @@ class TestPreprocessor : public TestFixture { "#else\n" " B\n" "#endif\n"; - TODO_ASSERT_EQUALS("\nLIBVER=101\n", "\n", getConfigsStr(filedata)); + ASSERT_EQUALS("\nLIBVER=101\n", getConfigsStr(filedata)); } void if_cond2() { @@ -2304,6 +2306,20 @@ class TestPreprocessor : public TestFixture { ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata)); } + void getConfigs16() { // #1059 + const char filedata[] = "#if A > 1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + + void getConfigs17() { // #1059 + const char filedata[] = "#if A < 1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + void getConfigsError() { const char filedata1[] = "#ifndef X\n" "#error \"!X\"\n" From ac3f534c9d62a171f5fc77d99fbaaebf8eba2fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 2 Jan 2026 17:44:18 +0100 Subject: [PATCH 011/675] cleaned up includes based on `include-what-you-use` (#8070) --- Makefile | 10 +++++----- cli/cmdlineparser.cpp | 1 - gui/mainwindow.cpp | 1 + gui/projectfiledialog.cpp | 2 ++ gui/resultitem.cpp | 2 ++ gui/resultstree.h | 2 -- gui/resultsview.h | 2 +- gui/test/projectfile/testprojectfile.cpp | 1 - gui/test/resultstree/testresultstree.cpp | 2 ++ lib/analyzerinfo.cpp | 1 + lib/check64bit.cpp | 1 + lib/checkclass.cpp | 1 - lib/checkmemoryleak.cpp | 2 +- lib/ctu.cpp | 1 - lib/mathlib.cpp | 1 - lib/platform.cpp | 1 + lib/preprocessor.cpp | 1 + lib/sarifreport.cpp | 5 ++++- lib/sarifreport.h | 1 - lib/symboldatabase.h | 2 +- lib/timer.cpp | 3 +-- lib/timer.h | 2 -- lib/valueflow.cpp | 3 +-- lib/valueflow.h | 3 --- lib/vf_common.cpp | 1 - lib/vfvalue.cpp | 2 +- oss-fuzz/Makefile | 8 ++++---- test/testcppcheck.cpp | 2 ++ test/testpreprocessor.cpp | 1 + test/testprocessexecutor.cpp | 1 + test/testsarifreport.cpp | 4 +++- test/testsimplifytemplate.cpp | 2 ++ test/testsimplifytypedef.cpp | 2 ++ test/testsuppressions.cpp | 1 + test/testthreadexecutor.cpp | 1 + test/testtimer.cpp | 3 +-- test/testtokenize.cpp | 2 ++ test/testunusedvar.cpp | 2 ++ tools/dmake/dmake.cpp | 1 + 39 files changed, 49 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 71b62bab7fc..02482206b9a 100644 --- a/Makefile +++ b/Makefile @@ -508,7 +508,7 @@ $(libcppdir)/checkbool.o: lib/checkbool.cpp lib/addoninfo.h lib/astutils.h lib/c $(libcppdir)/checkbufferoverrun.o: lib/checkbufferoverrun.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkbufferoverrun.h lib/checkers.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkbufferoverrun.cpp -$(libcppdir)/checkclass.o: lib/checkclass.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkclass.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h lib/xml.h +$(libcppdir)/checkclass.o: lib/checkclass.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkclass.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkclass.cpp $(libcppdir)/checkcondition.o: lib/checkcondition.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkcondition.h lib/checkers.h lib/checkother.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h @@ -583,7 +583,7 @@ $(libcppdir)/color.o: lib/color.cpp lib/color.h lib/config.h $(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkunusedfunctions.h lib/clangimport.h lib/color.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/regex.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/cppcheck.cpp -$(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h +$(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/check.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/ctu.cpp $(libcppdir)/errorlogger.o: lib/errorlogger.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h @@ -658,7 +658,7 @@ $(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h $(libcppdir)/templatesimplifier.o: lib/templatesimplifier.cpp lib/addoninfo.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/templatesimplifier.cpp -$(libcppdir)/timer.o: lib/timer.cpp lib/config.h lib/timer.h lib/utils.h +$(libcppdir)/timer.o: lib/timer.cpp lib/config.h lib/timer.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/timer.cpp $(libcppdir)/token.o: lib/token.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/astutils.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/tokenrange.h lib/utils.h lib/valueflow.h lib/vfvalue.h @@ -673,7 +673,7 @@ $(libcppdir)/utils.o: lib/utils.cpp lib/config.h lib/utils.h $(libcppdir)/vf_analyzers.o: lib/vf_analyzers.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/programmemory.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vf_analyzers.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_analyzers.cpp -$(libcppdir)/vf_common.o: lib/vf_common.cpp lib/addoninfo.h lib/astutils.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h +$(libcppdir)/vf_common.o: lib/vf_common.cpp lib/addoninfo.h lib/astutils.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_common.cpp $(libcppdir)/vf_settokenvalue.o: lib/vf_settokenvalue.cpp lib/addoninfo.h lib/astutils.h lib/calculate.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h @@ -859,7 +859,7 @@ test/testprogrammemory.o: test/testprogrammemory.cpp lib/addoninfo.h lib/check.h test/testregex.o: test/testregex.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/regex.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testregex.cpp -test/testsarifreport.o: test/testsarifreport.cpp externals/picojson/picojson.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/sarifreport.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h +test/testsarifreport.o: test/testsarifreport.cpp externals/picojson/picojson.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/json.h lib/library.h lib/mathlib.h lib/platform.h lib/sarifreport.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsarifreport.cpp test/testsettings.o: test/testsettings.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 38d0ce3e875..4e567e47d9f 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -43,7 +43,6 @@ #include #include -#include #include #include // EXIT_FAILURE #include diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 9603a3ebb97..6926183974b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -52,6 +52,7 @@ #include "threadhandler.h" #include "threadresult.h" #include "translationhandler.h" +#include "utils.h" #include "ui_mainwindow.h" diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 9a85124e4dc..bfa351722ec 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -23,10 +23,12 @@ #include "importproject.h" #include "library.h" #include "newsuppressiondialog.h" +#include "path.h" #include "platform.h" #include "platforms.h" #include "projectfile.h" #include "settings.h" +#include "utils.h" #include "ui_projectfile.h" diff --git a/gui/resultitem.cpp b/gui/resultitem.cpp index b68830b90ba..4215115be07 100644 --- a/gui/resultitem.cpp +++ b/gui/resultitem.cpp @@ -18,6 +18,8 @@ #include "resultitem.h" +#include + ResultItem::ResultItem(QSharedPointer errorItem, Type type, int errorPathIndex) : errorItem(std::move(errorItem)), mType(type), mErrorPathIndex(errorPathIndex) {} diff --git a/gui/resultstree.h b/gui/resultstree.h index 87907bc5d95..efa759cd6d1 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -36,13 +36,11 @@ class ApplicationList; class Report; class ErrorItem; -class ErrorLine; class QModelIndex; class QWidget; class QItemSelectionModel; class ThreadHandler; class QSettings; -class QStandardItem; class QStandardItemModel; enum class Severity : std::uint8_t; diff --git a/gui/resultsview.h b/gui/resultsview.h index 7aef3c6d5c2..770f9c0c3fa 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -35,11 +35,11 @@ class ErrorItem; class Settings; class ApplicationList; class ThreadHandler; -class QModelIndex; class QPrinter; class QSettings; class CheckStatistics; class QPoint; +class ResultItem; enum class ReportType : std::uint8_t; namespace Ui { class ResultsView; diff --git a/gui/test/projectfile/testprojectfile.cpp b/gui/test/projectfile/testprojectfile.cpp index e20b2ab38e2..988d62e8bce 100644 --- a/gui/test/projectfile/testprojectfile.cpp +++ b/gui/test/projectfile/testprojectfile.cpp @@ -18,7 +18,6 @@ #include "testprojectfile.h" -#include "importproject.h" #include "library.h" #include "platform.h" #include "projectfile.h" diff --git a/gui/test/resultstree/testresultstree.cpp b/gui/test/resultstree/testresultstree.cpp index 8208ca0343e..0873314a41c 100644 --- a/gui/test/resultstree/testresultstree.cpp +++ b/gui/test/resultstree/testresultstree.cpp @@ -23,6 +23,7 @@ // headers that declare mocked functions/variables #include "applicationlist.h" #include "common.h" +#include "filesettings.h" #include "projectfile.h" #include "threadhandler.h" #include "threadresult.h" @@ -33,6 +34,7 @@ #include "errorlogger.h" #include "errortypes.h" #include "report.h" +#include "resultitem.h" #include "showtypes.h" #include "suppressions.h" #include "xmlreport.h" diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index 54dbb4496af..9477f2e290d 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "xml.h" diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index aa8a9bcb18a..a106b0afe5f 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -23,6 +23,7 @@ #include "check64bit.h" #include "errortypes.h" +#include "platform.h" #include "settings.h" #include "symboldatabase.h" #include "token.h" diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 34a734fecaa..2949d3c57a7 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -31,7 +31,6 @@ #include "tokenize.h" #include "tokenlist.h" #include "utils.h" -#include "valueflow.h" #include #include diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 6de1ede2bf9..bd9d1bc892f 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -23,7 +23,6 @@ #include "errorlogger.h" #include "errortypes.h" #include "library.h" -#include "mathlib.h" #include "platform.h" #include "settings.h" #include "symboldatabase.h" @@ -31,6 +30,7 @@ #include "tokenize.h" #include +#include #include #include diff --git a/lib/ctu.cpp b/lib/ctu.cpp index aadba39d3c7..158c8c1e046 100644 --- a/lib/ctu.cpp +++ b/lib/ctu.cpp @@ -22,7 +22,6 @@ #include "astutils.h" #include "errortypes.h" -#include "settings.h" #include "symboldatabase.h" #include "token.h" #include "tokenize.h" diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index c23182a5a63..f065d63a935 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/platform.cpp b/lib/platform.cpp index 6a016254589..833c012ab8e 100644 --- a/lib/platform.cpp +++ b/lib/platform.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "xml.h" diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 93a7ce62bf1..c395bf07e8b 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/lib/sarifreport.cpp b/lib/sarifreport.cpp index fc4ff90df72..ce142430f54 100644 --- a/lib/sarifreport.cpp +++ b/lib/sarifreport.cpp @@ -17,13 +17,16 @@ */ #include "sarifreport.h" + +#include "cppcheck.h" #include "errorlogger.h" #include "errortypes.h" #include "settings.h" -#include "cppcheck.h" +#include #include #include +#include static const char sarifVersion[] = "2.1.0"; static const char sarifSchema[] = "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json"; diff --git a/lib/sarifreport.h b/lib/sarifreport.h index 26953703a51..90667322b2f 100644 --- a/lib/sarifreport.h +++ b/lib/sarifreport.h @@ -21,7 +21,6 @@ #include "config.h" #include "errorlogger.h" -#include "errortypes.h" #include #include diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index db51328c5be..954b31cc05b 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -40,7 +41,6 @@ #include #include -class Platform; class Function; class Scope; class Settings; diff --git a/lib/timer.cpp b/lib/timer.cpp index 5d64258be35..9e2dd901bea 100644 --- a/lib/timer.cpp +++ b/lib/timer.cpp @@ -18,9 +18,8 @@ #include "timer.h" -#include "utils.h" - #include +#include #include #include #include diff --git a/lib/timer.h b/lib/timer.h index 991b334f3aa..f50b3ca3485 100644 --- a/lib/timer.h +++ b/lib/timer.h @@ -24,8 +24,6 @@ #include #include -#include -#include #include #include #include diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index e649786fb8f..1f5bffc266d 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -112,8 +112,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -121,7 +121,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/valueflow.h b/lib/valueflow.h index 6fe4d052fdf..a813ff8d286 100644 --- a/lib/valueflow.h +++ b/lib/valueflow.h @@ -25,8 +25,6 @@ #include "errortypes.h" #include "mathlib.h" -#include -#include #include #include #include @@ -39,7 +37,6 @@ class SymbolDatabase; class TimerResultsIntf; class Token; class TokenList; -class ValueType; class Variable; class Scope; diff --git a/lib/vf_common.cpp b/lib/vf_common.cpp index 56a6b364c44..333f850d07d 100644 --- a/lib/vf_common.cpp +++ b/lib/vf_common.cpp @@ -26,7 +26,6 @@ #include "standards.h" #include "symboldatabase.h" #include "token.h" -#include "valueflow.h" #include "vfvalue.h" #include "vf_settokenvalue.h" diff --git a/lib/vfvalue.cpp b/lib/vfvalue.cpp index 2d1a82b32c3..4ec1c742ab3 100644 --- a/lib/vfvalue.cpp +++ b/lib/vfvalue.cpp @@ -18,9 +18,9 @@ #include "vfvalue.h" -#include "errortypes.h" #include "mathlib.h" #include "token.h" +#include "utils.h" #include #include diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index f949da24e0f..02d2e7fbde2 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -188,7 +188,7 @@ $(libcppdir)/checkbool.o: ../lib/checkbool.cpp ../lib/addoninfo.h ../lib/astutil $(libcppdir)/checkbufferoverrun.o: ../lib/checkbufferoverrun.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkbufferoverrun.h ../lib/checkers.h ../lib/config.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/vfvalue.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkbufferoverrun.cpp -$(libcppdir)/checkclass.o: ../lib/checkclass.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkclass.h ../lib/checkers.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/vfvalue.h ../lib/xml.h +$(libcppdir)/checkclass.o: ../lib/checkclass.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkclass.h ../lib/checkers.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkclass.cpp $(libcppdir)/checkcondition.o: ../lib/checkcondition.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkcondition.h ../lib/checkers.h ../lib/checkother.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h @@ -263,7 +263,7 @@ $(libcppdir)/color.o: ../lib/color.cpp ../lib/color.h ../lib/config.h $(libcppdir)/cppcheck.o: ../lib/cppcheck.cpp ../externals/picojson/picojson.h ../externals/simplecpp/simplecpp.h ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/analyzerinfo.h ../lib/check.h ../lib/checkers.h ../lib/checkunusedfunctions.h ../lib/clangimport.h ../lib/color.h ../lib/config.h ../lib/cppcheck.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/filesettings.h ../lib/json.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/preprocessor.h ../lib/regex.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/timer.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/version.h ../lib/vfvalue.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/cppcheck.cpp -$(libcppdir)/ctu.o: ../lib/ctu.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkers.h ../lib/config.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h +$(libcppdir)/ctu.o: ../lib/ctu.cpp ../externals/tinyxml2/tinyxml2.h ../lib/astutils.h ../lib/check.h ../lib/config.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/ctu.cpp $(libcppdir)/errorlogger.o: ../lib/errorlogger.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/check.h ../lib/checkers.h ../lib/color.h ../lib/config.h ../lib/cppcheck.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/standards.h ../lib/suppressions.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h @@ -338,7 +338,7 @@ $(libcppdir)/suppressions.o: ../lib/suppressions.cpp ../externals/tinyxml2/tinyx $(libcppdir)/templatesimplifier.o: ../lib/templatesimplifier.cpp ../lib/addoninfo.h ../lib/checkers.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/standards.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/templatesimplifier.cpp -$(libcppdir)/timer.o: ../lib/timer.cpp ../lib/config.h ../lib/timer.h ../lib/utils.h +$(libcppdir)/timer.o: ../lib/timer.cpp ../lib/config.h ../lib/timer.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/timer.cpp $(libcppdir)/token.o: ../lib/token.cpp ../externals/simplecpp/simplecpp.h ../lib/addoninfo.h ../lib/astutils.h ../lib/checkers.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/tokenrange.h ../lib/utils.h ../lib/valueflow.h ../lib/vfvalue.h @@ -353,7 +353,7 @@ $(libcppdir)/utils.o: ../lib/utils.cpp ../lib/config.h ../lib/utils.h $(libcppdir)/vf_analyzers.o: ../lib/vf_analyzers.cpp ../lib/addoninfo.h ../lib/analyzer.h ../lib/astutils.h ../lib/calculate.h ../lib/checkers.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/programmemory.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/valueflow.h ../lib/valueptr.h ../lib/vf_analyzers.h ../lib/vf_common.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_analyzers.cpp -$(libcppdir)/vf_common.o: ../lib/vf_common.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/checkers.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/valueflow.h ../lib/vf_common.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h +$(libcppdir)/vf_common.o: ../lib/vf_common.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/checkers.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/vf_common.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_common.cpp $(libcppdir)/vf_settokenvalue.o: ../lib/vf_settokenvalue.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/calculate.h ../lib/checkers.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/valueflow.h ../lib/vf_common.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index ac292a1a057..35b25175023 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -20,6 +20,7 @@ #include "color.h" #include "cppcheck.h" #include "errorlogger.h" +#include "errortypes.h" #include "filesettings.h" #include "fixture.h" #include "helpers.h" @@ -31,6 +32,7 @@ #include "suppressions.h" #include +#include #include #include #include diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 2ab97638407..108dc609c6f 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -21,6 +21,7 @@ // the code for a known configuration, it generates the code for each configuration. #include "errortypes.h" +#include "library.h" #include "path.h" #include "platform.h" #include "preprocessor.h" diff --git a/test/testprocessexecutor.cpp b/test/testprocessexecutor.cpp index 5e5bc3da532..1866234ac78 100644 --- a/test/testprocessexecutor.cpp +++ b/test/testprocessexecutor.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include "config.h" #include "fixture.h" #ifdef HAS_THREADING_MODEL_FORK diff --git a/test/testsarifreport.cpp b/test/testsarifreport.cpp index 9f00612a932..b4d3056a762 100644 --- a/test/testsarifreport.cpp +++ b/test/testsarifreport.cpp @@ -20,12 +20,14 @@ #include "errorlogger.h" #include "errortypes.h" #include "fixture.h" -#include "helpers.h" #include +#include #include #include +#include "json.h" + class TestSarifReport : public TestFixture { public: diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 963ba058b2b..3a2299f51de 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -32,6 +32,8 @@ #include #include +class ErrorLogger; + class TestSimplifyTemplate : public TestFixture { public: TestSimplifyTemplate() : TestFixture("TestSimplifyTemplate") {} diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index ed7fbe93a38..a24131dd667 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -29,6 +29,8 @@ #include #include +class ErrorLogger; + class TestSimplifyTypedef : public TestFixture { public: TestSimplifyTypedef() : TestFixture("TestSimplifyTypedef") {} diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 77032c50c69..1da06184994 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include "config.h" #include "cppcheck.h" #include "cppcheckexecutor.h" #include "errorlogger.h" diff --git a/test/testthreadexecutor.cpp b/test/testthreadexecutor.cpp index 6b387e0dea1..106a5bc9078 100644 --- a/test/testthreadexecutor.cpp +++ b/test/testthreadexecutor.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include "config.h" #include "fixture.h" #ifdef HAS_THREADING_MODEL_THREAD diff --git a/test/testtimer.cpp b/test/testtimer.cpp index c9bc570863b..75fead13d2d 100644 --- a/test/testtimer.cpp +++ b/test/testtimer.cpp @@ -19,8 +19,7 @@ #include "fixture.h" #include "timer.h" -#include -#include +#include class TestTimer : public TestFixture { public: diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 02b4b64a8ed..bc879547e0a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -39,6 +39,8 @@ #include +class ErrorLogger; + class TestTokenizer : public TestFixture { public: TestTokenizer() : TestFixture("TestTokenizer") {} diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index ef3bba226f4..c1d2b482ae5 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -27,6 +27,8 @@ #include #include +#include + class TestUnusedVar : public TestFixture { public: TestUnusedVar() : TestFixture("TestUnusedVar") {} diff --git a/tools/dmake/dmake.cpp b/tools/dmake/dmake.cpp index 6b91c7cbe31..100e32b6b5b 100644 --- a/tools/dmake/dmake.cpp +++ b/tools/dmake/dmake.cpp @@ -33,6 +33,7 @@ #include "../cli/filelister.h" #include "../lib/filesettings.h" +#include "../lib/path.h" #include "../lib/pathmatch.h" #include "../lib/utils.h" From c1d92760e5bbe048564697366876bbd55d71e033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 2 Jan 2026 17:44:32 +0100 Subject: [PATCH 012/675] testrunner: create more settings as immutable (#8067) --- test/testbufferoverrun.cpp | 5 +- test/testpreprocessor.cpp | 136 ++++++++++++++++++++----------------- test/testsuppressions.cpp | 12 ++-- 3 files changed, 84 insertions(+), 69 deletions(-) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index e53f2a323b2..ce7b9428d1f 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -4283,8 +4283,9 @@ class TestBufferOverrun : public TestFixture { " \n" " \n" ""; - /*const*/ Settings settings = settingsBuilder().libraryxml(xmldata).severity(Severity::warning).build(); - settings.platform.sizeof_wchar_t = 4; + // use a platform which has wchar_t with a sizeof 4 + const Settings settings = settingsBuilder().libraryxml(xmldata).severity(Severity::warning).platform(Platform::Unix32).build(); + ASSERT_EQUALS(4, settings.platform.sizeof_wchar_t); check("void f() {\n" " char c[10];\n" diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 108dc609c6f..e97b49196cb 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -1992,9 +1992,9 @@ class TestPreprocessor : public TestFixture { } void inline_suppressions() { - /*const*/ Settings settings; - settings.inlineSuppressions = true; - settings.checks.enable(Checks::missingInclude); + const auto settings = dinit(Settings, + $.inlineSuppressions = true, + $.checks.enable (Checks::missingInclude)); const char code[] = "// cppcheck-suppress missingInclude\n" "#include \"missing.h\"\n" @@ -2447,10 +2447,11 @@ class TestPreprocessor : public TestFixture { // test for existing local include void testMissingInclude() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); ScopedFile header("header.h", ""); @@ -2463,10 +2464,11 @@ class TestPreprocessor : public TestFixture { // test for missing local include void testMissingInclude2() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); const char code[] = "#include \"header.h\""; @@ -2477,10 +2479,11 @@ class TestPreprocessor : public TestFixture { // test for missing local include - no include path given void testMissingInclude3() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); ScopedFile header("header.h", "", "inc"); @@ -2493,11 +2496,12 @@ class TestPreprocessor : public TestFixture { // test for existing local include - include path provided void testMissingInclude4() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.includePaths.emplace_back("inc"); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.includePaths.emplace_back ("inc"), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); ScopedFile header("header.h", "", "inc"); @@ -2510,11 +2514,12 @@ class TestPreprocessor : public TestFixture { // test for existing local include - absolute path void testMissingInclude5() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.includePaths.emplace_back("inc"); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.includePaths.emplace_back ("inc"), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); ScopedFile header("header.h", "", Path::getCurrentPath()); @@ -2527,10 +2532,11 @@ class TestPreprocessor : public TestFixture { // test for missing local include - absolute path void testMissingInclude6() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); const std::string header = Path::join(Path::getCurrentPath(), "header.h"); @@ -2543,10 +2549,11 @@ class TestPreprocessor : public TestFixture { // test for missing system include - system includes are not searched for in relative path void testMissingSystemInclude() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); ScopedFile header("header.h", ""); @@ -2559,10 +2566,11 @@ class TestPreprocessor : public TestFixture { // test for missing system include void testMissingSystemInclude2() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); const char code[] = "#include "; @@ -2573,28 +2581,30 @@ class TestPreprocessor : public TestFixture { // test for existing system include in system include path void testMissingSystemInclude3() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.templateFormat = "simple", // has no effect + $.includePaths.emplace_back ("system") + ); setTemplateFormat("simple"); - settings.includePaths.emplace_back("system"); ScopedFile header("header.h", "", "system"); const char code[] = "#include "; - (void)getcodeforcfg(settings0, *this, code, "", "test.c"); + (void)getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("", errout_str()); } // test for existing system include - absolute path void testMissingSystemInclude4() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.includePaths.emplace_back("inc"); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.includePaths.emplace_back ("inc"); + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); ScopedFile header("header.h", "", Path::getCurrentPath()); @@ -2607,10 +2617,11 @@ class TestPreprocessor : public TestFixture { // test for missing system include - absolute path void testMissingSystemInclude5() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); const std::string header = Path::join(Path::getCurrentPath(), "header.h"); @@ -2623,10 +2634,12 @@ class TestPreprocessor : public TestFixture { // test for missing local and system include void testMissingIncludeMixed() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); ScopedFile header("header.h", ""); @@ -2644,11 +2657,12 @@ class TestPreprocessor : public TestFixture { } void testMissingIncludeCheckConfig() { - /*const*/ Settings settings; - settings.clearIncludeCache = true; - settings.checks.enable(Checks::missingInclude); - settings.includePaths.emplace_back("system"); - settings.templateFormat = "simple"; // has no effect + const auto settings = dinit(Settings, + $.clearIncludeCache = true, + $.checks.enable (Checks::missingInclude), + $.includePaths.emplace_back ("system"); + $.templateFormat = "simple" // has no effect + ); setTemplateFormat("simple"); ScopedFile header("header.h", ""); diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 1da06184994..1f572bd2eb2 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -315,12 +315,12 @@ class TestSuppressions : public TestFixture { fileSettings.emplace_back("test.cpp", Standards::Language::CPP, strlen(code)); } - /*const*/ auto settings = dinit(Settings, - $.jobs = 2, - $.quiet = true, - $.inlineSuppressions = true); - settings.severity.enable(Severity::information); - settings.templateFormat = templateFormat; + const auto settings = dinit(Settings, + $.jobs = 2, + $.quiet = true, + $.inlineSuppressions = true, + $.severity.enable (Severity::information), + $.templateFormat = templateFormat); Suppressions supprs; if (!suppression.empty()) { From 670e4a024e2416483cc7e1a04bada4f7c997d5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 2 Jan 2026 17:44:51 +0100 Subject: [PATCH 013/675] TemplateSimplifier: removed need for test class friend declaration / cleaned up member access (#8068) --- lib/templatesimplifier.h | 10 +++++++--- test/testsimplifytemplate.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/templatesimplifier.h b/lib/templatesimplifier.h index 5ac15875dad..b5285071841 100644 --- a/lib/templatesimplifier.h +++ b/lib/templatesimplifier.h @@ -45,8 +45,6 @@ struct newInstantiation; /** @brief Simplify templates from the preprocessed and partially simplified code. */ class CPPCHECKLIB TemplateSimplifier { - friend class TestSimplifyTemplate; - public: explicit TemplateSimplifier(Tokenizer &tokenizer); @@ -267,6 +265,7 @@ class CPPCHECKLIB TemplateSimplifier { static Token *findTemplateDeclarationEnd(Token *tok); static const Token *findTemplateDeclarationEnd(const Token *tok); +protected: /** * Match template declaration/instantiation * @param instance template instantiation @@ -277,6 +276,7 @@ class CPPCHECKLIB TemplateSimplifier { */ static bool instantiateMatch(const Token *instance, std::size_t numberOfArguments, bool variadic, const char patternAfter[]); +public: // TODO: only needs to be public for tests /** * Match template declaration/instantiation * @param tok The ">" token e.g. before "class" @@ -285,6 +285,7 @@ class CPPCHECKLIB TemplateSimplifier { */ int getTemplateNamePosition(const Token *tok); +private: /** * Get class template name position * @param tok The ">" token e.g. before "class" @@ -309,6 +310,7 @@ class CPPCHECKLIB TemplateSimplifier { * */ static bool getTemplateNamePositionTemplateVariable(const Token *tok, int &namepos); +public: /** * Simplify templates * @param maxtime time when the simplification should be stopped @@ -324,6 +326,7 @@ class CPPCHECKLIB TemplateSimplifier { */ static bool simplifyNumericCalculations(Token *tok, bool isTemplate = true); +private: /** * Simplify constant calculations such as "1+2" => "3". * This also performs simple cleanup of parentheses etc. @@ -338,7 +341,6 @@ class CPPCHECKLIB TemplateSimplifier { */ void simplifyTemplateArgs(Token *start, const Token *end, std::vector* newInst = nullptr); -private: /** * Get template declarations * @return true if code has templates. @@ -445,6 +447,7 @@ class CPPCHECKLIB TemplateSimplifier { const std::list &typeStringsUsedInTemplateInstantiation, const std::string &newName); +protected: /** * @brief TemplateParametersInDeclaration * @param tok template < typename T, typename S > @@ -456,6 +459,7 @@ class CPPCHECKLIB TemplateSimplifier { const Token * tok, std::vector & typeParametersInDeclaration); +private: /** * Remove a specific "template < ..." template class/function */ diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 3a2299f51de..494127fbee8 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -321,6 +321,11 @@ class TestSimplifyTemplate : public TestFixture { TEST_CASE(dumpTemplateArgFrom); } + class TemplateSimplifierTest : public TemplateSimplifier + { + friend class TestSimplifyTemplate; + }; + class TokenizerTest : public Tokenizer { friend class TestSimplifyTemplate; @@ -5649,7 +5654,7 @@ class TestSimplifyTemplate : public TestFixture { tokenizer.splitTemplateRightAngleBrackets(false); std::vector typeParametersInDeclaration; - TemplateSimplifier::getTemplateParametersInDeclaration(tokenizer.tokens()->tokAt(2), typeParametersInDeclaration); + TemplateSimplifierTest::getTemplateParametersInDeclaration(tokenizer.tokens()->tokAt(2), typeParametersInDeclaration); if (params.size() != typeParametersInDeclaration.size()) return false; @@ -5949,7 +5954,7 @@ class TestSimplifyTemplate : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); - return (TemplateSimplifier::instantiateMatch)(tokenizer.tokens(), numberOfArguments, false, patternAfter); + return (TemplateSimplifierTest::instantiateMatch)(tokenizer.tokens(), numberOfArguments, false, patternAfter); } void instantiateMatchTest() { From b933258e48dd06aaac2c4fc90138f9ccc085dca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Fri, 2 Jan 2026 18:32:25 +0100 Subject: [PATCH 014/675] Fix #14125: false positive: unusedVariable with trailing [[maybe_unused]] attribute (#8029) --- lib/tokenize.cpp | 26 ++++++++++++++++++-------- test/testtokenize.cpp | 18 ++++++++++++++++-- test/testunusedvar.cpp | 6 ++++++ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 952ba4b6c00..7998c588f4a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9607,17 +9607,27 @@ void Tokenizer::simplifyCPPAttribute() if (!head) syntaxError(tok); - while (Token::Match(head->next(), "%name%|*|&|&&|const|static|inline|volatile")) - head = head->next(); - if (Token::Match(head, "%name%") && !Token::Match(head, "auto [")) - head->isAttributeMaybeUnused(true); - else if (Token::Match(tok->previous(), "%name%") && Token::Match(tok->link(), "] [;={]")) { - tok->previous()->isAttributeMaybeUnused(true); + if (Token::simpleMatch(head, ";")) { + Token *backTok = tok; + while (Token::Match(backTok, "]|[|)")) { + if (Token::Match(backTok, "]|)")) + backTok = backTok->link(); + backTok = backTok->previous(); + } + if (Token::Match(backTok, "%name%")) { + backTok->isAttributeMaybeUnused(true); + } } else { - if (Token::simpleMatch(head->next(), "[")) { + while (Token::Match(head->next(), "%name%|::|*|&|&&")) + head = head->next(); + if (Token::Match(head, "%name%") && !Token::Match(head, "auto [")) + head->isAttributeMaybeUnused(true); + else if (Token::Match(tok->previous(), "%name%") && Token::Match(tok->link(), "] [;={]")) { + tok->previous()->isAttributeMaybeUnused(true); + } else if (Token::simpleMatch(head->next(), "[")) { head = head->next(); const Token *end = head->link(); - for (head = head->next(); end && head != end; head = head->next()) { + for (head = head->next(); head != end; head = head->next()) { if (Token::Match(head, "%name%")) { head->isAttributeMaybeUnused(true); } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index bc879547e0a..70b78a44250 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -278,7 +278,8 @@ class TestTokenizer : public TestFixture { TEST_CASE(functionAttributeListAfter); TEST_CASE(functionAttributeListAfter2); TEST_CASE(cppMaybeUnusedBefore); - TEST_CASE(cppMaybeUnusedAfter); + TEST_CASE(cppMaybeUnusedAfter1); + TEST_CASE(cppMaybeUnusedAfter2); TEST_CASE(cppMaybeUnusedStructuredBinding); TEST_CASE(splitTemplateRightAngleBrackets); @@ -4260,7 +4261,7 @@ class TestTokenizer : public TestFixture { ASSERT(var && var->isAttributeMaybeUnused()); } - void cppMaybeUnusedAfter() { + void cppMaybeUnusedAfter1() { const char code[] = "int var [[maybe_unused]] {};"; const char expected[] = "int var { } ;"; @@ -4273,6 +4274,19 @@ class TestTokenizer : public TestFixture { ASSERT(var && var->isAttributeMaybeUnused()); } + void cppMaybeUnusedAfter2() { + const char code[] = "std::string var [[maybe_unused]];"; + const char expected[] = "std :: string var ;"; + + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); + + ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); + + const Token *var = Token::findsimplematch(tokenizer.tokens(), "var"); + ASSERT(var && var->isAttributeMaybeUnused()); + } + void cppMaybeUnusedStructuredBinding() { const char code[] = "[[maybe_unused]] auto [var1, var2] = f();"; const char expected[] = "auto [ var1 , var2 ] = f ( ) ;"; diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index c1d2b482ae5..741f9b70b24 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -6534,6 +6534,12 @@ class TestUnusedVar : public TestFixture { " [[maybe_unused]] char b[1][2];\n" "}"); ASSERT_EQUALS("", errout_str()); + + functionVariableUsage("int main() {\n" + " std::string a [[maybe_unused]];\n" + " f();\n" + "}"); + ASSERT_EQUALS("", errout_str()); } void localvarrvalue() { // ticket #13977 From 46c8934377363c48c8a16ab902d69c2753f94459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 3 Jan 2026 10:28:10 +0100 Subject: [PATCH 015/675] fixed #14365 - updated pylint to 4.0.x (#8084) --- .github/workflows/scriptcheck.yml | 2 +- .pylintrc | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/scriptcheck.yml b/.github/workflows/scriptcheck.yml index 66e54ddff98..844b1d5c2f3 100644 --- a/.github/workflows/scriptcheck.yml +++ b/.github/workflows/scriptcheck.yml @@ -87,7 +87,7 @@ jobs: python -m pip install pip --upgrade python -m pip install natsort python -m pip install pexpect - python -m pip install 'pylint<=3.3.0' + python -m pip install 'pylint<4.1.0' python -m pip install unittest2 python -m pip install pytest python -m pip install pytest-xdist diff --git a/.pylintrc b/.pylintrc index 9b14fa2d00e..0ca3480c06f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -63,4 +63,3 @@ reports=no ignored-classes=SQLObject,_socketobject [MASTER] init-hook='import sys; sys.path.append("./addons")' -suggestion-mode=yes From a30d71874db1980f8cffb0fb0c2eccb9e725301f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 4 Jan 2026 10:48:02 +0100 Subject: [PATCH 016/675] Partial fix for #12046 FN: containerOutOfBounds (temporary string passed to subfunction) (#8083) Co-authored-by: chrchr-github --- lib/valueflow.cpp | 6 ++++-- test/teststl.cpp | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 1f5bffc266d..023d2ebde31 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -6706,13 +6706,15 @@ static void valueFlowContainerSize(const TokenList& tokenlist, for (const ValueFlow::Value& value : values) setTokenValue(tok, value, settings); } - else if (Token::Match(tok->previous(), ",|( {")) { + else if (Token::Match(tok->previous(), ",|( {|%str%")) { int nArg{}; if (const Token* funcTok = getTokenArgumentFunction(tok, nArg)) { if (const Function* func = funcTok->function()) { if (const Variable* var = func->getArgumentVar(nArg)) { if (var->valueType() && var->valueType()->container && var->valueType()->container->size_templateArgNo < 0) { - std::vector values = getInitListSize(tok, var->valueType(), settings, true); + auto values = tok->tokType() == Token::Type::eString + ? std::vector{makeContainerSizeValue(Token::getStrLength(tok))} + : getInitListSize(tok, var->valueType(), settings, true); ValueFlow::Value tokValue; tokValue.valueType = ValueFlow::Value::ValueType::TOK; tokValue.tokvalue = tok; diff --git a/test/teststl.cpp b/test/teststl.cpp index ec6f46148a8..2c4669dbeca 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -967,6 +967,11 @@ class TestStl : public TestFixture { "}\n"); ASSERT_EQUALS("[test.cpp:2:17]: error: Out of bounds access in expression 'v[0]' because 'v' is empty. [containerOutOfBounds]\n", errout_str()); + + checkNormal("bool f(const std::string_view s) { return s[500] == 'x'; }\n" // #12046 + "bool g() { return f(\" \"); }\n"); + ASSERT_EQUALS("[test.cpp:1:44]: error: Out of bounds access in 's[500]', if 's' size is 1 and '500' is 500 [containerOutOfBounds]\n", + errout_str()); } void outOfBoundsSymbolic() From 0539dee38babab6de0bb7fc74f8c0017cb5cee07 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 4 Jan 2026 14:14:00 +0100 Subject: [PATCH 017/675] Fix #13702, #13713 fuzzing crashes (#8071) Co-authored-by: chrchr-github --- lib/symboldatabase.cpp | 5 ++++- lib/tokenize.cpp | 2 ++ .../crash-04f8bc02d0683e12579485090f4a2cbc55d3c955 | 1 + .../crash-3de394576af6f9f7ca95bdd282075d06f980252f | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/cli/fuzz-crash/crash-04f8bc02d0683e12579485090f4a2cbc55d3c955 create mode 100644 test/cli/fuzz-crash/crash-3de394576af6f9f7ca95bdd282075d06f980252f diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index d4107884642..b6528d9a9e6 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1508,7 +1508,10 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars() continue; } if (tok->str() == "using") { - tok = Token::findsimplematch(tok, ";"); + Token* usingEnd = Token::findsimplematch(tok, ";"); + if (!usingEnd) + mTokenizer.syntaxError(tok); + tok = usingEnd; continue; } } diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7998c588f4a..086566fdac1 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8940,6 +8940,8 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::Match(tok, ": [)]=]")) syntaxError(tok); + if (Token::simpleMatch(tok, ", :")) + syntaxError(tok); if (Token::Match(tok, "typedef [,;:]")) syntaxError(tok); if (Token::Match(tok, "!|~ %comp%") && diff --git a/test/cli/fuzz-crash/crash-04f8bc02d0683e12579485090f4a2cbc55d3c955 b/test/cli/fuzz-crash/crash-04f8bc02d0683e12579485090f4a2cbc55d3c955 new file mode 100644 index 00000000000..1e6a05d0ae6 --- /dev/null +++ b/test/cli/fuzz-crash/crash-04f8bc02d0683e12579485090f4a2cbc55d3c955 @@ -0,0 +1 @@ +b f(){using e} \ No newline at end of file diff --git a/test/cli/fuzz-crash/crash-3de394576af6f9f7ca95bdd282075d06f980252f b/test/cli/fuzz-crash/crash-3de394576af6f9f7ca95bdd282075d06f980252f new file mode 100644 index 00000000000..7122cb87302 --- /dev/null +++ b/test/cli/fuzz-crash/crash-3de394576af6f9f7ca95bdd282075d06f980252f @@ -0,0 +1 @@ +t o(){for(u*e,:c)t c=e;} \ No newline at end of file From be71c2ef75273c43716bf5efb4a5c7bde900c047 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 08:26:49 +0100 Subject: [PATCH 018/675] Fix #13694, #13704, #13708, #14356 fuzzing crashes (#8076) Co-authored-by: chrchr-github --- lib/templatesimplifier.cpp | 2 ++ lib/tokenize.cpp | 4 ++++ lib/tokenlist.cpp | 2 ++ .../crash-9eb2c9e545b361a17d74ccd4e8c933ca65542b12 | 1 + .../crash-a03d001b1336e191debffcde652ce5fb63d0a7d6 | 1 + .../crash-c36b9a5f7fce91031cb578ef591f90d48d95a7f4 | 1 + .../crash-24c217c96d177b8dff4028bce639756d6a8c6088 | 1 + test/cli/fuzz_test.py | 8 ++++---- 8 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 test/cli/fuzz-crash/crash-9eb2c9e545b361a17d74ccd4e8c933ca65542b12 create mode 100644 test/cli/fuzz-crash/crash-a03d001b1336e191debffcde652ce5fb63d0a7d6 create mode 100644 test/cli/fuzz-crash/crash-c36b9a5f7fce91031cb578ef591f90d48d95a7f4 create mode 100644 test/cli/fuzz-crash_c/crash-24c217c96d177b8dff4028bce639756d6a8c6088 diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 1f90593560f..1291993990d 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -690,6 +690,8 @@ bool TemplateSimplifier::getTemplateDeclarations() else if (Token::Match(tok2, "{|=|;")) { const int namepos = getTemplateNamePosition(parmEnd); if (namepos > 0) { + if (!tok->scopeInfo()) + syntaxError(tok); TokenAndName decl(tok, tok->scopeInfo()->name, parmEnd->tokAt(namepos), parmEnd); if (decl.isForwardDeclaration()) { // Declaration => add to mTemplateForwardDeclarations diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 086566fdac1..cc98703011a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8936,6 +8936,8 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::Match(tok, "& %comp%|&&|%oror%|&|%or%") && tok->strAt(1) != ">") syntaxError(tok); + if (Token::Match(tok, "%comp%|&&|%oror%|&|%or% }") && tok->str() != ">") + syntaxError(tok); if (Token::Match(tok, "^ %op%") && !Token::Match(tok->next(), "[>*+-!~]")) syntaxError(tok); if (Token::Match(tok, ": [)]=]")) @@ -8944,6 +8946,8 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::Match(tok, "typedef [,;:]")) syntaxError(tok); + if (Token::Match(tok, "? %assign%")) + syntaxError(tok); if (Token::Match(tok, "!|~ %comp%") && !(cpp && tok->strAt(1) == ">" && Token::simpleMatch(tok->tokAt(-1), "operator"))) syntaxError(tok); diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 2ed39b82f43..1e476a14ec5 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -295,6 +295,8 @@ void TokenList::insertTokens(Token *dest, const Token *src, nonneg int n) std::stack link; while (n > 0) { + if (!src) + throw InternalError(dest, std::string(__func__) + ": invalid source range", InternalError::INTERNAL); dest->insertToken(src->str(), src->originalName()); dest = dest->next(); diff --git a/test/cli/fuzz-crash/crash-9eb2c9e545b361a17d74ccd4e8c933ca65542b12 b/test/cli/fuzz-crash/crash-9eb2c9e545b361a17d74ccd4e8c933ca65542b12 new file mode 100644 index 00000000000..8d7829b6343 --- /dev/null +++ b/test/cli/fuzz-crash/crash-9eb2c9e545b361a17d74ccd4e8c933ca65542b12 @@ -0,0 +1 @@ +{template<>i}template<>fact2(){fact2<3>()} \ No newline at end of file diff --git a/test/cli/fuzz-crash/crash-a03d001b1336e191debffcde652ce5fb63d0a7d6 b/test/cli/fuzz-crash/crash-a03d001b1336e191debffcde652ce5fb63d0a7d6 new file mode 100644 index 00000000000..0a3ef8a3bb2 --- /dev/null +++ b/test/cli/fuzz-crash/crash-a03d001b1336e191debffcde652ce5fb63d0a7d6 @@ -0,0 +1 @@ +(c[?=3:4])p \ No newline at end of file diff --git a/test/cli/fuzz-crash/crash-c36b9a5f7fce91031cb578ef591f90d48d95a7f4 b/test/cli/fuzz-crash/crash-c36b9a5f7fce91031cb578ef591f90d48d95a7f4 new file mode 100644 index 00000000000..094721301b9 --- /dev/null +++ b/test/cli/fuzz-crash/crash-c36b9a5f7fce91031cb578ef591f90d48d95a7f4 @@ -0,0 +1 @@ +cs=t,{;{}}>l \ No newline at end of file diff --git a/test/cli/fuzz-crash_c/crash-24c217c96d177b8dff4028bce639756d6a8c6088 b/test/cli/fuzz-crash_c/crash-24c217c96d177b8dff4028bce639756d6a8c6088 new file mode 100644 index 00000000000..161962b6fe4 --- /dev/null +++ b/test/cli/fuzz-crash_c/crash-24c217c96d177b8dff4028bce639756d6a8c6088 @@ -0,0 +1 @@ +f(S=n){n*,n&&} \ No newline at end of file diff --git a/test/cli/fuzz_test.py b/test/cli/fuzz_test.py index b8cf09a5657..f1dbcd2983e 100644 --- a/test/cli/fuzz_test.py +++ b/test/cli/fuzz_test.py @@ -11,9 +11,9 @@ def test_fuzz_crash(): fuzz_crash_dir = os.path.join(__script_dir, 'fuzz-crash') for f in os.listdir(fuzz_crash_dir): - ret, stdout, _ = cppcheck(['-q', '--language=c++', '--enable=all', '--inconclusive', f], cwd=fuzz_crash_dir) + ret, stdout, stderr = cppcheck(['-q', '--language=c++', '--enable=all', '--inconclusive', f], cwd=fuzz_crash_dir) if ret != 0: - failures[f] = stdout + failures[f] = stdout + stderr assert failures == {} @@ -26,9 +26,9 @@ def test_fuzz_crash_c(): if not os.path.exists(fuzz_crash_dir): return for f in os.listdir(fuzz_crash_dir): - ret, stdout, _ = cppcheck(['-q', '--language=c', '--enable=all', '--inconclusive', f], cwd=fuzz_crash_dir) + ret, stdout, stderr = cppcheck(['-q', '--language=c', '--enable=all', '--inconclusive', f], cwd=fuzz_crash_dir) if ret != 0: - failures[f] = stdout + failures[f] = stdout + stderr assert failures == {} From 25ad0dfcdde7ff26f4cf94ead915830321084b3a Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Mon, 5 Jan 2026 17:34:31 +0100 Subject: [PATCH 019/675] wxwidgets.cfg add some missing configuration for wxPropertyGrid (#8087) This pull request adds support for additional methods in the `wxwidgets` configuration file to improve property grid functionality and access. The most notable changes are the addition of new function definitions related to property value retrieval and grid access. New property retrieval functions: * Added definitions for `wxPGProperty::GetValue` and `wxPGProperty::DoGetValue`, enabling retrieval of property values as `wxVariant` objects. Property grid access: * Added definition for `wxPropertyGridManager::GetGrid`, allowing direct access to the underlying `wxPropertyGrid` from a `wxPropertyGridManager`. --- cfg/wxwidgets.cfg | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cfg/wxwidgets.cfg b/cfg/wxwidgets.cfg index e09b19e15af..50bc8e2ceef 100644 --- a/cfg/wxwidgets.cfg +++ b/cfg/wxwidgets.cfg @@ -7253,6 +7253,15 @@ This function is deprecated, use 'wxPGProperty::GetValueAsString()' instead. + + + + false + + + + + @@ -11384,6 +11393,12 @@ + + + false + + + From f4f510092daa4db3f223a025c6daad11733475fd Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Mon, 5 Jan 2026 20:25:41 +0100 Subject: [PATCH 020/675] wxwidgets.cfg: Added support for more missing interfaces. (#8088) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This pull request updates the `cfg/wxwidgets.cfg` file to improve coverage and accuracy of function definitions for wxWidgets classes. The most important changes include adding new function definitions and extending existing ones to cover additional classes and methods. ### Expanded function coverage * Added a new function definition for `wxULongLong::GetValue`, allowing retrieval of the value stored in a `wxULongLong` object. * Updated the function definition for `Refresh` to include both `wxWindow` and `wxPropertyGridManager`, ensuring correct handling of the method for both classes. * Extended the `IsOk` function definition to include `wxIcon`, in addition to `wxColour` and `wxFont`, improving consistency across related classes.…fresh' and 'wxIcon::IsOk' --- cfg/wxwidgets.cfg | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cfg/wxwidgets.cfg b/cfg/wxwidgets.cfg index 50bc8e2ceef..b219d9bee01 100644 --- a/cfg/wxwidgets.cfg +++ b/cfg/wxwidgets.cfg @@ -10361,6 +10361,14 @@ + + + false + + + + + false @@ -12518,7 +12526,8 @@ - + + false @@ -15822,7 +15831,8 @@ wxItemKind kind = wxITEM_NORMAL) --> - + + false From 0cb895d27a93e52f13b278260bc4b19dae44bcd5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 5 Jan 2026 21:50:20 +0100 Subject: [PATCH 021/675] Add test for #8616 (#8089) Co-authored-by: chrchr-github --- test/testbufferoverrun.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index ce7b9428d1f..ec02406dcc8 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -3752,6 +3752,26 @@ class TestBufferOverrun : public TestFixture { " memset(&i[1], 0, 1000);\n" "}"); TODO_ASSERT_EQUALS("[test.cpp:3:10]: (error) Buffer is accessed out of bounds: &i[1] [bufferAccessOutOfBounds]\n", "", errout_str()); + + check("struct S { int x; };\n" // #8616 + "void f() {\n" + " S s;\n" + " memset(&s, 0, sizeof(s) * 2);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4:12]: (error) Buffer is accessed out of bounds: &s [bufferAccessOutOfBounds]\n", errout_str()); + + check("void f() {\n" + " char x;\n" + " memset(&x, 0, 16);\n" + "}\n" + "void g(char y) {\n" + " char x;\n" + " memcpy(&x, &y, 16);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:12]: (error) Buffer is accessed out of bounds: &x [bufferAccessOutOfBounds]\n" + "[test.cpp:7:12]: (error) Buffer is accessed out of bounds: &x [bufferAccessOutOfBounds]\n" + "[test.cpp:7:16]: (error) Buffer is accessed out of bounds: &y [bufferAccessOutOfBounds]\n", + errout_str()); } void valueflow_string() { // using ValueFlow string values in checking From 4fc4f01ba74aee78c2178014cdb7f91d99f38ff0 Mon Sep 17 00:00:00 2001 From: Florian Mueller Date: Tue, 6 Jan 2026 13:05:22 +0100 Subject: [PATCH 022/675] =?UTF-8?q?Fixing=20false=20positives=20for=20MISR?= =?UTF-8?q?A=20C++=202023=20Rule=206.5.1=20on=20googletest=20ma=E2=80=A6?= =?UTF-8?q?=20(#8086)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running cppcheck premium with MISRA C++2023 Rule 6.5.1 enabled on unittests using googletests with `--library=googletest`, cppcheck is flagging each `TEST(test_suite_name, test_name)` with violation of Rule 6.5.1. The current definition of `TEST(A,B)` in `googletest.cfg` defines the function without special care, which violates the MISRA rule. Following the original MACRO definition from googletest, the PR introduces encapsulation with a class. Co-authored-by: Florian Mueller --- cfg/googletest.cfg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cfg/googletest.cfg b/cfg/googletest.cfg index 36dd8a40669..c32eef7274b 100644 --- a/cfg/googletest.cfg +++ b/cfg/googletest.cfg @@ -29,11 +29,11 @@ - - - - - + + + + + From 0fe48ba7879a1da546347bac44d3aeb921476da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Tue, 6 Jan 2026 13:26:23 +0100 Subject: [PATCH 023/675] fix #14352: fuzzing crash (null-pointer-use) in Preprocessor::simplifyPragmaAsmPrivate() (#8075) --- lib/preprocessor.cpp | 5 +++++ .../crash-ef635709a2489083534cd422e6a089daab23ec64 | 1 + test/testpreprocessor.cpp | 8 ++++++++ 3 files changed, 14 insertions(+) create mode 100644 test/cli/fuzz-crash/crash-ef635709a2489083534cd422e6a089daab23ec64 diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index c395bf07e8b..123ef5ca898 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -1070,6 +1070,7 @@ void Preprocessor::simplifyPragmaAsmPrivate(simplecpp::TokenList &tokenList) continue; const simplecpp::Token *endasm = tok3; + bool foundEndasm = false; while ((endasm = endasm->next) != nullptr) { if (endasm->op != '#' || sameline(endasm,endasm->previousSkipComments())) continue; @@ -1081,9 +1082,13 @@ void Preprocessor::simplifyPragmaAsmPrivate(simplecpp::TokenList &tokenList) continue; while (sameline(endasm,endasm3)) endasm = endasm->next; + foundEndasm = true; break; } + if (!foundEndasm) + throw InternalError(nullptr, "syntax error: missing #pragma endasm", InternalError::SYNTAX); + const simplecpp::Token * const tok4 = tok3->next; tok->setstr("asm"); const_cast(tok2)->setstr("("); diff --git a/test/cli/fuzz-crash/crash-ef635709a2489083534cd422e6a089daab23ec64 b/test/cli/fuzz-crash/crash-ef635709a2489083534cd422e6a089daab23ec64 new file mode 100644 index 00000000000..6274e3a27a1 --- /dev/null +++ b/test/cli/fuzz-crash/crash-ef635709a2489083534cd422e6a089daab23ec64 @@ -0,0 +1 @@ +#pragma asm \ No newline at end of file diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index e97b49196cb..66b3e24062f 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -365,6 +365,8 @@ class TestPreprocessor : public TestFixture { TEST_CASE(standard); TEST_CASE(writeLocations); + + TEST_CASE(pragmaAsm); } template @@ -2804,6 +2806,12 @@ class TestPreprocessor : public TestFixture { "} ;", processed); } + + void pragmaAsm() + { + const char code[] = "#pragma asm"; + ASSERT_THROW_INTERNAL(getcodeforcfg(settingsDefault, *this, code, "", "test.cpp"), InternalError::SYNTAX); + } }; REGISTER_TEST(TestPreprocessor) From 85e8b747b565f2193cb6fed9eac2e7c51cbd0df1 Mon Sep 17 00:00:00 2001 From: Melroy van den Berg Date: Tue, 6 Jan 2026 14:53:22 +0100 Subject: [PATCH 024/675] Docs: Better describe python venv (#8043) - virtualenv command doesn't exists - activate the virtual python environment - run the pip command - `python` often also no longer exists, but we will use the shebang of the python script (which points to python3 anyways) --------- Co-authored-by: autoantwort <41973254+autoantwort@users.noreply.github.com> --- readme.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index a5f40486719..72f368b3293 100644 --- a/readme.md +++ b/readme.md @@ -17,15 +17,17 @@ A manual is available [online](https://cppcheck.sourceforge.io/manual.pdf). ## Donate CPU -Cppcheck is a hobby project with limited resources. You can help us by donating CPU (1 core or as many as you like). It is simple: +Cppcheck is a hobby project with limited resources. You can help us by donating CPU (1 core, which is the default, or as many as you like. Use the `-j` flag to use more cores). It is simple: 1. Download (and extract) Cppcheck source code. - 2. Run: + 2. Run (Linux/MacOS example): ``` cd cppcheck/ - virtualenv .env - .env/bin/pip install -r tools/donate-cpu-requirements.txt - .env/bin/python tools/donate-cpu.py + python3 -m venv .venv + source .venv/bin/activate + + pip install -r tools/donate-cpu-requirements.txt + ./tools/donate-cpu.py ``` The script will analyse debian source code and upload the results to a cppcheck server. We need these results both to improve Cppcheck and to detect regressions. From 67c46045c4249e87dcaecef4e62821a22a0221f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 6 Jan 2026 14:58:03 +0100 Subject: [PATCH 025/675] AUTHORS: Add melroy89 [skip ci] (#8091) --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 01c3ab76379..be41c3c525c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -277,6 +277,7 @@ Matthias Schmieder Matt Johnson Maurice Gilden Mavik +Melroy van den Berg Michael Drake Michael Løiten Miika-Petteri Matikainen From 290585774a109205966b95352da8e6701140c9f6 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Tue, 6 Jan 2026 15:05:10 +0100 Subject: [PATCH 026/675] wxwidgets.cfg: Added support for more interfaces (#8090) This pull request expands the function configuration in `cfg/wxwidgets.cfg` to include additional wxWidgets API methods, improving coverage and consistency for function bindings. The most important changes involve adding more methods to existing function groups and introducing new function entries for various wxWidgets classes. ### Expanded function bindings * Added `wxTreeListItem::IsOk` to the function group with `wxBitmap::HasAlpha` and `wxBitmap::IsOk`, ensuring consistent handling of `IsOk` methods across more classes. * Extended the `Layout` function group to include `wxWindow::Layout`, `wxGrid::Layout`, and `wxPanel::Layout`, in addition to the existing `wxWindowBase::Layout` and `wxFrame::Layout`. Also, added a new group for sizer-related `Layout` methods (`wxSizer`, `wxBoxSizer`, `wxGridSizer`, `wxStaticBoxSizer`). ### New function entries * Added new function entries for `wxWindow::GetScreenPosition`, `wxGrid::GetScreenPosition`, `wxDataViewListCtrl::GetItemCount`, and the static method `wxStandardPaths::Get`, improving API access for these commonly-used methods. * Grouped `GetPosition` methods for `wxGridEvent`, `wxMouseEvent`, and `wxMouseState` into a single function entry, streamlining their configuration. --- cfg/wxwidgets.cfg | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/cfg/wxwidgets.cfg b/cfg/wxwidgets.cfg index b219d9bee01..c1370373b54 100644 --- a/cfg/wxwidgets.cfg +++ b/cfg/wxwidgets.cfg @@ -11703,7 +11703,8 @@ - + + false @@ -16122,6 +16123,30 @@ wxItemKind kind = wxITEM_NORMAL) --> + + + + false + + + + + + + + false + + + + + + + + false + + + + false @@ -16140,7 +16165,9 @@ wxItemKind kind = wxITEM_NORMAL) --> - + + + false @@ -17048,13 +17075,25 @@ wxItemKind kind = wxITEM_NORMAL) --> + - + + + false + + + + + + false + + + From f1c33b2964c128ef8747a7a266f41171fe281134 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 7 Jan 2026 15:21:23 +0100 Subject: [PATCH 027/675] Fix #14366 FN functionStatic with unknown base class (#8085) --- gui/codeeditor.cpp | 2 +- gui/codeeditor.h | 2 +- lib/checkclass.cpp | 4 ++++ test/testclass.cpp | 31 +++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/gui/codeeditor.cpp b/gui/codeeditor.cpp index 7e7f2cbc37c..b6d88a061d3 100644 --- a/gui/codeeditor.cpp +++ b/gui/codeeditor.cpp @@ -246,7 +246,7 @@ void Highlighter::highlightBlock(const QString &text) } } -void Highlighter::applyFormat(HighlightingRule &rule) +void Highlighter::applyFormat(HighlightingRule &rule) const { switch (rule.ruleRole) { case RuleRole::Keyword: diff --git a/gui/codeeditor.h b/gui/codeeditor.h index 4f6d07e1e36..9508c562c41 100644 --- a/gui/codeeditor.h +++ b/gui/codeeditor.h @@ -65,7 +65,7 @@ class Highlighter : public QSyntaxHighlighter { RuleRole ruleRole; }; - void applyFormat(HighlightingRule &rule); + void applyFormat(HighlightingRule &rule) const; QList mHighlightingRules; QList mHighlightingRulesWithSymbols; diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 2949d3c57a7..11951411f8f 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2292,6 +2292,10 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const if (tok->isKeyword() || tok->isStandardType()) return false; + if (tok->variable() && (tok->variable()->isArgument() || tok->variable()->isLocal())) + return false; + if (tok->function() || tok->type() || tok->enumerator()) + return false; for (const Variable& var : scope->varlist) { if (var.name() == tok->str()) { diff --git a/test/testclass.cpp b/test/testclass.cpp index 21457f15bfc..46c61d41c37 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6731,6 +6731,7 @@ class TestClass : public TestFixture { "struct S<0> {};\n" "struct D : S<150> {};\n"); // don't hang + ignore_errout(); } void const93() { // #12162 @@ -6785,6 +6786,36 @@ class TestClass : public TestFixture { " B::g(0);\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + checkConst("struct S {\n" // #14366 + " void f();\n" + "};\n" + "struct T : U {\n" + " void g(S* s) {\n" + " s->f();\n" + " }\n" + " void h() {\n" + " S s;\n" + " s.f();\n" + " }\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:5:10]: (style) Either there is a missing 'override', or the member function 'T::g' can be static. [functionStatic]\n" + "[test.cpp:8:10]: (style) Either there is a missing 'override', or the member function 'T::h' can be static. [functionStatic]\n", + errout_str()); + + checkConst("enum E { E0 };\n" + "int f();\n" + "struct S : U {\n" + " E g() {\n" + " return E0;\n" + " }\n" + " int h() {\n" + " return f();\n" + " }\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:4:7]: (style) Either there is a missing 'override', or the member function 'S::g' can be static. [functionStatic]\n" + "[test.cpp:7:9]: (style) Either there is a missing 'override', or the member function 'S::h' can be static. [functionStatic]\n", + errout_str()); } void const97() { // #13301 From 7a03d5ff169cc0606ee6c74480681b1cf3ae34bd Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 8 Jan 2026 12:44:01 +0100 Subject: [PATCH 028/675] Fix #13692 fuzzing crash (null-pointer-use) in Tokenizer::simplifyAsm() (#8094) --- lib/tokenize.cpp | 2 ++ .../fuzz-crash/crash-7d409757e9b94fc2eb23758b655e056ec3dd9d09 | 1 + 2 files changed, 3 insertions(+) create mode 100644 test/cli/fuzz-crash/crash-7d409757e9b94fc2eb23758b655e056ec3dd9d09 diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index cc98703011a..db30349dba7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9976,6 +9976,8 @@ void Tokenizer::simplifyAsm() instruction = tok->stringifyList(endasm); Token::eraseTokens(tok, endasm); } else if (!endasm) { + if (!tok->next()) + syntaxError(tok); instruction = tok->next()->stringifyList(endasm); Token::eraseTokens(tok, endasm); tok->insertToken(";"); diff --git a/test/cli/fuzz-crash/crash-7d409757e9b94fc2eb23758b655e056ec3dd9d09 b/test/cli/fuzz-crash/crash-7d409757e9b94fc2eb23758b655e056ec3dd9d09 new file mode 100644 index 00000000000..8b8929bc573 --- /dev/null +++ b/test/cli/fuzz-crash/crash-7d409757e9b94fc2eb23758b655e056ec3dd9d09 @@ -0,0 +1 @@ +_asm From 558f66e14ed52df1d636bc5c84b15079d26acb82 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:12:06 +0100 Subject: [PATCH 029/675] Fix #13500 fuzzing crash (null-pointer-use) in TemplateSimplifier::useDefaultArgumentValues() (#8096) --- lib/templatesimplifier.cpp | 4 ++++ .../fuzz-crash/crash-7c3e963c9c28dab506696d0dbe8aaf8772d5302f | 1 + 2 files changed, 5 insertions(+) create mode 100644 test/cli/fuzz-crash/crash-7c3e963c9c28dab506696d0dbe8aaf8772d5302f diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 1291993990d..349894b2b89 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -1153,6 +1153,8 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration) instantiationArgs[index].push_back(tok1); tok1 = tok1->next(); } while (tok1 && tok1 != endLink); + if (!tok1) + syntaxError(end); instantiationArgs[index].push_back(tok1); } else if (tok1->str() == "<" && (tok1->strAt(1) == ">" || (tok1->previous()->isName() && @@ -1162,6 +1164,8 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration) instantiationArgs[index].push_back(tok1); tok1 = tok1->next(); } while (tok1 && tok1 != endLink); + if (!tok1) + syntaxError(end); instantiationArgs[index].push_back(tok1); } else if (tok1->str() == ",") { ++index; diff --git a/test/cli/fuzz-crash/crash-7c3e963c9c28dab506696d0dbe8aaf8772d5302f b/test/cli/fuzz-crash/crash-7c3e963c9c28dab506696d0dbe8aaf8772d5302f new file mode 100644 index 00000000000..ff8d3a2d0ac --- /dev/null +++ b/test/cli/fuzz-crash/crash-7c3e963c9c28dab506696d0dbe8aaf8772d5302f @@ -0,0 +1 @@ +h>teu<""e<>;templateteu=d From 544303343f9b490e5f485d36b9c230aedd4108ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 8 Jan 2026 18:22:58 +0100 Subject: [PATCH 030/675] fixed #14208 - read custom manual URL from `cppcheck.cfg` (#8072) --- cli/cmdlineparser.cpp | 7 +------ lib/settings.cpp | 9 +++++++++ lib/settings.h | 2 ++ test/cli/premium_test.py | 1 + test/testcmdlineparser.cpp | 15 +++++++++------ test/testsettings.cpp | 15 +++++++++++++++ 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 4e567e47d9f..47759b75196 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -1702,11 +1702,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a void CmdLineParser::printHelp(bool premium) const { - // TODO: fetch URL from config like product name? - const std::string manualUrl(premium ? - "https://files.cppchecksolutions.com/manual.pdf" : - "https://cppcheck.sourceforge.io/manual.pdf"); - std::ostringstream oss; // TODO: display product name oss << "Cppcheck - A tool for static C/C++ code analysis\n" @@ -2077,7 +2072,7 @@ void CmdLineParser::printHelp(bool premium) const " cppcheck -I inc1/ -I inc2/ f.cpp\n" "\n" "For more information:\n" - " " << manualUrl << "\n" + " " << mSettings.manualUrl << "\n" "\n" "Many thanks to the 3rd party libraries we use:\n" " * tinyxml2 -- loading project/library/ctu files.\n" diff --git a/lib/settings.cpp b/lib/settings.cpp index 19b8ce5142f..8e4b8d2a6d4 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -117,6 +117,15 @@ std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppress settings.cppcheckCfgProductName = v.get(); } } + { + const auto it = utils::as_const(obj).find("manualUrl"); + if (it != obj.cend()) { + const auto& v = it->second; + if (!v.is()) + return "'manualUrl' is not a string"; + settings.manualUrl = v.get(); + } + } { const auto it = utils::as_const(obj).find("about"); if (it != obj.cend()) { diff --git a/lib/settings.h b/lib/settings.h index cae78e850eb..04541cda08c 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -291,6 +291,8 @@ class CPPCHECKLIB WARN_UNUSED Settings { int loadAverage{}; #endif + std::string manualUrl{"https://cppcheck.sourceforge.io/manual.pdf"}; + /** --max-configs value */ int maxConfigsOption = 0; // "Not Assigned" value diff --git a/test/cli/premium_test.py b/test/cli/premium_test.py index 1bb01260b42..ddf7b1e2fbe 100644 --- a/test/cli/premium_test.py +++ b/test/cli/premium_test.py @@ -29,6 +29,7 @@ def __copy_cppcheck_premium(tmpdir): "addons": [], "productName": "NAME", "about": "NAME", + "manualUrl" : "https://files.cppchecksolutions.com/manual.pdf", "safety": true } """.replace('NAME', __PRODUCT_NAME)) diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 038d1ea0b01..7b5c646e4bf 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -551,7 +551,8 @@ class TestCmdlineParser : public TestFixture { REDIRECT; ScopedFile file(Path::join(Path::getPathFromFilename(Path::getCurrentExecutablePath("")), "cppcheck.cfg"), "{\n" - "\"productName\": \"Cppcheck Premium\"" + "\"productName\": \"Cppcheck Premium\"," + "\"manualUrl\": \"https://docs.notcppcheck.com/manual.pdf\"" "}\n"); const char * const argv[] = {"cppcheck"}; ASSERT_EQUALS_ENUM(CmdLineParser::Result::Exit, parseFromArgs(argv)); @@ -559,7 +560,7 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS(file.path(), *settings->settingsFiles.cbegin()); const std::string log_str = logger->str(); ASSERT_MSG(startsWith(log_str, "Cppcheck - A tool for static C/C++ code analysis"), "header"); - ASSERT_MSG(log_str.find("https://files.cppchecksolutions.com/manual.pdf") != std::string::npos, "help url"); + ASSERT_MSG(log_str.find("https://docs.notcppcheck.com/manual.pdf") != std::string::npos, "help url"); } void nooptionsWithInvalidCfg() { @@ -589,7 +590,8 @@ class TestCmdlineParser : public TestFixture { REDIRECT; ScopedFile file(Path::join(Path::getPathFromFilename(Path::getCurrentExecutablePath("")), "cppcheck.cfg"), "{\n" - "\"productName\": \"Cppcheck Premium\"" + "\"productName\": \"Cppcheck Premium\"," + "\"manualUrl\": \"https://docs.notcppcheck.com/manual.pdf\"" "}\n"); const char * const argv[] = {"cppcheck", "-h"}; ASSERT_EQUALS_ENUM(CmdLineParser::Result::Exit, parseFromArgs(argv)); @@ -597,7 +599,7 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS(file.path(), *settings->settingsFiles.cbegin()); const std::string log_str = logger->str(); ASSERT_MSG(startsWith(log_str, "Cppcheck - A tool for static C/C++ code analysis"), "header"); - ASSERT_MSG(log_str.find("https://files.cppchecksolutions.com/manual.pdf") != std::string::npos, "help url"); + ASSERT_MSG(log_str.find("https://docs.notcppcheck.com/manual.pdf") != std::string::npos, "help url"); } void helplong() { @@ -618,7 +620,8 @@ class TestCmdlineParser : public TestFixture { REDIRECT; ScopedFile file(Path::join(Path::getPathFromFilename(Path::getCurrentExecutablePath("")), "cppcheck.cfg"), "{\n" - "\"productName\": \"Cppcheck Premium\"" + "\"productName\": \"Cppcheck Premium\"," + "\"manualUrl\": \"https://docs.notcppcheck.com/manual.pdf\"" "}\n"); const char * const argv[] = {"cppcheck", "--help"}; ASSERT_EQUALS_ENUM(CmdLineParser::Result::Exit, parseFromArgs(argv)); @@ -626,7 +629,7 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS(file.path(), *settings->settingsFiles.cbegin()); const std::string log_str = logger->str(); ASSERT_MSG(startsWith(log_str, "Cppcheck - A tool for static C/C++ code analysis"), "header"); - ASSERT_MSG(log_str.find("https://files.cppchecksolutions.com/manual.pdf") != std::string::npos, "help url"); + ASSERT_MSG(log_str.find("https://docs.notcppcheck.com/manual.pdf") != std::string::npos, "help url"); } void version() { diff --git a/test/testsettings.cpp b/test/testsettings.cpp index fd8f62c1a82..7bc6aeb0352 100644 --- a/test/testsettings.cpp +++ b/test/testsettings.cpp @@ -236,6 +236,21 @@ class TestSettings : public TestFixture { R"({"suppressions": [1]}\n)"); ASSERT_EQUALS("'suppressions' array entry is not a string", Settings::loadCppcheckCfg(s, supprs)); } + { + Settings s; + Suppressions supprs; + ScopedFile file("cppcheck.cfg", + R"({"manualUrl": "https://docs.notcppcheck.com/manual.pdf"})"); + ASSERT_EQUALS("", Settings::loadCppcheckCfg(s, supprs)); + ASSERT_EQUALS("https://docs.notcppcheck.com/manual.pdf", s.manualUrl); + } + { + Settings s; + Suppressions supprs; + ScopedFile file("cppcheck.cfg", + R"({"manualUrl": 0}\n)"); + ASSERT_EQUALS("'manualUrl' is not a string", Settings::loadCppcheckCfg(s, supprs)); + } // TODO: test with FILESDIR } From 9dfbfbeabafb24ee5b7cecc9b1deb80bb4f1a610 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 8 Jan 2026 20:35:09 +0100 Subject: [PATCH 031/675] Add test for #4638 FN memleak (pointer converted to bool on return) (#8098) Co-authored-by: chrchr-github --- test/testleakautovar.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index daf738e7b46..7aa64c1cd3c 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -181,6 +181,7 @@ class TestLeakAutoVar : public TestFixture { TEST_CASE(return10); TEST_CASE(return11); // #13098 TEST_CASE(return12); // #12238 + TEST_CASE(return13); // General tests: variable type, allocation type, etc TEST_CASE(test1); @@ -2838,6 +2839,22 @@ class TestLeakAutoVar : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void return13() { // #4638 + CheckOptions options; + options.cpp = true; + check("bool f() {\n" + " int* p = new int;\n" + " return p;\n" + "}\n" + "bool g() {\n" + " void* p = malloc(4);\n" + " return p;\n" + "}\n", options); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Memory leak: p [memleak]\n" + "[test.cpp:7:5]: (error) Memory leak: p [memleak]\n", + errout_str()); + } + void test1() { check("void f(double*&p) {\n" // 3809 " p = malloc(0x100);\n" From 1019e7a523cce8c3910cf233ed0ed5b1575b15c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 8 Jan 2026 20:55:13 +0100 Subject: [PATCH 032/675] Fix #13337 (GUI: In the Misra Report, use proper icons according to misra classifications) (#8092) --- .selfcheck_suppressions | 1 + gui/resultitem.h | 12 ++++++++++ gui/resultstree.cpp | 12 ++++++---- gui/test/resultstree/testresultstree.cpp | 29 ++++++++++++++++++++++++ gui/test/resultstree/testresultstree.h | 1 + 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/.selfcheck_suppressions b/.selfcheck_suppressions index 1b6dcc1965b..7728225cd44 100644 --- a/.selfcheck_suppressions +++ b/.selfcheck_suppressions @@ -17,6 +17,7 @@ functionStatic:*/ui_fileview.h # --debug-warnings suppressions valueFlowBailout valueFlowBailoutIncompleteVar +valueFlowMaxIterations:gui/resultstree.cpp autoNoType:externals/simplecpp/simplecpp.cpp autoNoType:cli/*.cpp autoNoType:lib/*.cpp diff --git a/gui/resultitem.h b/gui/resultitem.h index a7669d2a3b4..a39606ad23d 100644 --- a/gui/resultitem.h +++ b/gui/resultitem.h @@ -41,9 +41,21 @@ class ResultItem : public QStandardItem Type getType() const { return mType; } + + void setIconFileName(const QString& iconFileName) { + mIconFileName = iconFileName; + if (!mIconFileName.isEmpty()) + setIcon(QIcon(iconFileName)); + } + + // cppcheck-suppress unusedFunction; used in test-resultstree + const QString& getIconFileName() const { + return mIconFileName; + } private: const Type mType; const int mErrorPathIndex; + QString mIconFileName; }; #endif // RESULTITEM_H diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 78d56929b48..ed4cc8b0535 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -126,6 +126,10 @@ static QStringList getLabels() { QObject::tr("CWE")}; } +static Severity getSeverity(ReportType reportType, const ErrorItem& errorItem) { + return reportType == ReportType::normal ? errorItem.severity : getSeverityFromClassification(errorItem.classification); +} + ResultsTree::ResultsTree(QWidget * parent) : QTreeView(parent), mModel(new QStandardItemModel) @@ -160,6 +164,7 @@ void ResultsTree::setReportType(ReportType reportType) { QSharedPointer& errorItem = dynamic_cast(fileItem->child(j,0))->errorItem; errorItem->guideline = getGuideline(mReportType, mGuideline, errorItem->errorId, errorItem->severity); errorItem->classification = getClassification(mReportType, errorItem->guideline); + dynamic_cast(fileItem->child(j, COLUMN_FILE))->setIconFileName(severityToIcon(getSeverity(reportType, *errorItem))); fileItem->child(j, COLUMN_CERT_LEVEL)->setText(errorItem->classification); fileItem->child(j, COLUMN_CERT_RULE)->setText(errorItem->guideline); fileItem->child(j, COLUMN_MISRA_CLASSIFICATION)->setText(errorItem->classification); @@ -264,7 +269,7 @@ bool ResultsTree::addErrorItem(const ErrorItem& errorItem) ResultItem* stditem = addBacktraceFiles(fileItem, errorItemPtr, !showItem, - severityToIcon(errorItemPtr->severity), + severityToIcon(getSeverity(mReportType, *errorItemPtr)), ResultItem::Type::message, errorItemPtr->getMainLocIndex()); @@ -317,6 +322,7 @@ ResultItem *ResultsTree::addBacktraceFiles(ResultItem *parent, const int numberOfColumns = getLabels().size(); QList columns(numberOfColumns); columns[COLUMN_FILE] = createFilenameItem(errorItem, type, errorPathIndex); + columns[COLUMN_FILE]->setIconFileName(icon); columns[COLUMN_LINE] = createLineNumberItem(loc.line, errorItem, type, errorPathIndex); columns[COLUMN_SEVERITY] = createNormalItem(itemSeverity, errorItem, type, errorPathIndex); columns[COLUMN_SUMMARY] = createNormalItem(text, errorItem, type, errorPathIndex); @@ -340,10 +346,6 @@ ResultItem *ResultsTree::addBacktraceFiles(ResultItem *parent, setRowHidden(parent->rowCount() - 1, parent->index(), hide); - if (!icon.isEmpty()) { - list[COLUMN_FILE]->setIcon(QIcon(icon)); - } - return columns[COLUMN_FILE]; } diff --git a/gui/test/resultstree/testresultstree.cpp b/gui/test/resultstree/testresultstree.cpp index 0873314a41c..ac3ba4ff78c 100644 --- a/gui/test/resultstree/testresultstree.cpp +++ b/gui/test/resultstree/testresultstree.cpp @@ -294,6 +294,35 @@ void TestResultsTree::testReportType() const "missingReturn,Mandatory,17.4"); } +void TestResultsTree::testReportTypeIcon() const { + ResultsTree tree(nullptr); + tree.setReportType(ReportType::misraC2012); + tree.addErrorItem(createErrorItem("file1.c", 10, Severity::style, "some rule text", "premium-misra-c-2012-1.1")); // Required + tree.addErrorItem(createErrorItem("file1.c", 20, Severity::style, "some rule text", "premium-misra-c-2012-1.2")); // Advisory + tree.addErrorItem(createErrorItem("file1.c", 30, Severity::style, "some rule text", "premium-misra-c-2012-9.1")); // Mandatory + + const auto* model = dynamic_cast(tree.model()); + QVERIFY(model != nullptr); + const ResultItem* fileItem = dynamic_cast(model->item(0,0)); + + const ResultItem* err1 = dynamic_cast(fileItem->child(0,0)); + const ResultItem* err2 = dynamic_cast(fileItem->child(1,0)); + const ResultItem* err3 = dynamic_cast(fileItem->child(2,0)); + + QCOMPARE(err1->getIconFileName(), ":images/dialog-warning.png"); + QCOMPARE(err2->getIconFileName(), ":images/applications-development.png"); + QCOMPARE(err3->getIconFileName(), ":images/dialog-error.png"); + + tree.setReportType(ReportType::normal); + QCOMPARE(err1->getIconFileName(), ":images/applications-development.png"); + QCOMPARE(err2->getIconFileName(), ":images/applications-development.png"); + QCOMPARE(err3->getIconFileName(), ":images/applications-development.png"); + + tree.setReportType(ReportType::misraC2012); + QCOMPARE(err1->getIconFileName(), ":images/dialog-warning.png"); + QCOMPARE(err2->getIconFileName(), ":images/applications-development.png"); + QCOMPARE(err3->getIconFileName(), ":images/dialog-error.png"); +} void TestResultsTree::testGetGuidelineError() const { diff --git a/gui/test/resultstree/testresultstree.h b/gui/test/resultstree/testresultstree.h index 108ed098eb5..8604dc81c6b 100644 --- a/gui/test/resultstree/testresultstree.h +++ b/gui/test/resultstree/testresultstree.h @@ -27,6 +27,7 @@ private slots: void multiLineResult() const; void resultsInSameFile() const; void testReportType() const; + void testReportTypeIcon() const; void testGetGuidelineError() const; void misraCReportShowClassifications() const; }; From 7e723efc99dd30ba0d21db3c360df1124b86ea5b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 9 Jan 2026 14:48:21 +0100 Subject: [PATCH 033/675] Fix #13711 fuzzing crash (null-pointer-use) in Tokenizer::simplifyCompoundStatements() (#8099) --- lib/tokenize.cpp | 2 ++ .../fuzz-crash/crash-be54fe1da04e7a624214b58f3b572b87082a2e93 | 1 + 2 files changed, 3 insertions(+) create mode 100644 test/cli/fuzz-crash/crash-be54fe1da04e7a624214b58f3b572b87082a2e93 diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index db30349dba7..aa4302198e2 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5707,6 +5707,8 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) if (isCPP()) simplifyExternC(); + validate(); + // simplify compound statements: "[;{}] ( { code; } ) ;"->"[;{}] code;" simplifyCompoundStatements(); diff --git a/test/cli/fuzz-crash/crash-be54fe1da04e7a624214b58f3b572b87082a2e93 b/test/cli/fuzz-crash/crash-be54fe1da04e7a624214b58f3b572b87082a2e93 new file mode 100644 index 00000000000..e263f9d8c66 --- /dev/null +++ b/test/cli/fuzz-crash/crash-be54fe1da04e7a624214b58f3b572b87082a2e93 @@ -0,0 +1 @@ +(({}namespace d=n)); From e2640e7bf2b2213b5851cceb4a061466e16d265a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 9 Jan 2026 19:26:27 +0100 Subject: [PATCH 034/675] Fix #13497 fuzzing crash (null-pointer-use) in Tokenizer::simplifyTypedefCpp() (#8100) --- lib/tokenize.cpp | 2 ++ .../fuzz-crash/crash-0400fbfed5c89e368e436dbac630db0f80db94bd | 1 + 2 files changed, 3 insertions(+) create mode 100644 test/cli/fuzz-crash/crash-0400fbfed5c89e368e436dbac630db0f80db94bd diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index aa4302198e2..c5e810f1148 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1125,6 +1125,8 @@ void Tokenizer::simplifyTypedef() list.front()->deleteThis(); } + validate(); + simplifyTypedefCpp(); } diff --git a/test/cli/fuzz-crash/crash-0400fbfed5c89e368e436dbac630db0f80db94bd b/test/cli/fuzz-crash/crash-0400fbfed5c89e368e436dbac630db0f80db94bd new file mode 100644 index 00000000000..d6e9b32be37 --- /dev/null +++ b/test/cli/fuzz-crash/crash-0400fbfed5c89e368e436dbac630db0f80db94bd @@ -0,0 +1 @@ +typedef i(*const type2)();typedef t(ty)();(v ty)type2() From e031165626cf74d17e0ca26931aced2517325fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 9 Jan 2026 23:39:26 +0100 Subject: [PATCH 035/675] Fix #14370 (False negative: missingReturn in catch) (#8095) --- lib/checkfunctions.cpp | 13 +++++++++++++ test/testfunctions.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 8884a03fc48..1ab21eacfd2 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -396,6 +396,19 @@ static const Token *checkMissingReturnScope(const Token *tok, const Library &lib if (Token::simpleMatch(tok->tokAt(-2), "} else {")) return checkMissingReturnScope(tok->tokAt(-2), library); return tok; + } else if (tok->scope()->type == ScopeType::eCatch) { + while (tok->str() == "}") { + const Token *errorToken = checkMissingReturnScope(tok, library); + if (errorToken || tok->scope()->type == ScopeType::eTry) + return errorToken; + tok = tok->link(); + if (Token::simpleMatch(tok->previous(), ") {") && Token::simpleMatch(tok->linkAt(-1)->tokAt(-2), "} catch (")) + tok = tok->linkAt(-1)->tokAt(-2); + else + break; + } + // FIXME this should not be reached + return nullptr; } // FIXME return nullptr; diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index da589c765fe..6aa4e6534a2 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -85,6 +85,7 @@ class TestFunctions : public TestFixture { TEST_CASE(checkMissingReturn4); TEST_CASE(checkMissingReturn5); TEST_CASE(checkMissingReturn6); // #13180 + TEST_CASE(checkMissingReturn7); // #14370 - FN try/catch // std::move for locar variable TEST_CASE(returnLocalStdMove1); @@ -1880,6 +1881,43 @@ class TestFunctions : public TestFixture { ASSERT_EQUALS("[test.cpp:3:5]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str()); } + void checkMissingReturn7() {// #14370 FN try/catch + check("int foo(void) {\n" + " try { return readData(); }\n" + " catch (...) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:18]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str()); + + check("int foo(void) {\n" + " try { return readData(); }\n" + " catch (const E& e) {}\n" + " catch (...) { return 2; }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:25]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str()); + + check("int foo(void) {\n" + " try { x=1; }\n" + " catch (...) { return 2; }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:11]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str()); + + check("int foo(void) {\n" + " try { return readData(); }\n" + " catch (...) { return 0; }\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + + check("int foo(void)\n" + " try { x=1; }\n" + " catch (...) { return 2; }\n"); + ASSERT_EQUALS("[test.cpp:2:11]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str()); + + check("int foo(void)\n" + " try { return readData(); }\n" + " catch (...) { }\n"); + ASSERT_EQUALS("[test.cpp:3:19]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str()); + } + // NRVO check void returnLocalStdMove1() { check("struct A{}; A f() { A var; return std::move(var); }"); From 574fffaeb56155e52bb2349fa6649c623d1d17ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 10 Jan 2026 01:51:39 +0100 Subject: [PATCH 036/675] moved common `files.txt` loading code to `AnalyzerInformation` (#8097) --- Makefile | 4 +-- lib/analyzerinfo.cpp | 34 ++++++++++++++++++ lib/analyzerinfo.h | 4 +++ lib/checkunusedfunctions.cpp | 67 ++++++++++++------------------------ lib/cppcheck.cpp | 55 +++++++++-------------------- lib/ctu.cpp | 1 + oss-fuzz/Makefile | 4 +-- 7 files changed, 81 insertions(+), 88 deletions(-) diff --git a/Makefile b/Makefile index 02482206b9a..3fef3103d96 100644 --- a/Makefile +++ b/Makefile @@ -565,7 +565,7 @@ $(libcppdir)/checktype.o: lib/checktype.cpp lib/addoninfo.h lib/astutils.h lib/c $(libcppdir)/checkuninitvar.o: lib/checkuninitvar.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checknullpointer.h lib/checkuninitvar.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkuninitvar.cpp -$(libcppdir)/checkunusedfunctions.o: lib/checkunusedfunctions.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/checkers.h lib/checkunusedfunctions.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h +$(libcppdir)/checkunusedfunctions.o: lib/checkunusedfunctions.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/analyzerinfo.h lib/astutils.h lib/checkers.h lib/checkunusedfunctions.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkunusedfunctions.cpp $(libcppdir)/checkunusedvar.o: lib/checkunusedvar.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkunusedvar.h lib/config.h lib/errortypes.h lib/fwdanalysis.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h @@ -580,7 +580,7 @@ $(libcppdir)/clangimport.o: lib/clangimport.cpp lib/addoninfo.h lib/checkers.h l $(libcppdir)/color.o: lib/color.cpp lib/color.h lib/config.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/color.cpp -$(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkunusedfunctions.h lib/clangimport.h lib/color.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/regex.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h lib/vfvalue.h lib/xml.h +$(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkunusedfunctions.h lib/clangimport.h lib/color.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/regex.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/cppcheck.cpp $(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/check.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index 9477f2e290d..6d5ac9a9b15 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -209,3 +209,37 @@ bool AnalyzerInformation::Info::parse(const std::string& filesTxtLine) { return true; } +// TODO: bail out on unexpected data +void AnalyzerInformation::processFilesTxt(const std::string& buildDir, const std::function& handler) +{ + const std::string filesTxt(buildDir + "/files.txt"); + std::ifstream fin(filesTxt.c_str()); + std::string filesTxtLine; + while (std::getline(fin, filesTxtLine)) { + AnalyzerInformation::Info filesTxtInfo; + if (!filesTxtInfo.parse(filesTxtLine)) { + return; + } + + const std::string xmlfile = buildDir + '/' + filesTxtInfo.afile; + + tinyxml2::XMLDocument doc; + const tinyxml2::XMLError error = doc.LoadFile(xmlfile.c_str()); + if (error != tinyxml2::XML_SUCCESS) + return; + + const tinyxml2::XMLElement * const rootNode = doc.FirstChildElement(); + if (rootNode == nullptr) + return; + + for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) { + if (std::strcmp(e->Name(), "FileInfo") != 0) + continue; + const char *checkattr = e->Attribute("check"); + if (checkattr == nullptr) + continue; + handler(checkattr, e, filesTxtInfo); + } + } +} + diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 732587e0a71..04ea1a5b339 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -33,6 +34,7 @@ struct FileSettings; namespace tinyxml2 { class XMLDocument; + class XMLElement; }; /// @addtogroup Core @@ -75,6 +77,8 @@ class CPPCHECKLIB AnalyzerInformation { std::string sourceFile; }; + static void processFilesTxt(const std::string& buildDir, const std::function& handler); + protected: static std::string getFilesTxt(const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings); diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index b45200d7128..7edaff6c241 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -20,6 +20,7 @@ //--------------------------------------------------------------------------- #include "checkunusedfunctions.h" +#include "analyzerinfo.h" #include "astutils.h" #include "errorlogger.h" #include "errortypes.h" @@ -34,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -457,55 +458,31 @@ void CheckUnusedFunctions::analyseWholeProgram(const Settings &settings, ErrorLo std::map decls; std::set calls; - const std::string filesTxt(buildDir + "/files.txt"); - std::ifstream fin(filesTxt.c_str()); - std::string filesTxtLine; - while (std::getline(fin, filesTxtLine)) { - const std::string::size_type firstColon = filesTxtLine.find(':'); - if (firstColon == std::string::npos) - continue; - const std::string::size_type secondColon = filesTxtLine.find(':', firstColon+1); - if (secondColon == std::string::npos) - continue; - const std::string xmlfile = buildDir + '/' + filesTxtLine.substr(0,firstColon); - const std::string sourcefile = filesTxtLine.substr(secondColon+1); - - tinyxml2::XMLDocument doc; - const tinyxml2::XMLError error = doc.LoadFile(xmlfile.c_str()); - if (error != tinyxml2::XML_SUCCESS) - continue; - - const tinyxml2::XMLElement * const rootNode = doc.FirstChildElement(); - if (rootNode == nullptr) - continue; - - for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) { - if (std::strcmp(e->Name(), "FileInfo") != 0) + const auto handler = [&decls, &calls](const char* checkattr, const tinyxml2::XMLElement* e, const AnalyzerInformation::Info& filesTxtInfo) { + if (std::strcmp(checkattr,"CheckUnusedFunctions") != 0) + return; + for (const tinyxml2::XMLElement *e2 = e->FirstChildElement(); e2; e2 = e2->NextSiblingElement()) { + const char* functionName = e2->Attribute("functionName"); + if (functionName == nullptr) continue; - const char *checkattr = e->Attribute("check"); - if (checkattr == nullptr || std::strcmp(checkattr,"CheckUnusedFunctions") != 0) + const char* name = e2->Name(); + if (std::strcmp(name,"functioncall") == 0) { + calls.insert(functionName); continue; - for (const tinyxml2::XMLElement *e2 = e->FirstChildElement(); e2; e2 = e2->NextSiblingElement()) { - const char* functionName = e2->Attribute("functionName"); - if (functionName == nullptr) - continue; - const char* name = e2->Name(); - if (std::strcmp(name,"functioncall") == 0) { - calls.insert(functionName); - continue; - } - if (std::strcmp(name,"functiondecl") == 0) { - const char* lineNumber = e2->Attribute("lineNumber"); - if (lineNumber) { - const char* file = e2->Attribute("file"); - const char* column = default_if_null(e2->Attribute("column"), "0"); - // cppcheck-suppress templateInstantiation - TODO: fix this - see #11631 - decls[functionName] = Location(file ? file : sourcefile, strToInt(lineNumber), strToInt(column)); - } + } + if (std::strcmp(name,"functiondecl") == 0) { + const char* lineNumber = e2->Attribute("lineNumber"); + if (lineNumber) { + const char* file = e2->Attribute("file"); + const char* column = default_if_null(e2->Attribute("column"), "0"); + // cppcheck-suppress templateInstantiation - TODO: fix this - see #11631 + decls[functionName] = Location(file ? file : filesTxtInfo.sourceFile, strToInt(lineNumber), strToInt(column)); } } } - } + }; + + AnalyzerInformation::processFilesTxt(buildDir, handler); for (auto decl = decls.cbegin(); decl != decls.cend(); ++decl) { const std::string &functionName = stripTemplateParameters(decl->first); diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 0fb23203718..c7c6ea65dfc 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -70,10 +70,11 @@ #include #include "json.h" -#include "xml.h" #include +namespace tinyxml2 { class XMLElement; } + static constexpr char Version[] = CPPCHECK_VERSION_STRING; static constexpr char ExtraVersion[] = ""; @@ -1851,50 +1852,26 @@ unsigned int CppCheck::analyseWholeProgram(const std::string &buildDir, const st return mLogger->exitcode(); executeAddonsWholeProgram(files, fileSettings, ctuInfo); + std::list fileInfoList; CTU::FileInfo ctuFileInfo; - // Load all analyzer info data.. - const std::string filesTxt(buildDir + "/files.txt"); - std::ifstream fin(filesTxt); - std::string filesTxtLine; - while (std::getline(fin, filesTxtLine)) { - AnalyzerInformation::Info filesTxtInfo; - if (!filesTxtInfo.parse(filesTxtLine)) - continue; - - const std::string xmlfile = buildDir + '/' + filesTxtInfo.afile; - - tinyxml2::XMLDocument doc; - const tinyxml2::XMLError error = doc.LoadFile(xmlfile.c_str()); - if (error != tinyxml2::XML_SUCCESS) - continue; - - const tinyxml2::XMLElement * const rootNode = doc.FirstChildElement(); - if (rootNode == nullptr) - continue; - - for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) { - if (std::strcmp(e->Name(), "FileInfo") != 0) - continue; - const char *checkClassAttr = e->Attribute("check"); - if (!checkClassAttr) - continue; - if (std::strcmp(checkClassAttr, "ctu") == 0) { - ctuFileInfo.loadFromXml(e); - continue; - } - // cppcheck-suppress shadowFunction - TODO: fix this - for (const Check *check : Check::instances()) { - if (checkClassAttr == check->name()) { - if (Check::FileInfo* fi = check->loadFileInfoFromXml(e)) { - fi->file0 = filesTxtInfo.sourceFile; - fileInfoList.push_back(fi); - } + const auto handler = [&fileInfoList, &ctuFileInfo](const char* checkattr, const tinyxml2::XMLElement* e, const AnalyzerInformation::Info& filesTxtInfo) { + if (std::strcmp(checkattr, "ctu") == 0) { + ctuFileInfo.loadFromXml(e); + return; + } + for (const Check *check : Check::instances()) { + if (checkattr == check->name()) { + if (Check::FileInfo* fi = check->loadFileInfoFromXml(e)) { + fi->file0 = filesTxtInfo.sourceFile; + fileInfoList.push_back(fi); } } } - } + }; + + AnalyzerInformation::processFilesTxt(buildDir, handler); // Analyse the tokens // cppcheck-suppress shadowFunction - TODO: fix this diff --git a/lib/ctu.cpp b/lib/ctu.cpp index 158c8c1e046..df8ee0f74b6 100644 --- a/lib/ctu.cpp +++ b/lib/ctu.cpp @@ -231,6 +231,7 @@ bool CTU::FileInfo::NestedCall::loadFromXml(const tinyxml2::XMLElement *xmlEleme return !error; } +// TODO: bail out on unexpected data void CTU::FileInfo::loadFromXml(const tinyxml2::XMLElement *xmlElement) { for (const tinyxml2::XMLElement *e = xmlElement->FirstChildElement(); e; e = e->NextSiblingElement()) { diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index 02d2e7fbde2..ad7fb641024 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -245,7 +245,7 @@ $(libcppdir)/checktype.o: ../lib/checktype.cpp ../lib/addoninfo.h ../lib/astutil $(libcppdir)/checkuninitvar.o: ../lib/checkuninitvar.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkers.h ../lib/checknullpointer.h ../lib/checkuninitvar.h ../lib/config.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkuninitvar.cpp -$(libcppdir)/checkunusedfunctions.o: ../lib/checkunusedfunctions.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/astutils.h ../lib/checkers.h ../lib/checkunusedfunctions.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h +$(libcppdir)/checkunusedfunctions.o: ../lib/checkunusedfunctions.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/analyzerinfo.h ../lib/astutils.h ../lib/checkers.h ../lib/checkunusedfunctions.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkunusedfunctions.cpp $(libcppdir)/checkunusedvar.o: ../lib/checkunusedvar.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkers.h ../lib/checkunusedvar.h ../lib/config.h ../lib/errortypes.h ../lib/fwdanalysis.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/vfvalue.h @@ -260,7 +260,7 @@ $(libcppdir)/clangimport.o: ../lib/clangimport.cpp ../lib/addoninfo.h ../lib/che $(libcppdir)/color.o: ../lib/color.cpp ../lib/color.h ../lib/config.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/color.cpp -$(libcppdir)/cppcheck.o: ../lib/cppcheck.cpp ../externals/picojson/picojson.h ../externals/simplecpp/simplecpp.h ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/analyzerinfo.h ../lib/check.h ../lib/checkers.h ../lib/checkunusedfunctions.h ../lib/clangimport.h ../lib/color.h ../lib/config.h ../lib/cppcheck.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/filesettings.h ../lib/json.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/preprocessor.h ../lib/regex.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/timer.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/version.h ../lib/vfvalue.h ../lib/xml.h +$(libcppdir)/cppcheck.o: ../lib/cppcheck.cpp ../externals/picojson/picojson.h ../externals/simplecpp/simplecpp.h ../lib/addoninfo.h ../lib/analyzerinfo.h ../lib/check.h ../lib/checkers.h ../lib/checkunusedfunctions.h ../lib/clangimport.h ../lib/color.h ../lib/config.h ../lib/cppcheck.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/filesettings.h ../lib/json.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/preprocessor.h ../lib/regex.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/timer.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/version.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/cppcheck.cpp $(libcppdir)/ctu.o: ../lib/ctu.cpp ../externals/tinyxml2/tinyxml2.h ../lib/astutils.h ../lib/check.h ../lib/config.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h From 105ea18d115542b2b7d3d0435a8e59322dbd6580 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 10 Jan 2026 11:47:47 +0100 Subject: [PATCH 037/675] Fix #13706 fuzzing crash (assert) in TemplateSimplifier::TokenAndName::TokenAndName() (#8102) Co-authored-by: chrchr-github --- lib/templatesimplifier.cpp | 5 ++--- .../crash-5ac13e244448ff767f6596c220edb9ef7b61fa6d | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 test/cli/fuzz-crash/crash-5ac13e244448ff767f6596c220edb9ef7b61fa6d diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 349894b2b89..e7a096932cf 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -219,9 +219,8 @@ TemplateSimplifier::TokenAndName::TokenAndName(Token *token, std::string scope, } // make sure at most only one family flag is set - assert(isClass() ? !(isFunction() || isVariable()) : true); - assert(isFunction() ? !(isClass() || isVariable()) : true); - assert(isVariable() ? !(isClass() || isFunction()) : true); + if (isClass() + isFunction() + isVariable() > 1) + syntaxError(token); if (mToken) mToken->templateSimplifierPointer(this); diff --git a/test/cli/fuzz-crash/crash-5ac13e244448ff767f6596c220edb9ef7b61fa6d b/test/cli/fuzz-crash/crash-5ac13e244448ff767f6596c220edb9ef7b61fa6d new file mode 100644 index 00000000000..7bbc08cfd6d --- /dev/null +++ b/test/cli/fuzz-crash/crash-5ac13e244448ff767f6596c220edb9ef7b61fa6d @@ -0,0 +1 @@ +template<>struct t<>(); From 466839e79e2a44254142ba0358a3765ae2b3d818 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 10 Jan 2026 11:52:01 +0100 Subject: [PATCH 038/675] Fix #13705 fuzzing crash (null-pointer-use) in getEnumType() (#8103) Co-authored-by: chrchr-github --- lib/tokenize.cpp | 2 ++ .../fuzz-crash/crash-cd91802f0554ab425b82191389c9db2be0d50040 | 1 + 2 files changed, 3 insertions(+) create mode 100644 test/cli/fuzz-crash/crash-cd91802f0554ab425b82191389c9db2be0d50040 diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c5e810f1148..06cb0dbd426 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8955,6 +8955,8 @@ void Tokenizer::findGarbageCode() const if (Token::Match(tok, "!|~ %comp%") && !(cpp && tok->strAt(1) == ">" && Token::simpleMatch(tok->tokAt(-1), "operator"))) syntaxError(tok); + if (Token::Match(tok, "%comp% {") && (!cpp || tok->str() != ">")) + syntaxError(tok); if (Token::Match(tok, "] %name%") && (!cpp || !(tok->tokAt(1)->isKeyword() || (tok->tokAt(-1) && Token::simpleMatch(tok->tokAt(-2), "delete ["))))) { if (tok->next()->isUpperCaseName()) unknownMacroError(tok->next()); diff --git a/test/cli/fuzz-crash/crash-cd91802f0554ab425b82191389c9db2be0d50040 b/test/cli/fuzz-crash/crash-cd91802f0554ab425b82191389c9db2be0d50040 new file mode 100644 index 00000000000..b2a885a35d3 --- /dev/null +++ b/test/cli/fuzz-crash/crash-cd91802f0554ab425b82191389c9db2be0d50040 @@ -0,0 +1 @@ +{f F<{enum{E=1};}>} \ No newline at end of file From 19640019b704e9265c4fa77acf56a011ecbccabb Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 10 Jan 2026 12:33:00 +0100 Subject: [PATCH 039/675] Fix #13501 fuzzing crash (heap-use-after-free) in Tokenizer::simplifyNamespaceAliases() (#8101) Co-authored-by: chrchr-github --- lib/tokenize.cpp | 6 ++++-- .../crash-fb09b3314f55a502c8dd27f3f114122c71dd207e | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 test/cli/fuzz-crash/crash-fb09b3314f55a502c8dd27f3f114122c71dd207e diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 06cb0dbd426..7cb080e071f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9003,8 +9003,8 @@ void Tokenizer::findGarbageCode() const } } } - if (cpp && tok->str() == "namespace" && tok->tokAt(-1)) { - if (!Token::Match(tok->tokAt(-1), ";|{|}|using|inline")) { + if (cpp && tok->str() == "namespace") { + if (tok->tokAt(-1) && !Token::Match(tok->tokAt(-1), ";|{|}|using|inline")) { if (tok->tokAt(-1)->isUpperCaseName()) unknownMacroError(tok->tokAt(-1)); else if (tok->linkAt(-1) && tok->linkAt(-1)->tokAt(-1) && tok->linkAt(-1)->tokAt(-1)->isUpperCaseName()) @@ -9012,6 +9012,8 @@ void Tokenizer::findGarbageCode() const else syntaxError(tok); } + if (!tok->next() || (Token::Match(tok->next(), "%name% =") && !Token::Match(tok->tokAt(3), "::|%name%"))) + syntaxError(tok); } if (cpp && tok->str() == "using" && !Token::Match(tok->next(), "::|%name%")) syntaxError(tok); diff --git a/test/cli/fuzz-crash/crash-fb09b3314f55a502c8dd27f3f114122c71dd207e b/test/cli/fuzz-crash/crash-fb09b3314f55a502c8dd27f3f114122c71dd207e new file mode 100644 index 00000000000..3a017fdb2e0 --- /dev/null +++ b/test/cli/fuzz-crash/crash-fb09b3314f55a502c8dd27f3f114122c71dd207e @@ -0,0 +1 @@ +;namespace b=i;;namespace b={} From 34b9c45c4c67eb5dfa0aa99c0ce6198faaad4b18 Mon Sep 17 00:00:00 2001 From: clock999 Date: Sun, 11 Jan 2026 17:36:15 +0800 Subject: [PATCH 040/675] Fix #12861 Hang in valueFlowCondition() with huge array (#7757) I tested the fix based on 4617bc25d82ff8d46567e002995ad8f859d5e814. Use the cppcheck to check the below code which is submitted on the ticket #12861. ``` #define ROW A, A, A, A, A, A, A, A, #define ROW8 ROW ROW ROW ROW ROW ROW ROW ROW #define ROW64 ROW8 ROW8 ROW8 ROW8 ROW8 ROW8 ROW8 ROW8 #define ROW512 ROW64 ROW64 ROW64 ROW64 ROW64 ROW64 ROW64 ROW64 void f() { static const char A = 'a'; const char a[] = { ROW512 ROW512 ROW512 ROW512 }; } ``` With the fix, the overall time is 1.52582s. Without the fix, the time is 25.9674s. I also tested the testrunner for running the whole of the unit tests. There is some performance improment with the fix, but not remarkable. --- lib/token.h | 10 ++++++++++ lib/tokenlist.cpp | 10 ++++++++++ test/cli/performance_test.py | 23 +++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/lib/token.h b/lib/token.h index 5fddf510b19..d26c7ac7640 100644 --- a/lib/token.h +++ b/lib/token.h @@ -117,6 +117,7 @@ class CPPCHECKLIB Token { Token* mAstOperand1{}; Token* mAstOperand2{}; Token* mAstParent{}; + Token* mAstTop{}; // symbol database information const Scope* mScope{}; @@ -1557,6 +1558,9 @@ class CPPCHECKLIB Token { * @throws InternalError thrown on cyclic dependency */ void astParent(Token* tok); + void astTop(Token * tok) { + mImpl->mAstTop = tok; + } Token * astOperand1() { return mImpl->mAstOperand1; @@ -1597,6 +1601,9 @@ class CPPCHECKLIB Token { } RET_NONNULL Token *astTop() { + if (mImpl->mAstTop) { + return mImpl->mAstTop; + } Token *ret = this; while (ret->mImpl->mAstParent) ret = ret->mImpl->mAstParent; @@ -1604,6 +1611,9 @@ class CPPCHECKLIB Token { } RET_NONNULL const Token *astTop() const { + if (mImpl->mAstTop) { + return mImpl->mAstTop; + } const Token *ret = this; while (ret->mImpl->mAstParent) ret = ret->mImpl->mAstParent; diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 1e476a14ec5..7fccbb89f1d 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1860,6 +1860,16 @@ void TokenList::createAst() const throw InternalError(tok, "Syntax Error: Infinite loop when creating AST.", InternalError::AST); tok = nextTok; } + for (Token *tok = mTokensFrontBack->front; tok; tok = tok ? tok->next() : nullptr) { + if (tok->astParent()) + continue; + if (!tok->astOperand1() && !tok->astOperand2()) + continue; + visitAstNodes(tok, [&](Token* child) { + child->astTop(tok); + return ChildrenToVisit::op1_and_op2; + }); + } } namespace { diff --git a/test/cli/performance_test.py b/test/cli/performance_test.py index 9f5141f2bb9..90daf9b58cc 100644 --- a/test/cli/performance_test.py +++ b/test/cli/performance_test.py @@ -221,6 +221,7 @@ def test_slow_many_scopes(tmpdir): }""") cppcheck([filename]) # should not take more than ~1 second + @pytest.mark.skipif(sys.platform == 'darwin', reason='GitHub macOS runners are too slow') @pytest.mark.timeout(20) def test_crash_array_in_namespace(tmpdir): @@ -241,6 +242,28 @@ def test_crash_array_in_namespace(tmpdir): }""") cppcheck([filename]) # should not take more than ~5 seconds + +@pytest.mark.skipif(sys.platform == 'darwin', reason='GitHub macOS runners are too slow') +@pytest.mark.timeout(20) +def test_crash_array_in_array(tmpdir): + # 12861 + filename = os.path.join(tmpdir, 'hang.cpp') + with open(filename, 'wt') as f: + f.write(r""" + #define ROW A, A, A, A, A, A, A, A, + #define ROW8 ROW ROW ROW ROW ROW ROW ROW ROW + #define ROW64 ROW8 ROW8 ROW8 ROW8 ROW8 ROW8 ROW8 ROW8 + #define ROW512 ROW64 ROW64 ROW64 ROW64 ROW64 ROW64 ROW64 ROW64 + #define ROW4096 ROW512 ROW512 ROW512 ROW512 ROW512 ROW512 ROW512 ROW512 + void f() { + static const char A = 'a'; + const char a[] = { + ROW4096 ROW4096 ROW4096 ROW4096 + }; + }""") + cppcheck([filename]) + + @pytest.mark.timeout(5) def test_slow_bifurcate(tmpdir): # #14134 From 298d602e41c74d62bb571001cba0300a635e6186 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 12 Jan 2026 15:27:35 +0100 Subject: [PATCH 041/675] Fix #14388 cppcheck.natvis: TokenList visualization is broken [skip ci] (#8111) --- lib/cppcheck.natvis | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cppcheck.natvis b/lib/cppcheck.natvis index 4b3b2d0aea6..6f5b6fd86a2 100644 --- a/lib/cppcheck.natvis +++ b/lib/cppcheck.natvis @@ -10,13 +10,13 @@ - {mTokensFrontBack.front->mStr} - {mTokensFrontBack.back->mStr} + {mTokensFrontBack->front->mStr} - {mTokensFrontBack->back->mStr} mFiles - + - + pCurr @@ -68,4 +68,4 @@ - \ No newline at end of file + From a683c058ed585e171aa7530be19a742ea08c6192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 12 Jan 2026 18:21:46 +0100 Subject: [PATCH 042/675] Fix #14389 (triage: fix triage.pro file) (#8113) --- tools/triage/triage.pro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/triage/triage.pro b/tools/triage/triage.pro index 1bda43f40a7..213022968cd 100644 --- a/tools/triage/triage.pro +++ b/tools/triage/triage.pro @@ -1,8 +1,7 @@ -lessThan(QT_MAJOR_VERSION, 5): error(requires >= Qt 5 (You used: $$QT_VERSION)) QT += core gui widgets TARGET = triage TEMPLATE = app -QMAKE_CXXFLAGS += -std=c++11 +QMAKE_CXXFLAGS += -std=c++17 INCLUDEPATH += ../../gui MOC_DIR = temp OBJECTS_DIR = temp From db22e097baf769f8216f0c3b3db0f260ebba6bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 13 Jan 2026 02:16:44 +0100 Subject: [PATCH 043/675] some `Settings::premium` related cleanups (#8109) --- cli/cmdlineparser.cpp | 8 ++++---- cli/cmdlineparser.h | 2 +- lib/checkersreport.cpp | 6 +----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 47759b75196..48ac7e429d9 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -353,7 +353,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a return Result::Fail; if (argc <= 1) { - printHelp(mSettings.premium); + printHelp(); return Result::Exit; } @@ -388,7 +388,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a // Print help if (std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) { - printHelp(mSettings.premium); + printHelp(); return Result::Exit; } @@ -1700,7 +1700,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a return Result::Success; } -void CmdLineParser::printHelp(bool premium) const +void CmdLineParser::printHelp() const { std::ostringstream oss; // TODO: display product name @@ -1901,7 +1901,7 @@ void CmdLineParser::printHelp(bool premium) const " --plist-output=\n" " Generate Clang-plist output files in folder.\n"; - if (premium) { + if (mSettings.premium) { oss << " --premium=\n" ""; - /*const*/ Settings settings = settingsBuilder().libraryxml(xmldata).build(); + /*const*/ Settings settings = settingsBuilder().libraryxml(xmldata).severity(Severity::style).build(); check("void foo() {\n" " exit(0);\n" @@ -7456,7 +7453,7 @@ class TestOther : public TestFixture { " \n" " \n" ""; - /*const*/ Settings settings = settingsBuilder().libraryxml(xmldata).build(); + /*const*/ Settings settings = settingsBuilder().libraryxml(xmldata).severity(Severity::style).build(); check("void foo() {\n" " if (x() || x()) {}\n" @@ -8164,7 +8161,7 @@ class TestOther : public TestFixture { const char code[] = "void foo(bool flag) {\n" " bar( (flag) ? ~0u : ~0ul);\n" "}"; - /*const*/ Settings settings = settings0; + /*const*/ Settings settings = settings1; settings.platform.sizeof_int = 4; settings.platform.int_bit = 32; @@ -11932,6 +11929,19 @@ class TestOther : public TestFixture { errout_str()); } + void testUnusedLabelPremiumMisra() { // #14467 - enable unusedLabel with --premium=misra-c-20xx flag + Settings s; + check("void f() {\n" + " label:\n" + "}", dinit(CheckOptions, $.settings = &s)); + ASSERT_EQUALS("", errout_str()); + s.premiumArgs = "--premium=misra-c-2012"; // <- activates unusedLabel checking + check("void f() {\n" + " label:\n" + "}", dinit(CheckOptions, $.settings = &s)); + ASSERT_EQUALS("[test.cpp:2:5]: (style) Label 'label' is not used. [unusedLabel]\n", errout_str()); + } + // TODO: only used in a single place #define checkCustomSettings(...) checkCustomSettings_(__FILE__, __LINE__, __VA_ARGS__) template From d2c363fed20e74e935db81a9ba2706870676839e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 6 Feb 2026 16:00:22 +0100 Subject: [PATCH 105/675] moved `FileSettings::fileIndex` to `FileWithDetails::mFsFileId` / cleanups (#8104) to distinct it from `simplecpp::Location::fileIndex` --- Makefile | 2 +- gui/checkthread.cpp | 2 +- lib/analyzerinfo.cpp | 14 ++++----- lib/analyzerinfo.h | 6 ++-- lib/cppcheck.cpp | 53 ++++++++++++++++---------------- lib/cppcheck.h | 8 ++--- lib/filesettings.h | 24 ++++++++++++--- lib/importproject.cpp | 6 ++-- lib/summaries.cpp | 5 +-- lib/summaries.h | 2 +- oss-fuzz/Makefile | 2 +- test/testanalyzerinformation.cpp | 10 +++--- test/testimportproject.cpp | 4 +-- 13 files changed, 76 insertions(+), 62 deletions(-) diff --git a/Makefile b/Makefile index 3510d5ea7b1..37156d357af 100644 --- a/Makefile +++ b/Makefile @@ -649,7 +649,7 @@ $(libcppdir)/settings.o: lib/settings.cpp externals/picojson/picojson.h lib/addo $(libcppdir)/standards.o: lib/standards.cpp externals/simplecpp/simplecpp.h lib/config.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/standards.cpp -$(libcppdir)/summaries.o: lib/summaries.cpp lib/addoninfo.h lib/analyzerinfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h +$(libcppdir)/summaries.o: lib/summaries.cpp lib/addoninfo.h lib/analyzerinfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/summaries.cpp $(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/smallvector.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index 8f042068ee9..e10bf1ddf5a 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -238,7 +238,7 @@ void CheckThread::runAddonsAndTools(const Settings& settings, const FileSettings const std::string &buildDir = settings.buildDir; if (!buildDir.empty()) { - analyzerInfoFile = QString::fromStdString(AnalyzerInformation::getAnalyzerInfoFile(buildDir, fileSettings->filename(), fileSettings->cfg, fileSettings->fileIndex)); + analyzerInfoFile = QString::fromStdString(AnalyzerInformation::getAnalyzerInfoFile(buildDir, fileSettings->sfilename(), fileSettings->cfg, fileSettings->file.fsFileId())); QStringList args2(args); args2.insert(0,"-E"); diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index c7045252f3d..72857a9134f 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -69,7 +69,7 @@ std::string AnalyzerInformation::getFilesTxt(const std::list &sourc for (const FileSettings &fs : fileSettings) { const std::string afile = getFilename(fs.filename()); - const std::string id = fs.fileIndex > 0 ? std::to_string(fs.fileIndex) : ""; + const std::string id = fs.file.fsFileId() > 0 ? std::to_string(fs.file.fsFileId()) : ""; ret << afile << ".a" << (++fileCount[afile]) << sep << fs.cfg << sep << id << sep << Path::simplifyPath(fs.filename()) << std::endl; } @@ -127,11 +127,11 @@ std::string AnalyzerInformation::getAnalyzerInfoFileFromFilesTxt(std::istream& f return ""; } -std::string AnalyzerInformation::getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, int fileIndex) +std::string AnalyzerInformation::getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId) { std::ifstream fin(Path::join(buildDir, "files.txt")); if (fin.is_open()) { - const std::string& ret = getAnalyzerInfoFileFromFilesTxt(fin, sourcefile, cfg, fileIndex); + const std::string& ret = getAnalyzerInfoFileFromFilesTxt(fin, sourcefile, cfg, fsFileId); if (!ret.empty()) return Path::join(buildDir, ret); } @@ -145,13 +145,13 @@ std::string AnalyzerInformation::getAnalyzerInfoFile(const std::string &buildDir return Path::join(buildDir, std::move(filename)) + ".analyzerinfo"; } -bool AnalyzerInformation::analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, int fileIndex, std::size_t hash, std::list &errors) +bool AnalyzerInformation::analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId, std::size_t hash, std::list &errors) { if (buildDir.empty() || sourcefile.empty()) return true; close(); - const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(buildDir,sourcefile,cfg,fileIndex); + const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(buildDir,sourcefile,cfg,fsFileId); tinyxml2::XMLDocument analyzerInfoDoc; const tinyxml2::XMLError xmlError = analyzerInfoDoc.LoadFile(analyzerInfoFile.c_str()); @@ -191,10 +191,10 @@ bool AnalyzerInformation::Info::parse(const std::string& filesTxtLine) { return false; if (sep3 == sep2 + 1) - fileIndex = 0; + fsFileId = 0; else { try { - fileIndex = std::stoi(filesTxtLine.substr(sep2+1, sep3-sep2-1)); + fsFileId = std::stoi(filesTxtLine.substr(sep2+1, sep3-sep2-1)); } catch (const std::exception&) { return false; } diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 881076c09f4..19591f69e62 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -61,10 +61,10 @@ class CPPCHECKLIB AnalyzerInformation { /** Close current TU.analyzerinfo file */ void close(); - bool analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, int fileIndex, std::size_t hash, std::list &errors); + bool analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId, std::size_t hash, std::list &errors); void reportErr(const ErrorMessage &msg); void setFileInfo(const std::string &check, const std::string &fileInfo); - static std::string getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, int fileIndex); + static std::string getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId); static const char sep = ':'; @@ -73,7 +73,7 @@ class CPPCHECKLIB AnalyzerInformation { bool parse(const std::string& filesTxtLine); std::string afile; std::string cfg; - int fileIndex = 0; + std::size_t fsFileId = 0; std::string sourceFile; }; diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 399eb6d3d6e..de3bcd1530a 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -330,17 +330,17 @@ static std::vector split(const std::string &str, const std::string return ret; } -static std::string getDumpFileName(const Settings& settings, const std::string& filename, int fileIndex) +static std::string getDumpFileName(const Settings& settings, const FileWithDetails& file) { std::string extension = ".dump"; - if (fileIndex > 0) - extension = "." + std::to_string(fileIndex) + extension; + if (file.fsFileId() > 0) + extension = "." + std::to_string(file.fsFileId()) + extension; if (!settings.dump && settings.buildDir.empty()) extension = "." + std::to_string(settings.pid) + extension; if (!settings.dump && !settings.buildDir.empty()) - return AnalyzerInformation::getAnalyzerInfoFile(settings.buildDir, filename, "", fileIndex) + extension; - return filename + extension; + return AnalyzerInformation::getAnalyzerInfoFile(settings.buildDir, file.spath(), "", file.fsFileId()) + extension; + return file.spath() + extension; } static std::string getCtuInfoFileName(const std::string &dumpFile) @@ -350,13 +350,12 @@ static std::string getCtuInfoFileName(const std::string &dumpFile) static void createDumpFile(const Settings& settings, const FileWithDetails& file, - int fileIndex, std::ofstream& fdump, std::string& dumpFile) { if (!settings.dump && settings.addons.empty()) return; - dumpFile = getDumpFileName(settings, file.spath(), fileIndex); + dumpFile = getDumpFileName(settings, file); fdump.open(dumpFile); if (!fdump.is_open()) @@ -660,7 +659,7 @@ static std::string getClangFlags(const Settings& setting, Standards::Language la } // TODO: clear error list before returning -unsigned int CppCheck::checkClang(const FileWithDetails &file, int fileIndex) +unsigned int CppCheck::checkClang(const FileWithDetails &file) { // TODO: clear exitcode @@ -673,7 +672,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file, int fileIndex) // TODO: get language from FileWithDetails object std::string clangStderr; if (!mSettings.buildDir.empty()) - clangStderr = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, file.spath(), "", fileIndex) + ".clang-stderr"; + clangStderr = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, file.spath(), "", file.fsFileId()) + ".clang-stderr"; std::string exe = mSettings.clangExecutable; #ifdef _WIN32 @@ -747,7 +746,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file, int fileIndex) // create dumpfile std::ofstream fdump; std::string dumpFile; - createDumpFile(mSettings, file, fileIndex, fdump, dumpFile); + createDumpFile(mSettings, file, fdump, dumpFile); if (fdump.is_open()) { fdump << getLibraryDumpData(); // TODO: use tinyxml2 to create XML @@ -791,9 +790,9 @@ unsigned int CppCheck::check(const FileWithDetails &file) unsigned int returnValue; if (mSettings.clang) - returnValue = checkClang(file, 0); + returnValue = checkClang(file); else - returnValue = checkFile(file, "", 0); + returnValue = checkFile(file, ""); // TODO: call analyseClangTidy() @@ -802,7 +801,7 @@ unsigned int CppCheck::check(const FileWithDetails &file) unsigned int CppCheck::checkBuffer(const FileWithDetails &file, const char* data, std::size_t size) { - return checkBuffer(file, "", 0, data, size); + return checkBuffer(file, "", data, size); } unsigned int CppCheck::check(const FileSettings &fs) @@ -838,7 +837,7 @@ unsigned int CppCheck::check(const FileSettings &fs) } // need to pass the externally provided ErrorLogger instead of our internal wrapper CppCheck temp(tempSettings, mSuppressions, mErrorLoggerDirect, mTimerResults, mUseGlobalSuppressions, mExecuteCommand); - const unsigned int returnValue = temp.checkFile(fs.file, fs.cfg, fs.fileIndex); + const unsigned int returnValue = temp.checkFile(fs.file, fs.cfg); if (mUnusedFunctionsCheck) mUnusedFunctionsCheck->updateFunctionData(*temp.mUnusedFunctionsCheck); while (!temp.mFileInfo.empty()) { @@ -875,20 +874,20 @@ std::size_t CppCheck::calculateHash(const Preprocessor& preprocessor, const std: return preprocessor.calculateHash(toolinfo.str()); } -unsigned int CppCheck::checkBuffer(const FileWithDetails &file, const std::string &cfgname, int fileIndex, const char* data, std::size_t size) +unsigned int CppCheck::checkBuffer(const FileWithDetails &file, const std::string &cfgname, const char* data, std::size_t size) { const auto f = [&file, data, size](std::vector& files, simplecpp::OutputList* outputList) { return simplecpp::TokenList{{data, size}, files, file.spath(), outputList}; }; - return checkInternal(file, cfgname, fileIndex, f); + return checkInternal(file, cfgname, f); } -unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string &cfgname, int fileIndex) +unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string &cfgname) { const auto f = [&file](std::vector& files, simplecpp::OutputList* outputList) { return simplecpp::TokenList{file.spath(), files, outputList}; }; - return checkInternal(file, cfgname, fileIndex, f); + return checkInternal(file, cfgname, f); } void CppCheck::checkPlistOutput(const FileWithDetails& file, const std::vector& files) @@ -906,7 +905,7 @@ void CppCheck::checkPlistOutput(const FileWithDetails& file, const std::vectorsetAnalyzerInfo(nullptr); std::list errors; - analyzerInformation->analyzeFile(mSettings.buildDir, file.spath(), cfgname, fileIndex, hash, errors); + analyzerInformation->analyzeFile(mSettings.buildDir, file.spath(), cfgname, file.fsFileId(), hash, errors); analyzerInformation->setFileInfo("CheckUnusedFunctions", mUnusedFunctionsCheck->analyzerInfo(tokenizer)); analyzerInformation->close(); } @@ -1020,7 +1019,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str // Calculate hash so it can be compared with old hash / future hashes const std::size_t hash = calculateHash(preprocessor, file.spath()); std::list errors; - if (!analyzerInformation->analyzeFile(mSettings.buildDir, file.spath(), cfgname, fileIndex, hash, errors)) { + if (!analyzerInformation->analyzeFile(mSettings.buildDir, file.spath(), cfgname, file.fsFileId(), hash, errors)) { while (!errors.empty()) { mErrorLogger.reportErr(errors.front()); errors.pop_front(); @@ -1077,7 +1076,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str // write dump file xml prolog std::ofstream fdump; std::string dumpFile; - createDumpFile(mSettings, file, fileIndex, fdump, dumpFile); + createDumpFile(mSettings, file, fdump, dumpFile); if (fdump.is_open()) { fdump << getLibraryDumpData(); fdump << dumpProlog; @@ -1200,7 +1199,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str #endif // Simplify tokens into normal form, skip rest of iteration if failed - if (!tokenizer.simplifyTokens1(currentConfig, fileIndex)) + if (!tokenizer.simplifyTokens1(currentConfig, file.fsFileId())) continue; // dump xml if --dump @@ -1631,12 +1630,12 @@ void CppCheck::executeAddonsWholeProgram(const std::list &files std::vector ctuInfoFiles; for (const auto &f: files) { - const std::string &dumpFileName = getDumpFileName(mSettings, f.path(), 0); + const std::string &dumpFileName = getDumpFileName(mSettings, f); ctuInfoFiles.push_back(getCtuInfoFileName(dumpFileName)); } - for (const auto &f: fileSettings) { - const std::string &dumpFileName = getDumpFileName(mSettings, f.filename(), f.fileIndex); + for (const auto &fs: fileSettings) { + const std::string &dumpFileName = getDumpFileName(mSettings, fs.file); ctuInfoFiles.push_back(getCtuInfoFileName(dumpFileName)); } @@ -1748,7 +1747,7 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings) std::string line; if (!mSettings.buildDir.empty()) { - const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, fileSettings.filename(), "", fileSettings.fileIndex); + const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, fileSettings.sfilename(), "", fileSettings.file.fsFileId()); std::ofstream fcmd(analyzerInfoFile + ".clang-tidy-cmd"); fcmd << istr.str(); } diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 22423689cdf..868100df170 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -179,7 +179,7 @@ class CPPCHECKLIB CppCheck { * @param cfgname cfg name * @return number of errors found */ - unsigned int checkFile(const FileWithDetails& file, const std::string &cfgname, int fileIndex); + unsigned int checkFile(const FileWithDetails& file, const std::string &cfgname); void checkPlistOutput(const FileWithDetails& file, const std::vector& files); @@ -191,7 +191,7 @@ class CPPCHECKLIB CppCheck { * @param size the size of the data to be read * @return number of errors found */ - unsigned int checkBuffer(const FileWithDetails& file, const std::string &cfgname, int fileIndex, const char* data, std::size_t size); + unsigned int checkBuffer(const FileWithDetails& file, const std::string &cfgname, const char* data, std::size_t size); // TODO: should use simplecpp::OutputList using CreateTokenListFn = std::function&, std::list*)>; @@ -203,7 +203,7 @@ class CPPCHECKLIB CppCheck { * @param createTokenList a function to create the simplecpp::TokenList with * @return number of errors found */ - unsigned int checkInternal(const FileWithDetails& file, const std::string &cfgname, int fileIndex, const CreateTokenListFn& createTokenList); + unsigned int checkInternal(const FileWithDetails& file, const std::string &cfgname, const CreateTokenListFn& createTokenList); /** * @brief Check normal tokens @@ -232,7 +232,7 @@ class CPPCHECKLIB CppCheck { void executeRules(const std::string &tokenlist, const TokenList &list); #endif - unsigned int checkClang(const FileWithDetails &file, int fileIndex); + unsigned int checkClang(const FileWithDetails &file); const Settings& mSettings; Suppressions& mSuppressions; diff --git a/lib/filesettings.h b/lib/filesettings.h index 3149421c629..5a5ece9366b 100644 --- a/lib/filesettings.h +++ b/lib/filesettings.h @@ -35,15 +35,20 @@ class FileWithDetails { public: FileWithDetails(std::string path, Standards::Language lang, std::size_t size) - : mPath(std::move(path)) - , mPathSimplified(Path::simplifyPath(mPath)) - , mLang(lang) + : mLang(lang) , mSize(size) { + setPath(std::move(path)); if (mPath.empty()) throw std::runtime_error("empty path specified"); } + void setPath(std::string path) + { + mPath = std::move(path); + mPathSimplified = Path::simplifyPath(mPath); + } + const std::string& path() const { return mPath; @@ -68,11 +73,22 @@ class FileWithDetails { return mLang; } + + std::size_t fsFileId() const + { + return mFsFileId; + } + + void setFsFileId(std::size_t fsFileId) + { + mFsFileId = fsFileId; + } private: std::string mPath; std::string mPathSimplified; Standards::Language mLang = Standards::Language::None; std::size_t mSize; + std::size_t mFsFileId{0}; }; /** File settings. Multiple configurations for a file is allowed. */ @@ -81,14 +97,12 @@ struct CPPCHECKLIB FileSettings { : file(std::move(path), lang, size) {} - int fileIndex = 0; std::string cfg; FileWithDetails file; const std::string& filename() const { return file.path(); } - // cppcheck-suppress unusedFunction const std::string& sfilename() const { return file.spath(); diff --git a/lib/importproject.cpp b/lib/importproject.cpp index a5ac78b3107..1268c39d3c9 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -362,7 +362,7 @@ bool ImportProject::importCompileCommands(std::istream &istr) return false; } - std::map fileIndex; + std::map fsFileIds; for (const picojson::value &fileInfo : compileCommands.get()) { picojson::object obj = fileInfo.get(); @@ -445,7 +445,7 @@ bool ImportProject::importCompileCommands(std::istream &istr) fsSetIncludePaths(fs, directory, fs.includePaths, variables); // Assign a unique index to each file path. If the file path already exists in the map, // increment the index to handle duplicate file entries. - fs.fileIndex = fileIndex[path]++; + fs.file.setFsFileId(fsFileIds[path]++); fileSettings.push_back(std::move(fs)); } @@ -1563,7 +1563,7 @@ void ImportProject::setRelativePaths(const std::string &filename) return; const std::vector basePaths{Path::fromNativeSeparators(Path::getCurrentPath())}; for (auto &fs: fileSettings) { - fs.file = FileWithDetails{Path::getRelativePath(fs.filename(), basePaths), Standards::Language::None, 0}; // file will be identified later on + fs.file.setPath(Path::getRelativePath(fs.filename(), basePaths)); for (auto &includePath: fs.includePaths) includePath = Path::getRelativePath(includePath, basePaths); } diff --git a/lib/summaries.cpp b/lib/summaries.cpp index a543fcc7065..52a5d06b141 100644 --- a/lib/summaries.cpp +++ b/lib/summaries.cpp @@ -19,6 +19,7 @@ #include "summaries.h" #include "analyzerinfo.h" +#include "path.h" #include "settings.h" #include "symboldatabase.h" #include "token.h" @@ -34,7 +35,7 @@ -std::string Summaries::create(const Tokenizer &tokenizer, const std::string &cfg, int fileIndex) +std::string Summaries::create(const Tokenizer &tokenizer, const std::string &cfg, std::size_t fsFileId) { const SymbolDatabase *symbolDatabase = tokenizer.getSymbolDatabase(); const Settings &settings = tokenizer.getSettings(); @@ -82,7 +83,7 @@ std::string Summaries::create(const Tokenizer &tokenizer, const std::string &cfg } if (!settings.buildDir.empty()) { - std::string filename = AnalyzerInformation::getAnalyzerInfoFile(settings.buildDir, tokenizer.list.getSourceFilePath(), cfg, fileIndex); + std::string filename = AnalyzerInformation::getAnalyzerInfoFile(settings.buildDir, Path::simplifyPath(tokenizer.list.getSourceFilePath()), cfg, fsFileId); const std::string::size_type pos = filename.rfind(".a"); if (pos != std::string::npos) { filename[pos+1] = 's'; diff --git a/lib/summaries.h b/lib/summaries.h index ac3d40d840f..a7a314da9a8 100644 --- a/lib/summaries.h +++ b/lib/summaries.h @@ -29,7 +29,7 @@ class Tokenizer; namespace Summaries { - CPPCHECKLIB std::string create(const Tokenizer &tokenizer, const std::string &cfg, int fileIndex); + CPPCHECKLIB std::string create(const Tokenizer &tokenizer, const std::string &cfg, std::size_t fsFileId); CPPCHECKLIB void loadReturn(const std::string &buildDir, std::set &summaryReturn); } diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index 196e0994d5f..5055ba71a8e 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -329,7 +329,7 @@ $(libcppdir)/settings.o: ../lib/settings.cpp ../externals/picojson/picojson.h .. $(libcppdir)/standards.o: ../lib/standards.cpp ../externals/simplecpp/simplecpp.h ../lib/config.h ../lib/standards.h ../lib/utils.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/standards.cpp -$(libcppdir)/summaries.o: ../lib/summaries.cpp ../lib/addoninfo.h ../lib/analyzerinfo.h ../lib/checkers.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/summaries.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h +$(libcppdir)/summaries.o: ../lib/summaries.cpp ../lib/addoninfo.h ../lib/analyzerinfo.h ../lib/checkers.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/summaries.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/summaries.cpp $(libcppdir)/suppressions.o: ../lib/suppressions.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/checkers.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/filesettings.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/pathmatch.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/standards.h ../lib/suppressions.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h diff --git a/test/testanalyzerinformation.cpp b/test/testanalyzerinformation.cpp index 13dd721f0a4..fa4c4ddfaf4 100644 --- a/test/testanalyzerinformation.cpp +++ b/test/testanalyzerinformation.cpp @@ -59,9 +59,9 @@ class TestAnalyzerInformation : public TestFixture { void filesTextDuplicateFile() const { std::list fileSettings; fileSettings.emplace_back("a.c", Standards::Language::C, 10); - fileSettings.back().fileIndex = 0; + fileSettings.back().file.setFsFileId(0); fileSettings.emplace_back("a.c", Standards::Language::C, 10); - fileSettings.back().fileIndex = 1; + fileSettings.back().file.setFsFileId(1); const char expected[] = "a.a1:::a.c\n" "a.a2::1:a.c\n"; @@ -90,19 +90,19 @@ class TestAnalyzerInformation : public TestFixture { ASSERT_EQUALS(true, info.parse("a:b::d")); ASSERT_EQUALS("a", info.afile); ASSERT_EQUALS("b", info.cfg); - ASSERT_EQUALS(0, info.fileIndex); + ASSERT_EQUALS(0, info.fsFileId); ASSERT_EQUALS("d", info.sourceFile); ASSERT_EQUALS(true, info.parse("e:f:12:g")); ASSERT_EQUALS("e", info.afile); ASSERT_EQUALS("f", info.cfg); - ASSERT_EQUALS(12, info.fileIndex); + ASSERT_EQUALS(12, info.fsFileId); ASSERT_EQUALS("g", info.sourceFile); ASSERT_EQUALS(true, info.parse("odr1.a1:::C:/dm/cppcheck-fix-13333/test/cli/whole-program/odr1.cpp")); ASSERT_EQUALS("odr1.a1", info.afile); ASSERT_EQUALS("", info.cfg); - ASSERT_EQUALS(0, info.fileIndex); + ASSERT_EQUALS(0, info.fsFileId); ASSERT_EQUALS("C:/dm/cppcheck-fix-13333/test/cli/whole-program/odr1.cpp", info.sourceFile); } diff --git a/test/testimportproject.cpp b/test/testimportproject.cpp index 799f31d1bec..9e4b04abe94 100644 --- a/test/testimportproject.cpp +++ b/test/testimportproject.cpp @@ -371,8 +371,8 @@ class TestImportProject : public TestFixture { ASSERT_EQUALS(2, importer.fileSettings.size()); const FileSettings &fs1 = importer.fileSettings.front(); const FileSettings &fs2 = importer.fileSettings.back(); - ASSERT_EQUALS(0, fs1.fileIndex); - ASSERT_EQUALS(1, fs2.fileIndex); + ASSERT_EQUALS(0, fs1.file.fsFileId()); + ASSERT_EQUALS(1, fs2.file.fsFileId()); } void importCompileCommands14() const { // #14156 From 792a761add7e18736d79b582df719c13dc026ad2 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 6 Feb 2026 16:43:10 +0100 Subject: [PATCH 106/675] Fix #14465 duplicated returnDanglingLifetime (#8184) Co-authored-by: chrchr-github --- lib/checkautovariables.cpp | 3 ++- test/testautovariables.cpp | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index bc18c3dc477..867758a3210 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -617,7 +617,8 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token if ((tokvalue->variable() && !isEscapedReference(tokvalue->variable()) && isInScope(tokvalue->variable()->nameToken(), scope)) || isDeadTemporary(tokvalue, nullptr, mSettings->library)) { - errorReturnDanglingLifetime(tok, &val); + if (!diag(tokvalue)) + errorReturnDanglingLifetime(tok, &val); break; } } else if (tokvalue->variable() && isDeadScope(tokvalue->variable()->nameToken(), tok->scope())) { diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 1091a03e9ff..573f29c0d48 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -2643,8 +2643,7 @@ class TestAutoVariables : public TestFixture { " auto it = g().begin();\n" " return it;\n" "}"); - ASSERT_EQUALS("[test.cpp:3:24] -> [test.cpp:3:16] -> [test.cpp:4:5]: (error) Using iterator that is a temporary. [danglingTemporaryLifetime]\n" - "[test.cpp:3:24] -> [test.cpp:4:12]: (error) Returning iterator that will be invalid when returning. [returnDanglingLifetime]\n", + ASSERT_EQUALS("[test.cpp:3:24] -> [test.cpp:3:16] -> [test.cpp:4:5]: (error) Using iterator that is a temporary. [danglingTemporaryLifetime]\n", errout_str()); check("std::vector g();\n" @@ -3142,6 +3141,14 @@ class TestAutoVariables : public TestFixture { ASSERT_EQUALS( "[test.cpp:3:12] -> [test.cpp:2:10] -> [test.cpp:3:12]: (error) Returning pointer to local variable 'a' that will be invalid when returning. [returnDanglingLifetime]\n", errout_str()); + + check("std::string_view f() {\n" // #14465 + " std::vector v;\n" + " return *v.begin();\n" + "}\n"); + ASSERT_EQUALS( + "[test.cpp:3:12] -> [test.cpp:3:12]: (error) Returning object that will be invalid when returning. [returnDanglingLifetime]\n", + errout_str()); } void danglingLifetimeUniquePtr() From cc24161b6cff8b1033877166117827e5a5c54848 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 6 Feb 2026 16:44:41 +0100 Subject: [PATCH 107/675] Fix #13671 duplicated unreadVariable with assignment in variable declaration (#8139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: chrchr-github Co-authored-by: Daniel Marjamäki --- lib/checkunusedvar.cpp | 7 +- samples/unreadVariable/out.txt | 3 - test/testunusedvar.cpp | 122 +++++++++++---------------------- 3 files changed, 46 insertions(+), 86 deletions(-) diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index ddaffa0f817..5819eed715e 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1198,6 +1198,7 @@ void CheckUnusedVar::checkFunctionVariableUsage() const Token *nextStructuredBindingTok = nullptr; std::vector> unusedStructuredBindingTokens; size_t structuredBindingTokCount = 0; + std::set diagUnreadVariable; // prevent duplicate warnings for (const Token *tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) { if (nextStructuredBindingTok) { @@ -1366,8 +1367,10 @@ void CheckUnusedVar::checkFunctionVariableUsage() if (!expr->variable() || !expr->variable()->isMaybeUnused()) { if (structuredBindingTokCount > 0) unusedStructuredBindingTokens.emplace_back(tok, expr); - else + else { unreadVariableError(tok, expr->expressionString(), false); + diagUnreadVariable.emplace(expr->variable()); + } } } } @@ -1420,7 +1423,7 @@ void CheckUnusedVar::checkFunctionVariableUsage() !(var->valueType() && var->valueType()->container) && !(var->isStatic() && isReturnedByRef(var, scope->function))) unassignedVariableError(usage._var->nameToken(), varname); - else if (!usage._var->isMaybeUnused() && !usage._modified && !usage._read && var) { + else if (!usage._var->isMaybeUnused() && !usage._modified && !usage._read && var && diagUnreadVariable.count(usage._var) == 0) { const Token* vnt = var->nameToken(); bool error = false; if (vnt->next()->isSplittedVarDeclEq() || (!var->isReference() && vnt->strAt(1) == "=")) { diff --git a/samples/unreadVariable/out.txt b/samples/unreadVariable/out.txt index 2b1c295a8c6..1797e13dbbe 100644 --- a/samples/unreadVariable/out.txt +++ b/samples/unreadVariable/out.txt @@ -1,6 +1,3 @@ samples\unreadVariable\bad.cpp:5:34: style: Variable 's2' is assigned a value that is never used. [unreadVariable] std::string s1 = "test1", s2 = "test2"; ^ -samples\unreadVariable\bad.cpp:5:31: style: Variable 's2' is assigned a value that is never used. [unreadVariable] - std::string s1 = "test1", s2 = "test2"; - ^ diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 741f9b70b24..0a676d00218 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -2156,8 +2156,7 @@ class TestUnusedVar : public TestFixture { " int i = 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2233,8 +2232,7 @@ class TestUnusedVar : public TestFixture { " bool i = false;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:10]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2242,8 +2240,7 @@ class TestUnusedVar : public TestFixture { " bool i = true;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:10]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2266,8 +2263,7 @@ class TestUnusedVar : public TestFixture { "}\n", dinit(FunctionVariableUsageOptions, $.cpp = false)); ASSERT_EQUALS( - "[test.c:3:17]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.c:3:15]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.c:3:17]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2275,8 +2271,7 @@ class TestUnusedVar : public TestFixture { " int i = undefined;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2284,8 +2279,7 @@ class TestUnusedVar : public TestFixture { " int * i = Data;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2293,8 +2287,7 @@ class TestUnusedVar : public TestFixture { " void * i = Data;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:14]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:12]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:14]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2302,8 +2295,7 @@ class TestUnusedVar : public TestFixture { " const void * i = Data;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:20]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:18]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:20]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2311,8 +2303,7 @@ class TestUnusedVar : public TestFixture { " struct S * i = DATA;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:18]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:16]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:18]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2320,8 +2311,7 @@ class TestUnusedVar : public TestFixture { " const struct S * i = DATA;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:24]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:22]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:24]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2341,8 +2331,7 @@ class TestUnusedVar : public TestFixture { " undefined * i = X;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:19]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:17]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:19]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2351,8 +2340,7 @@ class TestUnusedVar : public TestFixture { " int j = i;\n" "}"); ASSERT_EQUALS( - "[test.cpp:4:11]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:9]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:11]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2378,8 +2366,7 @@ class TestUnusedVar : public TestFixture { " char *i = \"123456789\";\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2387,8 +2374,7 @@ class TestUnusedVar : public TestFixture { " int i = 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -2624,8 +2610,7 @@ class TestUnusedVar : public TestFixture { " int i = 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:2:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:2:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:2:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // extracttests.enable } @@ -3081,8 +3066,7 @@ class TestUnusedVar : public TestFixture { "}"); ASSERT_EQUALS("[test.cpp:7:15]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" "[test.cpp:3:9]: (style) Unused variable: i [unusedVariable]\n" - "[test.cpp:5:13]: (style) Unused variable: i [unusedVariable]\n" - "[test.cpp:7:13]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:5:13]: (style) Unused variable: i [unusedVariable]\n", errout_str()); functionVariableUsage("void foo(int x)\n" @@ -3730,8 +3714,7 @@ class TestUnusedVar : public TestFixture { " const std::string x = Bar();\n" // <- warning "}"); ASSERT_EQUALS( - "[test.cpp:16:25]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:16:23]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:16:25]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } @@ -3915,8 +3898,7 @@ class TestUnusedVar : public TestFixture { " return i;\n" "}\n"); ASSERT_EQUALS( - "[test.cpp:2:18]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:2:16]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:2:18]: (style) Variable 'j' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("int f() {\n" @@ -3924,8 +3906,7 @@ class TestUnusedVar : public TestFixture { " return j;\n" "}\n"); ASSERT_EQUALS( - "[test.cpp:2:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:2:9]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:2:11]: (style) Variable 'i' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f() {\n" // #10846 @@ -4172,8 +4153,7 @@ class TestUnusedVar : public TestFixture { " int *b = &a;\n" "}"); ASSERT_EQUALS("[test.cpp:4:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n" - "[test.cpp:4:10]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -4182,8 +4162,7 @@ class TestUnusedVar : public TestFixture { " int *b = a;\n" "}"); ASSERT_EQUALS("[test.cpp:4:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n" - "[test.cpp:4:10]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -4263,8 +4242,7 @@ class TestUnusedVar : public TestFixture { " int *b = &a;\n" "}"); ASSERT_EQUALS( - "[test.cpp:4:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:10]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // a is not a local variable and b is aliased to it @@ -4273,8 +4251,7 @@ class TestUnusedVar : public TestFixture { " int *b = &a;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:10]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:12]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // a is not a local variable and b is aliased to it @@ -4287,8 +4264,7 @@ class TestUnusedVar : public TestFixture { " }\n" "};"); ASSERT_EQUALS( - "[test.cpp:6:16]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:6:14]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:6:16]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("int a;\n" @@ -4497,8 +4473,7 @@ class TestUnusedVar : public TestFixture { " *d = 0;\n" "}"); ASSERT_EQUALS("[test.cpp:5:12]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n" - "[test.cpp:5:10]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:9]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -4544,8 +4519,7 @@ class TestUnusedVar : public TestFixture { "}"); TODO_ASSERT_EQUALS( "[test.cpp:4:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", - "[test.cpp:5:13]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:5:11]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:5:13]: (style) Variable 'c' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo()\n" @@ -4602,8 +4576,7 @@ class TestUnusedVar : public TestFixture { " struct S * s = (struct S *)a;\n" "}"); ASSERT_EQUALS("[test.cpp:5:18]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n" - "[test.cpp:5:16]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("struct S { char c[100]; };\n" @@ -4613,8 +4586,7 @@ class TestUnusedVar : public TestFixture { " const struct S * s = (const struct S *)a;\n" "}"); ASSERT_EQUALS("[test.cpp:5:24]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n" - "[test.cpp:5:22]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("struct S { char c[100]; };\n" @@ -4624,8 +4596,7 @@ class TestUnusedVar : public TestFixture { " struct S * s = static_cast(a);\n" "}"); ASSERT_EQUALS("[test.cpp:5:18]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n" - "[test.cpp:5:16]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("struct S { char c[100]; };\n" @@ -4635,8 +4606,7 @@ class TestUnusedVar : public TestFixture { " const struct S * s = static_cast(a);\n" "}"); ASSERT_EQUALS("[test.cpp:5:24]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n" - "[test.cpp:5:22]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:10]: (style) Unused variable: a [unusedVariable]\n", errout_str()); functionVariableUsage("int a[10];\n" @@ -4696,8 +4666,7 @@ class TestUnusedVar : public TestFixture { " int * a = &ab.a;\n" "}"); ASSERT_EQUALS( - "[test.cpp:4:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:11]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("struct AB { int a; int b; } ab;\n" @@ -4715,8 +4684,7 @@ class TestUnusedVar : public TestFixture { " int * a = &ab.a;\n" "}"); ASSERT_EQUALS("[test.cpp:5:13]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:15]: (style) Variable 'ab' is not assigned a value. [unassignedVariable]\n" - "[test.cpp:5:11]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:15]: (style) Variable 'ab' is not assigned a value. [unassignedVariable]\n", errout_str()); functionVariableUsage("struct AB { int a; int b; };\n" @@ -5338,8 +5306,7 @@ class TestUnusedVar : public TestFixture { " struct ABC abc = { 1, 2, 3 };\n" "}"); ASSERT_EQUALS( - "[test.cpp:4:20]: (style) Variable 'abc' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:4:16]: (style) Variable 'abc' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:4:20]: (style) Variable 'abc' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } @@ -5399,8 +5366,7 @@ class TestUnusedVar : public TestFixture { " return 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:9]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:9]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // extracttests.disable @@ -5410,8 +5376,7 @@ class TestUnusedVar : public TestFixture { " return 0;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:9]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:7]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:9]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n", errout_str()); // extracttests.enable @@ -5701,8 +5666,7 @@ class TestUnusedVar : public TestFixture { " return 1;\n" "}"); ASSERT_EQUALS( - "[test.cpp:3:15]: (style) Variable 'y' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:3:13]: (style) Variable 'y' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:3:15]: (style) Variable 'y' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("int foo(int x)\n" @@ -6372,16 +6336,14 @@ class TestUnusedVar : public TestFixture { " std::string s = \"foo\";\n" "}"); ASSERT_EQUALS( - "[test.cpp:2:19]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:2:17]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:2:19]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void foo() {\n" // #8901 " const std::string s = \"foo\";\n" "}"); ASSERT_EQUALS( - "[test.cpp:2:25]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:2:23]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:2:25]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("std::string foo() {\n" @@ -6421,8 +6383,7 @@ class TestUnusedVar : public TestFixture { " const bool b = true;\n" "}"); ASSERT_EQUALS( - "[test.cpp:2:18]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:2:16]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:2:18]: (style) Variable 'b' is assigned a value that is never used. [unreadVariable]\n", errout_str()); } @@ -6566,8 +6527,7 @@ class TestUnusedVar : public TestFixture { " std::string x = foo();\n" "}"); ASSERT_EQUALS( - "[test.cpp:2:19]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:2:17]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:2:19]: (style) Variable 'x' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void f() {\n" @@ -6708,7 +6668,7 @@ class TestUnusedVar : public TestFixture { " auto a2 = std::unique_ptr(new A());\n" "}\n"); ASSERT_EQUALS("[test.cpp:7:12]: (style) Variable 'a' is assigned a value that is never used. [unreadVariable]\n" - "[test.cpp:8:13]: (style) Variable 'a2' is assigned a value that is never used. [unreadVariable]\n", // duplicate + "[test.cpp:8:13]: (style) Variable 'a2' is assigned a value that is never used. [unreadVariable]\n", errout_str()); functionVariableUsage("void g();\n" // #11094 From dad374cb2a9f0be605a6355b3129de99fc6cc0c4 Mon Sep 17 00:00:00 2001 From: Reshma V Kumar Date: Fri, 6 Feb 2026 23:11:53 +0530 Subject: [PATCH 108/675] CheckClass: renamed `Bool` enum values (#8187) In AIX, TRUE and FALSE are already defined in AIX system header files. As a result, compiling cppcheck in AIX fails with the following errors: ``` /home/buildusr/cppcheck/lib/checkclass.h:231:38: error: expected identifier before numeric constant 231 | enum class Bool : std::uint8_t { TRUE, FALSE, BAILOUT }; | ^~~~ /home/buildusr/cppcheck/lib/checkclass.h:231:38: error: expected '}' before numeric constant In file included from /home/buildusr/cppcheck/lib/astutils.cpp:37: /home/buildusr/cppcheck/lib/checkclass.h:231:36: note: to match this '{' 231 | enum class Bool : std::uint8_t { TRUE, FALSE, BAILOUT }; | ^ In file included from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include-fixed/wchar.h:50, from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/cwchar:44, from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/bits/postypes.h:40, from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/bits/char_traits.h:40, from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/10/include/c++/string:40, from /home/buildusr/cppcheck/lib/matchcompiler.h:23, from /home/buildusr/cppcheck/build/lib/build/mc_astutils.cpp:1: /home/buildusr/cppcheck/lib/checkclass.h:231:38: error: expected unqualified-id before numeric constant 231 | enum class Bool : std::uint8_t { TRUE, FALSE, BAILOUT }; | ^~~~ In file included from /home/buildusr/cppcheck/lib/astutils.cpp:37: /home/buildusr/cppcheck/lib/checkclass.h:232:12: error: 'Bool' does not name a type; did you mean 'bool'? 232 | static Bool isInverted(const Token *tok, const Token *rhs); | ^~~~ | bool /home/buildusr/cppcheck/lib/checkclass.h:236:60: error: non-member function 'bool isMemberVar(const Scope*, const Token*)' cannot have cv-qualifier 236 | bool isMemberVar(const Scope *scope, const Token *tok) const; | ^~~~~ /home/buildusr/cppcheck/lib/checkclass.h:240:97: error: non-member function 'bool checkConstFunc(const Scope*, const Function*, MemberAccess&)' cannot have cv-qualifier 240 | bool checkConstFunc(const Scope *scope, const Function *func, MemberAccess& memberAccessed) const; | ^~~~~ /home/buildusr/cppcheck/lib/checkclass.h:313:137: error: non-member function 'void initializeVarList(const Function&, std::__cxx11::list&, const Scope*, std::vector&)' cannot have cv-qualifier 313 | void initializeVarList(const Function &func, std::list &callstack, const Scope *scope, std::vector &usage) const; | ^~~~~ /home/buildusr/cppcheck/lib/checkclass.h:344:1: error: expected declaration before '}' token 344 | }; | ^ ``` In this PR, TRUE and FALSE is being renamed to True and False to resolve this issue. Please let me know your suggestions or concerns on these changes. --- lib/checkclass.cpp | 12 ++++++------ lib/checkclass.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 30cc582651c..f56c799b247 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1872,12 +1872,12 @@ CheckClass::Bool CheckClass::isInverted(const Token *tok, const Token *rhs) || (Token::simpleMatch(itr->astOperand2(), "this") && Token::simpleMatch(itr->astOperand1(), "&") && Token::simpleMatch(itr->astOperand1()->next(), rhs->str().c_str(), rhs->str().size())))) { //Do nothing } else { - return Bool::BAILOUT; + return Bool::Bailout; } } if (res) - return Bool::TRUE; - return Bool::FALSE; + return Bool::True; + return Bool::False; } const Token * CheckClass::getIfStmtBodyStart(const Token *tok, const Token *rhs) @@ -1885,11 +1885,11 @@ const Token * CheckClass::getIfStmtBodyStart(const Token *tok, const Token *rhs) const Token *top = tok->astTop(); if (Token::simpleMatch(top->link(), ") {")) { switch (isInverted(tok->astParent(), rhs)) { - case Bool::BAILOUT: + case Bool::Bailout: return nullptr; - case Bool::TRUE: + case Bool::True: return top->link()->next(); - case Bool::FALSE: + case Bool::False: return top->link()->linkAt(1); } } diff --git a/lib/checkclass.h b/lib/checkclass.h index 130f6ffd781..3b49861126a 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -228,7 +228,7 @@ class CPPCHECKLIB CheckClass : public Check { bool hasAllocation(const Function *func, const Scope* scope, const Token *start, const Token *end) const; bool hasAllocationInIfScope(const Function *func, const Scope* scope, const Token *ifStatementScopeStart) const; static bool hasAssignSelf(const Function *func, const Token *rhs, const Token *&out_ifStatementScopeStart); - enum class Bool : std::uint8_t { TRUE, FALSE, BAILOUT }; + enum class Bool : std::uint8_t { True, False, Bailout }; static Bool isInverted(const Token *tok, const Token *rhs); static const Token * getIfStmtBodyStart(const Token *tok, const Token *rhs); From a4956771f10e361745a4c33447b80df5b8f9b6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 8 Feb 2026 21:25:09 +0100 Subject: [PATCH 109/675] cppcheck.vcxproj: do not use precompiled header for `externals` sources (#8177) this fixes the conflict between functions with the same name in Cppcheck and simplecpp --- lib/cppcheck.vcxproj | 10 ++++++++-- tools/dmake/dmake.cpp | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/cppcheck.vcxproj b/lib/cppcheck.vcxproj index d0175b2997f..b0e52a814fe 100644 --- a/lib/cppcheck.vcxproj +++ b/lib/cppcheck.vcxproj @@ -18,8 +18,14 @@ - - + + NotUsing + + + + NotUsing + + diff --git a/tools/dmake/dmake.cpp b/tools/dmake/dmake.cpp index 100e32b6b5b..f8869f2eba7 100644 --- a/tools/dmake/dmake.cpp +++ b/tools/dmake/dmake.cpp @@ -250,7 +250,7 @@ static int write_vcxproj(const std::string &proj_name, const std::function)"; + outstr += "\r\n"; + outstr += R"( NotUsing)"; + outstr += "\r\n"; + outstr += R"( )"; + outstr += "\r\n"; + outstr += " \r\n"; + return outstr; + } outstr += " <"; outstr += (type == Compile) ? "ClCompile" : "ClInclude"; outstr += R"( Include=")"; @@ -542,8 +554,8 @@ int main(int argc, char **argv) }); write_vcxproj("lib/cppcheck.vcxproj", [&](std::string &outstr){ - outstr += make_vcxproj_cl_entry(R"(..\externals\simplecpp\simplecpp.cpp)", Compile); - outstr += make_vcxproj_cl_entry(R"(..\externals\tinyxml2\tinyxml2.cpp)", Compile); + outstr += make_vcxproj_cl_entry(R"(..\externals\simplecpp\simplecpp.cpp)", NoPch); + outstr += make_vcxproj_cl_entry(R"(..\externals\tinyxml2\tinyxml2.cpp)", NoPch); for (const std::string &libfile: libfiles_prio) { const std::string l = libfile.substr(4); From 8f83c601024fa08839b6b2ae0d1bc8550d2d66f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 8 Feb 2026 21:27:18 +0100 Subject: [PATCH 110/675] refs #14226 - PathMatch: removed need for test class friend declaration (#8179) --- lib/pathmatch.h | 4 ++-- test/testpathmatch.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pathmatch.h b/lib/pathmatch.h index b89ddcbe40b..ab9d2a3c43d 100644 --- a/lib/pathmatch.h +++ b/lib/pathmatch.h @@ -169,10 +169,10 @@ class CPPCHECKLIB PathMatch { return pattern; } -private: - friend class TestPathMatch; +protected: class PathIterator; +private: /* List of patterns */ std::vector mPatterns; /* Base path to with patterns and paths are relative */ diff --git a/test/testpathmatch.cpp b/test/testpathmatch.cpp index 2be6a943845..dc55bacf339 100644 --- a/test/testpathmatch.cpp +++ b/test/testpathmatch.cpp @@ -28,6 +28,11 @@ class TestPathMatch : public TestFixture { TestPathMatch() : TestFixture("TestPathMatch") {} private: + class PathMatchTest final : public PathMatch + { + friend class TestPathMatch; + }; + static constexpr auto unix = PathMatch::Syntax::unix; static constexpr auto windows = PathMatch::Syntax::windows; static constexpr auto ifreg = PathMatch::Filemode::regular; @@ -277,7 +282,7 @@ class TestPathMatch : public TestFixture { void pathiterator() const { /* See https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats * for information on Windows path syntax. */ - using PathIterator = PathMatch::PathIterator; + using PathIterator = PathMatchTest::PathIterator; ASSERT_EQUALS("/", PathIterator("/", nullptr, unix).read()); ASSERT_EQUALS("/", PathIterator("//", nullptr, unix).read()); ASSERT_EQUALS("/", PathIterator("/", "/", unix).read()); From 6cf6b21a7a370fb46f0082458abb35fb7448ae0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 8 Feb 2026 21:27:44 +0100 Subject: [PATCH 111/675] refs #14226 - ImportProject: removed need for test class friend declaration / cleanups (#8182) --- lib/importproject.h | 14 ++++++++------ test/testimportproject.cpp | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/importproject.h b/lib/importproject.h index 55b65bfa641..45a8dbac8b1 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -55,7 +55,6 @@ namespace cppcheck { * @brief Importing project settings. */ class CPPCHECKLIB WARN_UNUSED ImportProject { - friend class TestImporter; public: enum class Type : std::uint8_t { NONE, @@ -69,9 +68,11 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { CPPCHECK_GUI }; +protected: static void fsSetDefines(FileSettings& fs, std::string defs); static void fsSetIncludePaths(FileSettings& fs, const std::string &basepath, const std::list &in, std::map &variables); +public: std::list fileSettings; std::vector errors; @@ -103,9 +104,7 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { bool importCompileCommands(std::istream &istr); bool importCppcheckGuiProject(std::istream &istr, Settings &settings, Suppressions &supprs); static std::string collectArgs(const std::string &cmd, std::vector &args); - static void parseArgs(FileSettings &fs, const std::vector &args); -private: struct SharedItemsProject { bool successful = false; std::string pathToProjectFile; @@ -113,14 +112,17 @@ class CPPCHECKLIB WARN_UNUSED ImportProject { std::vector sourceFiles; }; - bool importSln(std::istream &istr, const std::string &path, const std::vector &fileFilters); - SharedItemsProject importVcxitems(const std::string &filename, const std::vector &fileFilters, std::vector &cache); bool importVcxproj(const std::string &filename, std::map &variables, const std::string &additionalIncludeDirectories, const std::vector &fileFilters, std::vector &cache); bool importVcxproj(const std::string &filename, const tinyxml2::XMLDocument &doc, std::map &variables, const std::string &additionalIncludeDirectories, const std::vector &fileFilters, std::vector &cache); - bool importBcb6Prj(const std::string &projectFilename); +private: + static void parseArgs(FileSettings &fs, const std::vector &args); void setRelativePaths(const std::string &filename); + bool importSln(std::istream &istr, const std::string &path, const std::vector &fileFilters); + SharedItemsProject importVcxitems(const std::string &filename, const std::vector &fileFilters, std::vector &cache); + bool importBcb6Prj(const std::string &projectFilename); + std::string mPath; std::set mAllVSConfigs; }; diff --git a/test/testimportproject.cpp b/test/testimportproject.cpp index 9e4b04abe94..c3bee4dcfa6 100644 --- a/test/testimportproject.cpp +++ b/test/testimportproject.cpp @@ -32,13 +32,15 @@ #include #include -class TestImporter : public ImportProject { +class TestImporter final : public ImportProject { public: using ImportProject::importCompileCommands; using ImportProject::importCppcheckGuiProject; using ImportProject::importVcxproj; using ImportProject::SharedItemsProject; using ImportProject::collectArgs; + using ImportProject::fsSetDefines; + using ImportProject::fsSetIncludePaths; }; @@ -88,16 +90,16 @@ class TestImportProject : public TestFixture { void setDefines() const { FileSettings fs{"test.cpp", Standards::Language::CPP, 0}; - ImportProject::fsSetDefines(fs, "A"); + TestImporter::fsSetDefines(fs, "A"); ASSERT_EQUALS("A=1", fs.defines); - ImportProject::fsSetDefines(fs, "A;B;"); + TestImporter::fsSetDefines(fs, "A;B;"); ASSERT_EQUALS("A=1;B=1", fs.defines); - ImportProject::fsSetDefines(fs, "A;;B;"); + TestImporter::fsSetDefines(fs, "A;;B;"); ASSERT_EQUALS("A=1;B=1", fs.defines); - ImportProject::fsSetDefines(fs, "A;;B"); + TestImporter::fsSetDefines(fs, "A;;B"); ASSERT_EQUALS("A=1;B=1", fs.defines); } @@ -105,7 +107,7 @@ class TestImportProject : public TestFixture { FileSettings fs{"test.cpp", Standards::Language::CPP, 0}; std::list in(1, "../include"); std::map variables; - ImportProject::fsSetIncludePaths(fs, "abc/def/", in, variables); + TestImporter::fsSetIncludePaths(fs, "abc/def/", in, variables); ASSERT_EQUALS(1U, fs.includePaths.size()); ASSERT_EQUALS("abc/include/", fs.includePaths.front()); } @@ -115,7 +117,7 @@ class TestImportProject : public TestFixture { std::list in(1, "$(SolutionDir)other"); std::map variables; variables["SolutionDir"] = "c:/abc/"; - ImportProject::fsSetIncludePaths(fs, "/home/fred", in, variables); + TestImporter::fsSetIncludePaths(fs, "/home/fred", in, variables); ASSERT_EQUALS(1U, fs.includePaths.size()); ASSERT_EQUALS("c:/abc/other/", fs.includePaths.front()); } @@ -125,7 +127,7 @@ class TestImportProject : public TestFixture { std::list in(1, "$(SOLUTIONDIR)other"); std::map variables; variables["SolutionDir"] = "c:/abc/"; - ImportProject::fsSetIncludePaths(fs, "/home/fred", in, variables); + TestImporter::fsSetIncludePaths(fs, "/home/fred", in, variables); ASSERT_EQUALS(1U, fs.includePaths.size()); ASSERT_EQUALS("c:/abc/other/", fs.includePaths.front()); } From 67606e6ee50aaefa3ba6c312c644b8b962d7d9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 8 Feb 2026 21:29:19 +0100 Subject: [PATCH 112/675] small cleanup of disabled Clang compiler warnings (#8166) --- cmake/compileroptions.cmake | 2 -- externals/tinyxml2/CMakeLists.txt | 2 ++ lib/json.h | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/compileroptions.cmake b/cmake/compileroptions.cmake index b4b3c2e0689..348ad9f2674 100644 --- a/cmake/compileroptions.cmake +++ b/cmake/compileroptions.cmake @@ -132,8 +132,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() # TODO: fix and enable these warnings - or move to suppression list below - add_compile_options_safe(-Wno-documentation-unknown-command) # TODO: Clang currently does not support all commands - add_compile_options_safe(-Wno-unused-exception-parameter) add_compile_options_safe(-Wno-sign-conversion) add_compile_options_safe(-Wno-shadow-field-in-constructor) add_compile_options_safe(-Wno-shorten-64-to-32) diff --git a/externals/tinyxml2/CMakeLists.txt b/externals/tinyxml2/CMakeLists.txt index 9f15c558682..2e1aa036b81 100644 --- a/externals/tinyxml2/CMakeLists.txt +++ b/externals/tinyxml2/CMakeLists.txt @@ -15,6 +15,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options_safe(tinyxml2 -Wno-zero-as-null-pointer-constant) target_compile_options_safe(tinyxml2 -Wno-format-nonliteral) target_compile_options_safe(tinyxml2 -Wno-inconsistent-missing-destructor-override) + target_compile_options_safe(tinyxml2 -Wno-sign-conversion) + target_compile_options_safe(tinyxml2 -Wno-double-promotion) endif() if(CYGWIN) target_compile_definitions(-D_LARGEFILE_SOURCE) # required for fseeko() and ftello() diff --git a/lib/json.h b/lib/json.h index 2bcfe102071..51101842677 100644 --- a/lib/json.h +++ b/lib/json.h @@ -28,6 +28,7 @@ SUPPRESS_WARNING_CLANG_PUSH("-Wextra-semi-stmt") SUPPRESS_WARNING_CLANG_PUSH("-Wzero-as-null-pointer-constant") SUPPRESS_WARNING_CLANG_PUSH("-Wformat") SUPPRESS_WARNING_CLANG_PUSH("-Wfloat-conversion") +SUPPRESS_WARNING_CLANG_PUSH("-Wimplicit-float-conversion") #define PICOJSON_USE_INT64 #include // IWYU pragma: export @@ -37,6 +38,7 @@ SUPPRESS_WARNING_CLANG_POP SUPPRESS_WARNING_CLANG_POP SUPPRESS_WARNING_CLANG_POP SUPPRESS_WARNING_CLANG_POP +SUPPRESS_WARNING_CLANG_POP SUPPRESS_WARNING_GCC_POP SUPPRESS_WARNING_POP From 3a99f41f6957edad369944579a710be2e51d382f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 9 Feb 2026 08:34:28 +0100 Subject: [PATCH 113/675] Partial fix for #14342 FN containerOutOfBounds with std::span and std::string_view (regression) (#8164) --- lib/valueflow.cpp | 8 +++++--- test/teststl.cpp | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index edd6634a0ea..86b49c0b137 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -6504,10 +6504,12 @@ static std::vector getContainerSizeFromConstructorArgs(const s return {}; } -static bool valueFlowIsSameContainerType(const ValueType& contType, const Token* tok, const Settings& settings) +static bool valueFlowIsSameContainerType(const ValueType& contType, const Token* tok, bool isView, const Settings& settings) { - if (!tok || !tok->valueType() || !tok->valueType()->containerTypeToken) + if (!tok || !tok->valueType()) return true; + if (!tok->valueType()->containerTypeToken) + return !isView; const ValueType tokType = ValueType::parseDecl(tok->valueType()->containerTypeToken, settings); return contType.isTypeEqual(&tokType) || tokType.type == ValueType::Type::UNKNOWN_TYPE; @@ -6536,7 +6538,7 @@ static std::vector getInitListSize(const Token* tok, initList = true; else if (vt.isIntegral() && astIsIntegral(args[0], false)) initList = true; - else if (args.size() == 1 && valueFlowIsSameContainerType(vt, tok->astOperand2(), settings)) + else if (args.size() == 1 && valueFlowIsSameContainerType(vt, tok->astOperand2(), valueType->container->view, settings)) initList = false; // copy ctor else if (args.size() == 2 && (!args[0]->valueType() || !args[1]->valueType())) // might be unknown iterators initList = false; diff --git a/test/teststl.cpp b/test/teststl.cpp index 2c4669dbeca..636fd36b1d0 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -972,6 +972,14 @@ class TestStl : public TestFixture { "bool g() { return f(\" \"); }\n"); ASSERT_EQUALS("[test.cpp:1:44]: error: Out of bounds access in 's[500]', if 's' size is 1 and '500' is 500 [containerOutOfBounds]\n", errout_str()); + + checkNormal("int main() {\n" // #14342 + " const int a[] = { 1, 2, 3 };\n" + " std::span x{ a };\n" + " return x[3];\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4:13]: error: Out of bounds access in 'x[3]', if 'x' size is 1 and '3' is 3 [containerOutOfBounds]\n", + errout_str()); } void outOfBoundsSymbolic() From 81c9ac2bd82bfdf9c42b5c4e82cb3f310bbc044d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 10 Feb 2026 09:06:17 +0100 Subject: [PATCH 114/675] Fix #14439 FP uninitvar when variable name matches function pointer argument (#8158) --- lib/tokenize.cpp | 4 ++-- test/testvarid.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index dcba832cee2..63358cb8e6f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5032,8 +5032,8 @@ void Tokenizer::setVarIdPass1() // there are tokens which can't appear at the begin of a function declaration such as "return" const bool isNotstartKeyword = start->next() && notstart.find(start->strAt(1)) != notstart.end(); - // now check if it is a function declaration - if (Token::Match(start, "[;{}] %type% %name%|*") && par && Token::simpleMatch(end, ") ;") && !isNotstartKeyword) { + // now check if it is a function (pointer) declaration + if ((Token::simpleMatch(start, ") (") || Token::Match(start, "[;{}] %type% %name%|*")) && par && Token::Match(end, ") [;=]") && !isNotstartKeyword) { // function declaration => don't set varid tok = end; continue; diff --git a/test/testvarid.cpp b/test/testvarid.cpp index de8a58cfa61..32bff9c5724 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -3497,6 +3497,16 @@ class TestVarID : public TestFixture { const char code3[] = "void f (void (*g) (int i, IN int n)) {}\n"; ASSERT_EQUALS("1: void f ( void ( * g@1 ) ( int , IN int ) ) { }\n", tokenize(code3)); + + const char code4[] = "void f() {\n" // #14439 + " int* p;\n" + " void (*a[1])(int* p) = { 0 };\n" + "}\n"; + ASSERT_EQUALS("1: void f ( ) {\n" + "2: int * p@1 ;\n" + "3: void ( * a@2 [ 1 ] ) ( int * p ) = { 0 } ;\n" + "4: }\n", + tokenize(code4)); } void varid_alignas() { From 7f1225d031acb0b3b723e64872580424b353e974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 10 Feb 2026 12:19:43 +0100 Subject: [PATCH 115/675] refs #10663 - bail out early on some impossible matches in `Library::detectContainerInternal()` (#8191) --- lib/library.cpp | 9 ++++++++- lib/library.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/library.cpp b/lib/library.cpp index ad5ea13a3ed..f3a56cf15f1 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -619,6 +619,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc) container.startPattern2 = startPattern; if (!endsWith(container.startPattern, '<')) container.startPattern2 += " !!::"; + container.startPatternHasStd = startsWith(container.startPattern2, "std :: "); } const char* const endPattern = node->Attribute("endPattern"); if (endPattern) @@ -1395,12 +1396,18 @@ const Library::Container* Library::detectContainerInternal(const Token* const ty break; } + const bool hasScope = typeStart->strAt(1) == "::"; + const bool bailIfHasStd = !withoutStd && !hasScope; + for (const std::pair & c : mData->mContainers) { const Container& container = c.second; if (container.startPattern.empty()) continue; - const int offset = (withoutStd && startsWith(container.startPattern2, "std :: ")) ? 7 : 0; + if (bailIfHasStd && container.startPatternHasStd) + continue; + + const int offset = (withoutStd && container.startPatternHasStd) ? 7 : 0; // If endPattern is undefined, it will always match, but itEndPattern has to be defined. if (detect != IteratorOnly && container.endPattern.empty()) { diff --git a/lib/library.h b/lib/library.h index b5b19a197b2..d8c9e0c47cc 100644 --- a/lib/library.h +++ b/lib/library.h @@ -239,6 +239,7 @@ class CPPCHECKLIB Library { bool unstableErase{}; bool unstableInsert{}; bool view{}; + bool startPatternHasStd{}; Action getAction(const std::string& function) const { const auto i = utils::as_const(functions).find(function); From bbfd62c94c88bf46d1260c08306d274c24fa043e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 10 Feb 2026 13:41:15 +0100 Subject: [PATCH 116/675] fixed #12834 - de-duplicate input files by comparing absolute paths (#8193) --- cli/cmdlineparser.cpp | 4 +-- test/cli/more-projects_test.py | 34 ++++------------------- test/cli/other_test.py | 50 ++++------------------------------ 3 files changed, 14 insertions(+), 74 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 92f4c6cef3b..7c18e428023 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -269,10 +269,10 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) { auto it = filesResolved.begin(); while (it != filesResolved.end()) { - const std::string& name = it->path(); + const std::string& absname = Path::getAbsoluteFilePath(it->spath()); // TODO: log if duplicated files were dropped filesResolved.erase(std::remove_if(std::next(it), filesResolved.end(), [&](const FileWithDetails& entry) { - return entry.path() == name; + return Path::getAbsoluteFilePath(entry.spath()) == absname; }), filesResolved.end()); ++it; } diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index 03dc00ed0f3..73d738d9cfb 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -657,7 +657,7 @@ def test_project_file_duplicate_2(tmpdir): assert stderr == '' -def test_project_file_duplicate_3(tmpdir): +def test_project_file_duplicate_3(tmpdir): # #12834 test_file_a = os.path.join(tmpdir, 'a.c') with open(test_file_a, 'wt'): pass @@ -687,33 +687,18 @@ def test_project_file_duplicate_3(tmpdir): """.format(in_file_a, in_file_b, in_file_c, in_file_d, in_file_e, in_file_f, tmpdir)) args = ['--project={}'.format(project_file)] - args.append('-j1') # TODO: remove when fixed exitcode, stdout, stderr = cppcheck(args, cwd=tmpdir) assert exitcode == 0 lines = stdout.splitlines() - # TODO: only a single file should be checked - if sys.platform == 'win32': - assert lines == [ - 'Checking {} ...'.format(test_file_a), - '1/3 files checked 33% done', - 'Checking {} ...'.format(test_file_a), - '2/3 files checked 66% done', - 'Checking {} ...'.format(test_file_a), - '3/3 files checked 100% done' - ] - else: - assert lines == [ - 'Checking {} ...'.format(test_file_a), - '1/2 files checked 50% done', - 'Checking {} ...'.format(test_file_a), - '2/2 files checked 100% done' - ] + assert lines == [ + 'Checking {} ...'.format(test_file_a) + ] assert stderr == '' @pytest.mark.skipif(sys.platform != 'win32', reason="requires Windows") -def test_project_file_duplicate_4(tmpdir): +def test_project_file_duplicate_4(tmpdir): # #12834 test_file_a = os.path.join(tmpdir, 'a.c') with open(test_file_a, 'wt'): pass @@ -756,19 +741,12 @@ def test_project_file_duplicate_4(tmpdir): args2[0], args2[1], args2[2], args2[3], args2[4], args2[5], args2[6])) args = ['--project={}'.format(project_file)] - args.append('-j1') # TODO: remove when fixed exitcode, stdout, stderr = cppcheck(args, cwd=tmpdir) assert exitcode == 0 lines = stdout.splitlines() - # TODO: only a single file should be checked assert lines == [ - 'Checking {} ...'.format(test_file_a), - '1/3 files checked 33% done', - 'Checking {} ...'.format(test_file_a), - '2/3 files checked 66% done', - 'Checking {} ...'.format(test_file_a), - '3/3 files checked 100% done' + 'Checking {} ...'.format(test_file_a) ] assert stderr == '' diff --git a/test/cli/other_test.py b/test/cli/other_test.py index c4ae2fab5cf..744a68aac60 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -1216,7 +1216,7 @@ def test_file_duplicate_2(tmpdir): assert stderr == '' -def test_file_duplicate_3(tmpdir): +def test_file_duplicate_3(tmpdir): # #12834 test_file_a = os.path.join(tmpdir, 'a.c') with open(test_file_a, 'wt'): pass @@ -1230,43 +1230,18 @@ def test_file_duplicate_3(tmpdir): in_file_f = os.path.join(tmpdir, 'dummy', '..', 'a.c') args = [in_file_a, in_file_b, in_file_c, in_file_d, in_file_e, in_file_f, str(tmpdir)] - args.append('-j1') # TODO: remove when fixed exitcode, stdout, stderr = cppcheck(args, cwd=tmpdir) assert exitcode == 0, stdout if stdout else stderr lines = stdout.splitlines() - # TODO: only a single file should be checked - if sys.platform == 'win32': - assert lines == [ - 'Checking {} ...'.format('a.c'), - '1/6 files checked 16% done', - 'Checking {} ...'.format('a.c'), - '2/6 files checked 33% done', - 'Checking {} ...'.format('a.c'), - '3/6 files checked 50% done', - 'Checking {} ...'.format(test_file_a), - '4/6 files checked 66% done', - 'Checking {} ...'.format(test_file_a), - '5/6 files checked 83% done', - 'Checking {} ...'.format(test_file_a), - '6/6 files checked 100% done' - ] - else: - assert lines == [ - 'Checking {} ...'.format('a.c'), - '1/4 files checked 25% done', - 'Checking {} ...'.format('a.c'), - '2/4 files checked 50% done', - 'Checking {} ...'.format(test_file_a), - '3/4 files checked 75% done', - 'Checking {} ...'.format(test_file_a), - '4/4 files checked 100% done' - ] + assert lines == [ + 'Checking {} ...'.format('a.c') + ] assert stderr == '' @pytest.mark.skipif(sys.platform != 'win32', reason="requires Windows") -def test_file_duplicate_4(tmpdir): +def test_file_duplicate_4(tmpdir): # #12834 test_file_a = os.path.join(tmpdir, 'a.c') with open(test_file_a, 'wt'): pass @@ -1284,25 +1259,12 @@ def test_file_duplicate_4(tmpdir): for a in args1: args2.append(a.replace('\\', '/')) args = args1 + args2 - args.append('-j1') # TODO: remove when fixed exitcode, stdout, stderr = cppcheck(args, cwd=tmpdir) assert exitcode == 0, stdout if stdout else stderr lines = stdout.splitlines() - # TODO: only a single file should be checked assert lines == [ - 'Checking {} ...'.format('a.c'), - '1/6 files checked 16% done', - 'Checking {} ...'.format('a.c'), - '2/6 files checked 33% done', - 'Checking {} ...'.format('a.c'), - '3/6 files checked 50% done', - 'Checking {} ...'.format(test_file_a), - '4/6 files checked 66% done', - 'Checking {} ...'.format(test_file_a), - '5/6 files checked 83% done', - 'Checking {} ...'.format(test_file_a), - '6/6 files checked 100% done' + 'Checking {} ...'.format('a.c') ] assert stderr == '' From dc2049b6493a3cf7ea44f52dcb0ba6fadfcdad49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 10 Feb 2026 13:58:14 +0100 Subject: [PATCH 117/675] fixed #14459 - removed unused `files.txt` entry when defines are provided by the user (#8175) the filename is never handed out and thus the file is never created --- cli/cppcheckexecutor.cpp | 2 +- gui/mainwindow.cpp | 4 ++-- lib/analyzerinfo.cpp | 8 +++----- lib/analyzerinfo.h | 4 ++-- test/testanalyzerinformation.cpp | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 716478f0baf..4f74bccbd5e 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -396,7 +396,7 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup std::list fileNames; for (auto i = mFiles.cbegin(); i != mFiles.cend(); ++i) fileNames.emplace_back(i->path()); - AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, mFileSettings); + AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, mFileSettings); stdLogger.readActiveCheckers(); } diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 19270f1605b..6d0a1a8d5ce 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -618,7 +618,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons if (!checkSettings.buildDir.empty()) { checkSettings.loadSummaries(); std::list sourcefiles; - AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, p.fileSettings); + AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, p.fileSettings); } //mThread->SetanalyzeProject(true); @@ -700,7 +700,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar std::transform(fileNames.cbegin(), fileNames.cend(), std::back_inserter(sourcefiles), [](const QString& s) { return s.toStdString(); }); - AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, checkSettings.userDefines, {}); + AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, {}); } mThread->setCheckFiles(true); diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index 72857a9134f..fa84e1580d2 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -48,14 +48,14 @@ static std::string getFilename(const std::string &fullpath) return fullpath.substr(pos1,pos2); } -void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings) +void AnalyzerInformation::writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::list &fileSettings) { const std::string filesTxt(buildDir + "/files.txt"); std::ofstream fout(filesTxt); - fout << getFilesTxt(sourcefiles, userDefines, fileSettings); + fout << getFilesTxt(sourcefiles, fileSettings); } -std::string AnalyzerInformation::getFilesTxt(const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings) { +std::string AnalyzerInformation::getFilesTxt(const std::list &sourcefiles, const std::list &fileSettings) { std::ostringstream ret; std::map fileCount; @@ -63,8 +63,6 @@ std::string AnalyzerInformation::getFilesTxt(const std::list &sourc for (const std::string &f : sourcefiles) { const std::string afile = getFilename(f); ret << afile << ".a" << (++fileCount[afile]) << sep << sep << sep << Path::simplifyPath(f) << '\n'; - if (!userDefines.empty()) - ret << afile << ".a" << (++fileCount[afile]) << sep << userDefines << sep << sep << Path::simplifyPath(f) << '\n'; } for (const FileSettings &fs : fileSettings) { diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 19591f69e62..479b0d89896 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -57,7 +57,7 @@ class CPPCHECKLIB AnalyzerInformation { public: ~AnalyzerInformation(); - static void writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings); + static void writeFilesTxt(const std::string &buildDir, const std::list &sourcefiles, const std::list &fileSettings); /** Close current TU.analyzerinfo file */ void close(); @@ -80,7 +80,7 @@ class CPPCHECKLIB AnalyzerInformation { static void processFilesTxt(const std::string& buildDir, const std::function& handler); protected: - static std::string getFilesTxt(const std::list &sourcefiles, const std::string &userDefines, const std::list &fileSettings); + static std::string getFilesTxt(const std::list &sourcefiles, const std::list &fileSettings); static std::string getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fileIndex); diff --git a/test/testanalyzerinformation.cpp b/test/testanalyzerinformation.cpp index fa4c4ddfaf4..a1f927ea876 100644 --- a/test/testanalyzerinformation.cpp +++ b/test/testanalyzerinformation.cpp @@ -66,7 +66,7 @@ class TestAnalyzerInformation : public TestFixture { const char expected[] = "a.a1:::a.c\n" "a.a2::1:a.c\n"; - ASSERT_EQUALS(expected, AnalyzerInformationTest::getFilesTxt({}, "", fileSettings)); + ASSERT_EQUALS(expected, AnalyzerInformationTest::getFilesTxt({}, fileSettings)); } void duplicateFile() const { From d92c5797f96d0dfbd2b6b21e3023bc23084312fc Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:58:34 +0100 Subject: [PATCH 118/675] Fix #14428 FP duplicateCondition, pointer data may be changed in function call (#8155) --- lib/astutils.cpp | 2 -- test/testcondition.cpp | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 304a2f154d9..e140d965114 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -3086,8 +3086,6 @@ static const Token* findExpressionChangedImpl(const Token* expr, } bool global = false; if (tok->variable()) { - if (tok->variable()->isConst()) - return false; global = !tok->variable()->isLocal() && !tok->variable()->isArgument() && !(tok->variable()->isMember() && !tok->variable()->isStatic()); } else if (tok->isIncompleteVar() && !tok->isIncompleteConstant()) { diff --git a/test/testcondition.cpp b/test/testcondition.cpp index bbe4ef312b8..58fa04dc490 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -5899,6 +5899,28 @@ class TestCondition : public TestFixture { " if (strlen(s2) > 0) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void g(int*);\n" // #14428 + "int f(int* const p) {\n" + " int i = 0;\n" + " if (*p == 0)\n" + " g(p);\n" + " if (*p == 0)\n" + " i = 1;\n" + " return i;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + + check("void g(const int*);\n" + "int f(const int* const p) {\n" + " int i = 0;\n" + " if (*p == 0)\n" + " g(p);\n" + " if (*p == 0)\n" + " i = 1;\n" + " return i;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4:12] -> [test.cpp:6:12]: (style) The if condition is the same as the previous if condition [duplicateCondition]\n", errout_str()); } void checkInvalidTestForOverflow() { From 08fb0fcc20d0fcb8fa4a1cb58ada7052c7e81efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 10 Feb 2026 14:30:49 +0100 Subject: [PATCH 119/675] AnalyzerInformation: use `Info::parse()` in `getAnalyzerInfoFileFromFilesTxt()` (#8176) --- lib/analyzerinfo.cpp | 14 ++++++-------- lib/analyzerinfo.h | 2 +- lib/utils.h | 5 +++++ test/testanalyzerinformation.cpp | 14 +++++++++----- test/testutils.cpp | 12 ++++++++++++ 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index fa84e1580d2..ea6c414b7b0 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -110,17 +110,15 @@ bool AnalyzerInformation::skipAnalysis(const tinyxml2::XMLDocument &analyzerInfo return true; } -std::string AnalyzerInformation::getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fileIndex) +std::string AnalyzerInformation::getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fsFileId) { - const std::string id = (fileIndex > 0) ? std::to_string(fileIndex) : ""; std::string line; - const std::string end(sep + cfg + sep + id + sep + Path::simplifyPath(sourcefile)); while (std::getline(filesTxt,line)) { - if (line.size() <= end.size() + 2U) - continue; - if (!endsWith(line, end.c_str(), end.size())) - continue; - return line.substr(0,line.find(sep)); + AnalyzerInformation::Info filesTxtInfo; + if (!filesTxtInfo.parse(line)) + continue; // TODO: report error? + if (endsWith(sourcefile, filesTxtInfo.sourceFile) && filesTxtInfo.cfg == cfg && filesTxtInfo.fsFileId == fsFileId) + return filesTxtInfo.afile; } return ""; } diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 479b0d89896..1547ef50f16 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -82,7 +82,7 @@ class CPPCHECKLIB AnalyzerInformation { protected: static std::string getFilesTxt(const std::list &sourcefiles, const std::list &fileSettings); - static std::string getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fileIndex); + static std::string getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fsFileId); static bool skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors); diff --git a/lib/utils.h b/lib/utils.h index c59e4d3a32c..c84c72236c1 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -124,6 +124,11 @@ bool endsWith(const std::string& str, const char (&end)[N]) return endsWith(str, end, N - 1); } +inline bool endsWith(const std::string& str, const std::string& end) +{ + return endsWith(str, end.c_str(), end.length()); +} + inline static bool isPrefixStringCharLiteral(const std::string &str, char q, const std::string& p) { // str must be at least the prefix plus the start and end quote diff --git a/test/testanalyzerinformation.cpp b/test/testanalyzerinformation.cpp index a1f927ea876..a92a8c37b1a 100644 --- a/test/testanalyzerinformation.cpp +++ b/test/testanalyzerinformation.cpp @@ -39,6 +39,7 @@ class TestAnalyzerInformation : public TestFixture { }; void run() override { + TEST_CASE(getAnalyzerInfoFileFromFilesTxt); TEST_CASE(getAnalyzerInfoFile); TEST_CASE(duplicateFile); TEST_CASE(filesTextDuplicateFile); @@ -46,12 +47,15 @@ class TestAnalyzerInformation : public TestFixture { TEST_CASE(skipAnalysis); } - void getAnalyzerInfoFile() const { + void getAnalyzerInfoFileFromFilesTxt() const { constexpr char filesTxt[] = "file1.a4:::file1.c\n"; - std::istringstream f1(filesTxt); - ASSERT_EQUALS("file1.a4", AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt(f1, "file1.c", "", 0)); - std::istringstream f2(filesTxt); - ASSERT_EQUALS("file1.a4", AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt(f2, "./file1.c", "", 0)); + std::istringstream f(filesTxt); + ASSERT_EQUALS("file1.a4", AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt(f, "file1.c", "", 0)); + f.str(filesTxt); + ASSERT_EQUALS("file1.a4", AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt(f, "./file1.c", "", 0)); + } + + void getAnalyzerInfoFile() const { ASSERT_EQUALS("builddir/file1.c.analyzerinfo", AnalyzerInformation::getAnalyzerInfoFile("builddir", "file1.c", "", 0)); ASSERT_EQUALS("builddir/file1.c.analyzerinfo", AnalyzerInformation::getAnalyzerInfoFile("builddir", "some/path/file1.c", "", 0)); } diff --git a/test/testutils.cpp b/test/testutils.cpp index 37c1030000d..0aad2c447a1 100644 --- a/test/testutils.cpp +++ b/test/testutils.cpp @@ -44,6 +44,7 @@ class TestUtils : public TestFixture { TEST_CASE(splitString); TEST_CASE(as_const); TEST_CASE(memoize); + TEST_CASE(endsWith); } void isValidGlobPattern() const { @@ -563,6 +564,17 @@ class TestUtils : public TestFixture { ASSERT_EQUALS(1, callF()); ASSERT_EQUALS(1, count); } + + void endsWith() const + { + ASSERT(::endsWith("test", "test")); + ASSERT(::endsWith("test2", "2")); + ASSERT(::endsWith("test test", "test")); + ASSERT(::endsWith("test", "t")); + ASSERT(!::endsWith("", "test")); + ASSERT(!::endsWith("tes", "test")); + ASSERT(!::endsWith("2test", "2")); + } }; REGISTER_TEST(TestUtils) From e28245182cd914ca75a4cf6960787fb6ec04e6f1 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:49:46 +0100 Subject: [PATCH 120/675] Fix #13908 Improve check: uninitdata not detected in 'std::cout << i << ", " << *i;' (regression) (#8165) --- lib/checkuninitvar.cpp | 3 ++- test/testuninitvar.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 8463f6a1c8e..8f044acb44b 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -844,7 +844,8 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const Variable& var } // assume that variable is assigned - return true; + if (!Token::simpleMatch(tok->astParent(), "<<")) + return true; } } } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index b3c988e5b00..331bdf8d3cb 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -570,6 +570,13 @@ class TestUninitVar : public TestFixture { "}"); ASSERT_EQUALS("[test.cpp:3:17]: (error) Uninitialized variable: p [legacyUninitvar]\n", errout_str()); } + + checkUninitVar("void f() {\n" // #13908 + " int* i = new int;\n" + " std::cout << i << \", \" << *i;\n" + " delete i;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:32]: (error) Memory is allocated but not initialized: i [uninitdata]\n", errout_str()); } // #8494 : Overloaded & operator From 8b6484022c601141073ee09add0e44544bfea1e3 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:51:54 +0100 Subject: [PATCH 121/675] Fix #13797 FN nullPointer with negated if-condition (regression) (#8172) Co-authored-by: chrchr-github --- lib/checkunusedfunctions.cpp | 2 +- lib/library.cpp | 2 +- lib/symboldatabase.cpp | 2 +- lib/vf_analyzers.cpp | 4 ++-- test/testnullpointer.cpp | 11 ++++++++++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 7edaff6c241..f6daec51f20 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -385,7 +385,7 @@ bool CheckUnusedFunctions::check(const Settings& settings, ErrorLogger& errorLog if (func.filename != "+") filename = func.filename; errors.emplace_back(filename, func.fileIndex, func.lineNumber, func.column, it->first); - } else if (func.isC && !func.isStatic && !func.usedOtherFile) { + } else if (func.isC && !func.isStatic) { std::string filename; if (func.filename != "+") filename = func.filename; diff --git a/lib/library.cpp b/lib/library.cpp index f3a56cf15f1..f2363f75d14 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -210,7 +210,7 @@ Library::Error Library::load(const char exename[], const char path[], bool debug tinyxml2::XMLError error = xml_LoadFile(doc, fullfilename.c_str()); if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) { // only perform further lookups when the given path was not absolute - if (!is_abs_path && error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) + if (!is_abs_path) { std::list cfgfolders; #ifdef FILESDIR diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 5e4062193a0..f5ffa4e1604 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1023,7 +1023,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization() if (var.isClass() && !var.isReference()) { if (var.type()) { // does this type need initialization? - if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault() && !var.isStatic()) + if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault()) needInitialization = true; else if (var.type()->needInitialization == Type::NeedInitialization::Unknown) { if (!(var.valueType() && var.valueType()->type == ValueType::CONTAINER)) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index e14af7a9c98..ec026f2f487 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -139,7 +139,7 @@ struct ValueFlowAnalyzer : Analyzer { return result; } ConditionState lhs = analyzeCondition(tok->astOperand1(), depth - 1); - if (lhs.isUnknownDependent()) + if (lhs.isUnknownDependent() || !tok->astOperand2()) return lhs; ConditionState rhs = analyzeCondition(tok->astOperand2(), depth - 1); if (rhs.isUnknownDependent()) @@ -1202,7 +1202,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer { return false; if (value.isImpossible()) return false; - if (isConditional() && !value.isKnown() && !value.isImpossible()) + if (isConditional() && !value.isKnown()) return true; if (value.isSymbolicValue()) return false; diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 1eb01edfcce..96e188075e4 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -2458,6 +2458,14 @@ class TestNullPointer : public TestFixture { " if (h(i) && *i == 1) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void f(int i) {\n" // #13797 + " int* p = nullptr;\n" + " if (!i) {\n" + " *p = 0;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4:10]: (error) Null pointer dereference: p [nullPointer]\n", errout_str()); } void nullpointer78() // #7802 @@ -3929,7 +3937,8 @@ class TestNullPointer : public TestFixture { " std::string s(p);\n" " return s;\n" "}\n", dinit(CheckOptions, $.inconclusive = true)); - ASSERT_EQUALS("", errout_str()); + ASSERT_EQUALS("[test.cpp:6:17]: (warning, inconclusive) Possible null pointer dereference: p [nullPointer]\n", + errout_str()); check("void f() {\n" // #11078 " const char* p = nullptr;\n" From 7e6f5e612f8504fb1e4e7cb796a4606928de75dd Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 11 Feb 2026 08:54:20 +0100 Subject: [PATCH 122/675] Fix #14448 FN uninitdata after pointer check (#8163) --- lib/checkuninitvar.cpp | 2 +- test/testuninitvar.cpp | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 8f044acb44b..014031259e4 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -907,7 +907,7 @@ bool CheckUninitVar::checkIfForWhileHead(const Token *startparentheses, const Va continue; uninitvarError(errorToken, errorToken->expressionString(), alloc); } - return true; + return !Token::Match(tok->astParent(), "!|%comp%"); } // skip sizeof / offsetof if (isUnevaluated(tok)) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 331bdf8d3cb..cf5bf42f635 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2042,7 +2042,7 @@ class TestUninitVar : public TestFixture { " return;\n" " char c = *s;\n" "}"); - TODO_ASSERT_EQUALS("[test.cpp:6]: (error) Memory is allocated but not initialized: s\n", "", errout_str()); + ASSERT_EQUALS("[test.cpp:6:15]: (error) Memory is allocated but not initialized: s [uninitdata]\n", errout_str()); // #3708 - false positive when using ptr typedef checkUninitVar("void f() {\n" @@ -2146,6 +2146,24 @@ class TestUninitVar : public TestFixture { " *(p + i) = 0;\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + checkUninitVar("int* f() {\n" // #14448 + " int* p = (int*)malloc(4);\n" + " if (!p)\n" + " return nullptr;\n" + " if (*p) {}\n" + " return p;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5:9]: (error) Memory is allocated but not initialized: *p [uninitdata]\n", errout_str()); + + checkUninitVar("int* f() {\n" + " int* p = (int*)malloc(4);\n" + " if (p == nullptr)\n" + " return nullptr;\n" + " if (*p) {}\n" + " return p;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5:9]: (error) Memory is allocated but not initialized: *p [uninitdata]\n", errout_str()); } // class / struct.. From 1e79f7ffa1de4b9dc34cd96080f7d78c925d19b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 11 Feb 2026 13:57:07 +0100 Subject: [PATCH 123/675] Fix #14476 (Premium Misra: skip bailout; condition '2>3' is always false) (#8195) --- lib/checkcondition.cpp | 12 +++++++----- test/testcondition.cpp | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index eb025a35d1d..2b3ca4ed93d 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -1502,10 +1502,11 @@ void CheckCondition::clarifyConditionError(const Token *tok, bool assign, bool b void CheckCondition::alwaysTrueFalse() { - if (!mSettings->severity.isEnabled(Severity::style) && - !mSettings->isPremiumEnabled("alwaysTrue") && - !mSettings->isPremiumEnabled("alwaysFalse") && - !mSettings->isPremiumEnabled("knownConditionTrueFalse")) + const bool pedantic = mSettings->isPremiumEnabled("alwaysTrue") || + mSettings->isPremiumEnabled("alwaysFalse") || + mSettings->isPremiumEnabled("knownConditionTrueFalse"); + + if (!pedantic && !mSettings->severity.isEnabled(Severity::style)) return; logChecker("CheckCondition::alwaysTrueFalse"); // style @@ -1588,7 +1589,8 @@ void CheckCondition::alwaysTrueFalse() true, true)) continue; - if (isConstVarExpression(tok, [](const Token* tok) { + + if (!pedantic && isConstVarExpression(tok, [](const Token* tok) { return Token::Match(tok, "[|(|&|+|-|*|/|%|^|>>|<<") && !Token::simpleMatch(tok, "( )"); })) continue; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 58fa04dc490..d6953ca7149 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -110,6 +110,7 @@ class TestCondition : public TestFixture { TEST_CASE(alwaysTrueLoop); TEST_CASE(alwaysTrueTryCatch); TEST_CASE(alwaysTrueSideEffect); + TEST_CASE(alwaysTruePremiumMisra); TEST_CASE(multiConditionAlwaysTrue); TEST_CASE(duplicateCondition); @@ -5625,6 +5626,20 @@ class TestCondition : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void alwaysTruePremiumMisra() { + const char code[] = "void f() {\n" + " if (3 > 2) {}\n" + "}"; + + check(code); + ASSERT_EQUALS("", errout_str()); + + Settings misraSettings; + misraSettings.premiumArgs = "--misra-c-2012"; + check(code, misraSettings); + ASSERT_EQUALS("[test.cpp:2:9]: (style) Condition '3>2' is always true [knownConditionTrueFalse]\n", errout_str()); + } + void multiConditionAlwaysTrue() { check("void f() {\n" " int val = 0;\n" From 7c5db88a2602303241586cb4e991ba5de3123cd0 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 12 Feb 2026 08:02:54 +0100 Subject: [PATCH 124/675] Add tests for #10241, #11519, #12532, #13403 (#8200) Co-authored-by: chrchr-github --- test/testbufferoverrun.cpp | 18 ++++++++++++++++++ test/testcondition.cpp | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 66b3ea2e4e0..2f2027c13af 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -4173,6 +4173,15 @@ class TestBufferOverrun : public TestFixture { " a[i] = NULL;\n" "}"); ASSERT_EQUALS("[test.cpp:4:6]: (error) Array 'a[2]' accessed at index 2, which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str()); + + check("void f(const uint8_t* a) {\n" // 10421 + " uint8_t* p = (uint8_t*)malloc(20U * sizeof(uint8_t));\n" + " if (!p) return false;\n" + " for (uint8_t i = 1; i < 30; ++i)\n" + " p[i] = a[i];\n" + " free(p);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5:10]: (error) Array 'p[20]' accessed at index 29, which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str()); } // statically allocated buffer @@ -5351,6 +5360,15 @@ class TestBufferOverrun : public TestFixture { " f(a);\n" "}\n"); ASSERT_EQUALS("[test.cpp:7:12] -> [test.cpp:9:6] -> [test.cpp:3:12]: (error) Array index out of bounds; 'p' buffer size is 4 and it is accessed at offset 20. [ctuArrayIndex]\n", errout_str()); + + ctu("void bar(int *p) { p[4] = 42; }\n" // #13403 + "void f() {\n" + " int *p = (int*)malloc(4 * sizeof(int));\n" + " if (!p) return;\n" + " bar(p);\n" + " free(p);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:12] -> [test.cpp:4:9] -> [test.cpp:5:8] -> [test.cpp:1:20]: (error) Array index out of bounds; 'p' buffer size is 16 and it is accessed at offset 16. [ctuArrayIndex]\n", errout_str()); } void ctu_array() { diff --git a/test/testcondition.cpp b/test/testcondition.cpp index d6953ca7149..f7a40e2d90b 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -4815,6 +4815,29 @@ class TestCondition : public TestFixture { " return false;\n" "}\n"); ASSERT_EQUALS("[test.cpp:6:12] -> [test.cpp:7:21]: (style) Assigned value 's.g()' is always true [knownConditionTrueFalse]\n", errout_str()); + + check("void f(const void* p) {\n" // #11519 + " bool b = false;\n" + " if (!p && !b) {}\n" + " if (!b) {}\n" + " (void)b;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:15]: (style) Condition '!b' is always true [knownConditionTrueFalse]\n" + "[test.cpp:4:9]: (style) Condition '!b' is always true [knownConditionTrueFalse]\n", + errout_str()); + + check("struct C {\n" // #12532 + " void f() const;\n" + " int a, b;\n" + "};\n" + "void C::f() const {\n" + " if (a)\n" + " return;\n" + " if (!b) {}\n" + " if (a) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:6:9] -> [test.cpp:9:9]: (style) Condition 'a' is always false [knownConditionTrueFalse]\n", + errout_str()); } void alwaysTrueSymbolic() From bd5ff18da3e72348d694b77214bda95746b2d585 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 12 Feb 2026 08:09:49 +0100 Subject: [PATCH 125/675] Fix #14451 fuzzing crash (stack-overflow) in CheckNullPointer::nullPointerByDeRefAndCheck() (#8199) --- lib/tokenize.cpp | 2 ++ .../fuzz-crash_c/crash-18b7d7437e79f7e1b843b676e0c3beaf4929d043 | 1 + 2 files changed, 3 insertions(+) create mode 100644 test/cli/fuzz-crash_c/crash-18b7d7437e79f7e1b843b676e0c3beaf4929d043 diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 63358cb8e6f..31551764b7b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8987,6 +8987,8 @@ void Tokenizer::findGarbageCode() const if (!Token::Match(tok->next(), "%name%|*|~")) syntaxError(tok, tok->strAt(-1) + " " + tok->str() + " " + tok->strAt(1)); } + if (Token::Match(tok, ".|-> .|->")) + syntaxError(tok); if (Token::Match(tok, "[{,] . %name%") && !Token::Match(tok->tokAt(3), "[.=[{]")) syntaxError(tok->next()); if (Token::Match(tok, "%name% %op% %name%") && !tok->isKeyword() && tok->next()->isIncDecOp()) diff --git a/test/cli/fuzz-crash_c/crash-18b7d7437e79f7e1b843b676e0c3beaf4929d043 b/test/cli/fuzz-crash_c/crash-18b7d7437e79f7e1b843b676e0c3beaf4929d043 new file mode 100644 index 00000000000..6a015200e02 --- /dev/null +++ b/test/cli/fuzz-crash_c/crash-18b7d7437e79f7e1b843b676e0c3beaf4929d043 @@ -0,0 +1 @@ +v(){p?1:p..} \ No newline at end of file From 052538e8410e5c36115d9310dcdca31ecc125d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 12 Feb 2026 14:46:48 +0100 Subject: [PATCH 126/675] Fix #14475 (Document unknownMacro) (#8194) Co-authored-by: chrchr-github <78114321+chrchr-github@users.noreply.github.com> --- man/checkers/unknownMacro.md | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 man/checkers/unknownMacro.md diff --git a/man/checkers/unknownMacro.md b/man/checkers/unknownMacro.md new file mode 100644 index 00000000000..52599215d89 --- /dev/null +++ b/man/checkers/unknownMacro.md @@ -0,0 +1,68 @@ + +# unknownMacro + +**Message**: There is an unknown macro here somewhere. Configuration is required. If AAA is a macro then please configure it. [unknownMacro] +
+**Category**: Configuration
+**Severity**: Error
+**Language**: C and C++ + +## Description + +Cppcheck has found code that is confusing and does not know how to analyze it. This is a critical +error, the analysis of the whole translation unit is aborted. Such error in a header file can mean +that analysis of many source files are aborted. + +Your code is probably OK but you need to configure Cppcheck to make Cppcheck understand the code +better. + +## How to fix + +Review the configuration. + +If Cppcheck warns about a macro that is defined in a 3rd party library, and there is a cfg file for +that, then a `--library=` option may be a proper solution. + +If Cppcheck warns about a macro that is defined in a header that should be included, make sure that +this header is included properly. Cppcheck must have the include path. + +If Cppcheck warns about a compiler keyword add a `-D` that defines this keyword somehow. I.e. if +cppcheck should just ignore the keyword then an `-DKEYWORD=` option is suggested. + +## Example + +### Example code 1 +``` + fprintf(stderr, "Generating up to " F_U64 " sequences and up to " F_U64 " bases.\n", nSeqs, nBases); +``` + +Warning: + +canu-2.2/src/seqrequester/src/seqrequester/generate.H:72:41: error: There is an unknown macro here somewhere. Configuration is required. If F_U64 is a macro then please configure it. [unknownMacro] + +Fix: + +Somehow `F_U64` must be specified for Cppcheck to be able to analyse this properly. Either: + * Add `-DF_U64="x"` to explicitly tell Cppcheck what it should replace F_U64 with. Or; + * Add `-I..` so that headers are included properly. + * If the symbol is defined in a 3rd party library adding a corresponding `--library=` might solve such issue. + +### Example code 2 +``` +BOTAN_FUNC_ISA("crypto") +void AES_128::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const +``` + +Warning: + +botan-2.19.5+dfsg/src/lib/block/aes/aes_power8/aes_power8.cpp:103:1: error: There is an unknown macro here somewhere. Configuration is required. If BOTAN_FUNC_ISA is a macro then please configure it. [unknownMacro] + +Fix: + +Somehow `BOTAN_FUNC_ISA` must be specified for Cppcheck to be able to analyse this properly. Either: + * Add `-DBOTAN_FUNC_ISA(X)=` to explicitly tell Cppcheck that BOTAN_FUNC_ISA("crypto") should be ignored. Or; + * Add `-I..` so that headers are included properly. + * If the symbol is defined in a 3rd party library adding a corresponding `--library=` might solve such issue. + + + From 6a51ddb47593745fae7017c530b71b89df58cba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 13 Feb 2026 08:17:49 +0100 Subject: [PATCH 127/675] CI-cygwin.yml: switched site to https://mirrors:cicku:me/cygwin (#8205) the default https://mirrors.kernel.org/sourceware/cygwin/ is no longer listed on https://cygwin.com/mirrors.html --- .github/workflows/CI-cygwin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI-cygwin.yml b/.github/workflows/CI-cygwin.yml index 445c0953eb5..0eee9446869 100644 --- a/.github/workflows/CI-cygwin.yml +++ b/.github/workflows/CI-cygwin.yml @@ -44,6 +44,7 @@ jobs: - name: Set up Cygwin uses: cygwin/cygwin-install-action@master with: + site: https://mirrors.cicku.me/cygwin/ platform: ${{ matrix.platform }} packages: ${{ matrix.packages }} From fd66b27d2d350c596db0d6b1938b2e93ea3e7c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 13 Feb 2026 09:08:19 +0100 Subject: [PATCH 128/675] extracted redundant selfcheck invocation into shared script (#7617) --- .github/workflows/asan.yml | 15 +--------- .github/workflows/tsan.yml | 16 +--------- .github/workflows/ubsan.yml | 15 +--------- selfcheck_san.sh | 58 +++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 43 deletions(-) create mode 100755 selfcheck_san.sh diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 642dbfd151c..1b7de3e7001 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -142,17 +142,4 @@ jobs: - name: Self check if: false run: | - selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude,information --exception-handling --debug-warnings --check-level=exhaustive" - cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" - gui_options="-DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt" - gui_options="$gui_options --suppress=autoNoType:*/moc_*.cpp --suppress=symbolDatabaseWarning:*/moc_*.cpp" - ec=0 - ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json frontend || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json -Ifrontend cli || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options $gui_options --addon=naming.json --suppress=constVariablePointer:*/moc_*.cpp -Icmake.output/gui -Ifrontend -Igui gui/*.cpp cmake.output/gui || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli -Ifrontend test/*.cpp || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli tools/dmake/*.cpp || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options $gui_options -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage || ec=1 - exit $ec + ./selfcheck_san.sh ./cmake.output diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml index cd1fad16751..0c29d903034 100644 --- a/.github/workflows/tsan.yml +++ b/.github/workflows/tsan.yml @@ -143,18 +143,4 @@ jobs: - name: Self check if: false run: | - selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude,information --exception-handling --debug-warnings --check-level=exhaustive" - selfcheck_options="$selfcheck_options --executor=thread" - cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" - gui_options="-DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt" - gui_options="$gui_options --suppress=autoNoType:*/moc_*.cpp --suppress=symbolDatabaseWarning:*/moc_*.cpp" - ec=0 - ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json frontend || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json -Ifrontend cli || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options $gui_options --addon=naming.json --suppress=constVariablePointer:*/moc_*.cpp -Icmake.output/gui -Ifrontend -Igui gui/*.cpp cmake.output/gui || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli -Ifrontend test/*.cpp || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli tools/dmake/*.cpp || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options $gui_options -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage || ec=1 - exit $ec + ./selfcheck_san.sh ./cmake.output "--executor=thread --error-exitcode=0" diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index ecfe0f05379..7be2c511015 100644 --- a/.github/workflows/ubsan.yml +++ b/.github/workflows/ubsan.yml @@ -137,17 +137,4 @@ jobs: # TODO: only fail the step on sanitizer issues - since we use processes it will only fail the underlying process which will result in an cppcheckError - name: Self check run: | - selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude,information --exception-handling --debug-warnings --check-level=exhaustive" - cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" - gui_options="-DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt" - gui_options="$gui_options --suppress=autoNoType:*/moc_*.cpp --suppress=symbolDatabaseWarning:*/moc_*.cpp" - ec=0 - ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json frontend || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json -Ifrontend cli || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options $gui_options --addon=naming.json --suppress=constVariablePointer:*/moc_*.cpp -Icmake.output/gui -Ifrontend -Igui gui/*.cpp cmake.output/gui || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli -Ifrontend test/*.cpp || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli tools/dmake/*.cpp || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options $gui_options -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage || ec=1 - exit $ec + ./selfcheck_san.sh ./cmake.output diff --git a/selfcheck_san.sh b/selfcheck_san.sh new file mode 100755 index 00000000000..f300d8be2df --- /dev/null +++ b/selfcheck_san.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +cmake_output="$1" +selfcheck_options_extra="$2" + +selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude,information --exception-handling --debug-warnings --check-level=exhaustive" +selfcheck_options="$selfcheck_options $selfcheck_options_extra" +cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" +qt_options="--library=qt -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_MOC_HAS_STRINGDATA" +qt_options="$qt_options --suppress=autoNoType:*/moc_*.cpp --suppress=symbolDatabaseWarning:*/moc_*.cpp" + +ec=0 + +$cmake_output/bin/cppcheck $selfcheck_options \ + externals \ + || ec=1 + +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options \ + --addon=naming.json \ + frontend \ + || ec=1 + +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options \ + --addon=naming.json \ + -Ifrontend \ + cli \ + || ec=1 + +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options \ + --addon=naming.json \ + --enable=internal \ + lib \ + || ec=1 + +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options $qt_options \ + --addon=naming.json \ + --suppress=constVariablePointer:*/moc_*.cpp \ + -DQT_CHARTS_LIB \ + -I$cmake_output/gui -Ifrontend -Igui \ + gui/*.cpp $cmake_output/gui \ + || ec=1 + +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options \ + -Icli -Ifrontend \ + test/*.cpp \ + || ec=1 + +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options \ + -Icli \ + tools/dmake/*.cpp \ + || ec=1 + +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options $qt_options \ + -I$cmake_output/tools/triage -Igui \ + tools/triage/*.cpp $cmake_output/tools/triage \ + || ec=1 + +exit $ec \ No newline at end of file From e4a8480aae5cc8864ab0853d66be9ac6b8498055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 13 Feb 2026 13:09:04 +0100 Subject: [PATCH 129/675] Fix #14488 (GUI: The Misra C checkbox in "Edit Project" dialog is unchecked) (#8206) --- gui/manualtest/projectfiledialog.md | 18 ++++++++++++++++++ gui/projectfiledialog.cpp | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gui/manualtest/projectfiledialog.md diff --git a/gui/manualtest/projectfiledialog.md b/gui/manualtest/projectfiledialog.md new file mode 100644 index 00000000000..e8ce09cc96e --- /dev/null +++ b/gui/manualtest/projectfiledialog.md @@ -0,0 +1,18 @@ + +# Project file dialog + +Some manual testing in the project file dialog interface + + +## Test: Misra C checkbox + +Matrix: Use both open source and premium + +1. Load project file in trac ticket 14488 +1. Goto "Edit project" +1. Goto "Addons" tab + +EXPECTED: The misra c checkbox should be checked + +TODO: can this test be automated + diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 33329411db0..eeee66231b7 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -414,8 +414,8 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile) mUI->mMisraC->setText("Misra C"); else { mUI->mMisraC->setText("Misra C 2012 " + tr("Note: Open source Cppcheck does not fully implement Misra C 2012")); - updateAddonCheckBox(mUI->mMisraC, projectFile, dataDir, ADDON_MISRA); } + updateAddonCheckBox(mUI->mMisraC, projectFile, dataDir, ADDON_MISRA); mUI->mMisraVersion->setEnabled(mUI->mMisraC->isChecked()); connect(mUI->mMisraC, &QCheckBox::toggled, mUI->mMisraVersion, &QComboBox::setEnabled); From 50fa3b4e55c451dffbd5aba42f2ba0bd6df0b0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 13 Feb 2026 16:06:48 +0100 Subject: [PATCH 130/675] ValueFlow: avoid various unnecessary copies (#8207) --- lib/valueflow.cpp | 13 +++--- lib/vf_settokenvalue.cpp | 96 +++++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 57 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 86b49c0b137..7aa0ce4aac6 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1511,7 +1511,7 @@ ValueFlow::Value ValueFlow::getLifetimeObjValue(const Token *tok, bool inconclus // There should only be one lifetime if (values.size() != 1) return ValueFlow::Value{}; - return values.front(); + return std::move(values.front()); } template @@ -3652,7 +3652,7 @@ static void valueFlowSymbolicOperators(const SymbolDatabase& symboldatabase, con continue; ValueFlow::Value v = makeSymbolic(arg); - v.errorPath = c.errorPath; + v.errorPath = std::move(c.errorPath); v.errorPath.emplace_back(tok, "Passed to " + tok->str()); if (c.intvalue == 0) v.setImpossible(); @@ -5070,8 +5070,7 @@ static void valueFlowInferCondition(TokenList& tokenlist, const Settings& settin std::vector result = infer(makeIntegralInferModel(), "!=", tok->values(), 0); if (result.size() != 1) continue; - ValueFlow::Value value = result.front(); - setTokenValue(tok, std::move(value), settings); + setTokenValue(tok, std::move(result.front()), settings); } } } @@ -5490,7 +5489,7 @@ static void valueFlowInjectParameter(const TokenList& tokenlist, const Settings& settings, const Variable* arg, const Scope* functionScope, - const std::list& argvalues) + std::list argvalues) { // Is argument passed by value or const reference, and is it a known non-class type? if (arg->isReference() && !arg->isConst() && !arg->isClass()) @@ -5504,7 +5503,7 @@ static void valueFlowInjectParameter(const TokenList& tokenlist, valueFlowForward(const_cast(functionScope->bodyStart->next()), functionScope->bodyEnd, arg->nameToken(), - argvalues, + std::move(argvalues), tokenlist, errorLogger, settings); @@ -5731,7 +5730,7 @@ static void valueFlowFunctionDefaultParameter(const TokenList& tokenlist, const argvalues.push_back(std::move(v)); } if (!argvalues.empty()) - valueFlowInjectParameter(tokenlist, errorLogger, settings, var, scope, argvalues); + valueFlowInjectParameter(tokenlist, errorLogger, settings, var, scope, std::move(argvalues)); } } } diff --git a/lib/vf_settokenvalue.cpp b/lib/vf_settokenvalue.cpp index 4d39d35daae..b2647bf46ec 100644 --- a/lib/vf_settokenvalue.cpp +++ b/lib/vf_settokenvalue.cpp @@ -126,32 +126,31 @@ namespace ValueFlow return value.isIntValue() || value.isFloatValue(); } - static void setTokenValueCast(Token *parent, const ValueType &valueType, const Value &value, const Settings &settings) + static void setTokenValueCast(Token *parent, const ValueType &valueType, Value value, const Settings &settings) { if (valueType.pointer || value.isImpossible()) - setTokenValue(parent,value,settings); + setTokenValue(parent,std::move(value),settings); else if (valueType.type == ValueType::Type::CHAR) - setTokenValue(parent, castValue(value, valueType.sign, settings.platform.char_bit), settings); + setTokenValue(parent, castValue(std::move(value), valueType.sign, settings.platform.char_bit), settings); else if (valueType.type == ValueType::Type::SHORT) - setTokenValue(parent, castValue(value, valueType.sign, settings.platform.short_bit), settings); + setTokenValue(parent, castValue(std::move(value), valueType.sign, settings.platform.short_bit), settings); else if (valueType.type == ValueType::Type::INT) - setTokenValue(parent, castValue(value, valueType.sign, settings.platform.int_bit), settings); + setTokenValue(parent, castValue(std::move(value), valueType.sign, settings.platform.int_bit), settings); else if (valueType.type == ValueType::Type::LONG) - setTokenValue(parent, castValue(value, valueType.sign, settings.platform.long_bit), settings); + setTokenValue(parent, castValue(std::move(value), valueType.sign, settings.platform.long_bit), settings); else if (valueType.type == ValueType::Type::LONGLONG) - setTokenValue(parent, castValue(value, valueType.sign, settings.platform.long_long_bit), settings); + setTokenValue(parent, castValue(std::move(value), valueType.sign, settings.platform.long_long_bit), settings); else if (valueType.isFloat() && isNumeric(value)) { - Value floatValue = value; - floatValue.valueType = Value::ValueType::FLOAT; if (value.isIntValue()) - floatValue.floatValue = static_cast(value.intvalue); - setTokenValue(parent, std::move(floatValue), settings); + value.floatValue = static_cast(value.intvalue); + value.valueType = Value::ValueType::FLOAT; + setTokenValue(parent, std::move(value), settings); } else if (value.isIntValue()) { const long long charMax = settings.platform.signedCharMax(); const long long charMin = settings.platform.signedCharMin(); if (charMin <= value.intvalue && value.intvalue <= charMax) { // unknown type, but value is small so there should be no truncation etc - setTokenValue(parent,value,settings); + setTokenValue(parent,std::move(value),settings); } } } @@ -307,22 +306,23 @@ namespace ValueFlow value.valueType = Value::ValueType::INT; setTokenValue(next, std::move(value), settings); } else if (yields == Library::Container::Yield::EMPTY) { - Value v(value); - v.valueType = Value::ValueType::INT; - v.bound = Value::Bound::Point; + const Value::Bound bound = value.bound; + const long long intvalue = value.intvalue; + value.valueType = Value::ValueType::INT; + value.bound = Value::Bound::Point; if (value.isImpossible()) { - if (value.intvalue == 0) - v.setKnown(); - else if ((value.bound == Value::Bound::Upper && value.intvalue > 0) || - (value.bound == Value::Bound::Lower && value.intvalue < 0)) { - v.intvalue = 0; - v.setKnown(); + if (intvalue == 0) + value.setKnown(); + else if ((bound == Value::Bound::Upper && intvalue > 0) || + (bound == Value::Bound::Lower && intvalue < 0)) { + value.intvalue = 0; + value.setKnown(); } else - v.setPossible(); + value.setPossible(); } else { - v.intvalue = !v.intvalue; + value.intvalue = !value.intvalue; } - setTokenValue(next, std::move(v), settings); + setTokenValue(next, std::move(value), settings); } return; } @@ -346,27 +346,26 @@ namespace ValueFlow setTokenValue(parent, std::move(value), settings); return; } - Value pvalue = value; if (!value.subexpressions.empty() && Token::Match(parent, ". %var%")) { if (contains(value.subexpressions, parent->strAt(1))) - pvalue.subexpressions.clear(); + value.subexpressions.clear(); else return; } if (parent->isUnaryOp("&")) { - pvalue.indirect++; - setTokenValue(parent, std::move(pvalue), settings); + value.indirect++; + setTokenValue(parent, std::move(value), settings); } else if (Token::Match(parent, ". %var%") && parent->astOperand1() == tok && parent->astOperand2()) { - if (parent->originalName() == "->" && pvalue.indirect > 0) - pvalue.indirect--; - setTokenValue(parent->astOperand2(), std::move(pvalue), settings); + if (parent->originalName() == "->" && value.indirect > 0) + value.indirect--; + setTokenValue(parent->astOperand2(), std::move(value), settings); } else if (Token::Match(parent->astParent(), ". %var%") && parent->astParent()->astOperand1() == parent) { - if (parent->astParent()->originalName() == "->" && pvalue.indirect > 0) - pvalue.indirect--; - setTokenValue(parent->astParent()->astOperand2(), std::move(pvalue), settings); - } else if (parent->isUnaryOp("*") && pvalue.indirect > 0) { - pvalue.indirect--; - setTokenValue(parent, std::move(pvalue), settings); + if (parent->astParent()->originalName() == "->" && value.indirect > 0) + value.indirect--; + setTokenValue(parent->astParent()->astOperand2(), std::move(value), settings); + } else if (parent->isUnaryOp("*") && value.indirect > 0) { + value.indirect--; + setTokenValue(parent, std::move(value), settings); } return; } @@ -382,7 +381,7 @@ namespace ValueFlow && tok->valueType()->getSizeOf(settings, ValueType::Accuracy::ExactOrZero, ValueType::SizeOf::Pointer) >= valueType.getSizeOf(settings, ValueType::Accuracy::ExactOrZero, ValueType::SizeOf::Pointer)) return; - setTokenValueCast(parent, valueType, value, settings); + setTokenValueCast(parent, valueType, std::move(value), settings); } else if (parent->str() == ":") { @@ -421,11 +420,10 @@ namespace ValueFlow if (ret) return; - Value v(std::move(value)); - v.conditional = true; - v.changeKnownToPossible(); + value.conditional = true; + value.changeKnownToPossible(); - setTokenValue(parent, std::move(v), settings); + setTokenValue(parent, std::move(value), settings); } } @@ -713,15 +711,13 @@ namespace ValueFlow std::vector args = getArguments(value.tokvalue); if (const Library::Function* f = settings.library.getFunction(parent->previous())) { if (f->containerYield == Library::Container::Yield::SIZE) { - Value v(std::move(value)); - v.valueType = Value::ValueType::INT; - v.intvalue = args.size(); - setTokenValue(parent, std::move(v), settings); + value.valueType = Value::ValueType::INT; + value.intvalue = args.size(); + setTokenValue(parent, std::move(value), settings); } else if (f->containerYield == Library::Container::Yield::EMPTY) { - Value v(std::move(value)); - v.intvalue = args.empty(); - v.valueType = Value::ValueType::INT; - setTokenValue(parent, std::move(v), settings); + value.intvalue = args.empty(); + value.valueType = Value::ValueType::INT; + setTokenValue(parent, std::move(value), settings); } } } From 1c65d48db6e73c7fd9cca57721f9271a14b4fc25 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 14 Feb 2026 13:35:48 +0100 Subject: [PATCH 131/675] Fix #14485 FP uninitdata with cast (#8209) --- lib/checkuninitvar.cpp | 2 +- test/testuninitvar.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 014031259e4..d2e72e0c82f 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1243,7 +1243,7 @@ const Token* CheckUninitVar::isVariableUsage(const Token *vartok, const Library& return nullptr; } if (alloc != NO_ALLOC) { - if (Token::Match(valueExpr->astParent(), "%comp%|%oror%|&&|?|!")) + if (Token::Match(valueExpr->astParent(), "%comp%|%oror%|&&|?|!|%")) return nullptr; if (Token::Match(valueExpr->astParent(), "%or%|&") && valueExpr->astParent()->isBinaryOp()) return nullptr; diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index cf5bf42f635..15467db7971 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2164,6 +2164,13 @@ class TestUninitVar : public TestFixture { " return p;\n" "}\n"); ASSERT_EQUALS("[test.cpp:5:9]: (error) Memory is allocated but not initialized: *p [uninitdata]\n", errout_str()); + + checkUninitVar("char* f(size_t nBytes, size_t nAlign) {\n" // #14485 + " char* p = reinterpret_cast(malloc(nBytes));\n" + " if ((uintptr_t)p % nAlign != 0) {}\n" + " return p;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } // class / struct.. From fbb105553604a6395298c6bc6ec6f43e966aa56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 14 Feb 2026 14:42:43 +0100 Subject: [PATCH 132/675] Fix #14489 (GUI: The platform files are not shown in the dropdown in ProjectFileDialog) (#8214) --- gui/manualtest/projectfiledialog.md | 13 +++++++++++ gui/projectfile.cpp | 21 ++++++++++++++++++ gui/projectfile.h | 4 ++++ gui/projectfiledialog.cpp | 28 ++++-------------------- gui/test/projectfile/CMakeLists.txt | 1 + gui/test/projectfile/testprojectfile.cpp | 18 +++++++++++++++ gui/test/projectfile/testprojectfile.h | 1 + gui/test/resultstree/CMakeLists.txt | 2 ++ gui/test/resultstree/testresultstree.cpp | 4 ---- 9 files changed, 64 insertions(+), 28 deletions(-) diff --git a/gui/manualtest/projectfiledialog.md b/gui/manualtest/projectfiledialog.md index e8ce09cc96e..eb76109e53e 100644 --- a/gui/manualtest/projectfiledialog.md +++ b/gui/manualtest/projectfiledialog.md @@ -4,8 +4,21 @@ Some manual testing in the project file dialog interface + +## Test: Platform files + +Ticket: #14489 + +EXPECTED: In the project file dialog it should be possible to select xml files i.e. pic8.xml + +TODO: can this test be automated + + + ## Test: Misra C checkbox +Ticket: #14488 + Matrix: Use both open source and premium 1. Load project file in trac ticket 14488 diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index 3e4e783d7a8..d2913fbfd65 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -1176,3 +1177,23 @@ QString ProjectFile::getAddonFilePath(QString filesDir, const QString &addon) return QString(); } + +QStringList ProjectFile::getSearchPaths(const QString& projectPath, const QString& appPath, const QString& datadir, const QString& dir) { + QStringList ret; + ret << appPath << (appPath + "/" + dir) << projectPath; +#ifdef FILESDIR + if (FILESDIR[0]) + ret << FILESDIR << (FILESDIR "/" + dir); +#endif + if (!datadir.isEmpty()) + ret << datadir << (datadir + "/" + dir); + return ret; +} + +QStringList ProjectFile::getSearchPaths(const QString& dir) const { + const QFileInfo inf(mFilename); + const QString applicationFilePath = QCoreApplication::applicationFilePath(); + const QString appPath = QFileInfo(applicationFilePath).canonicalPath(); + const QString datadir = getDataDir(); + return getSearchPaths(inf.canonicalFilePath(), appPath, datadir, dir); +} diff --git a/gui/projectfile.h b/gui/projectfile.h index 18503e8d6e1..01abe0643a5 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -446,6 +446,10 @@ class ProjectFile : public QObject { /** Use Clang parser */ bool clangParser; + /** Get paths where we should glob for certain files (dir="cfg"/"platforms"/etc */ + QStringList getSearchPaths(const QString& dir) const; + static QStringList getSearchPaths(const QString& projectPath, const QString& appPath, const QString& datadir, const QString& dir); + protected: /** diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index eeee66231b7..76fe51d2274 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -142,22 +141,10 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi mUI->premiumLicense->setVisible(false); - // Checkboxes for the libraries.. - const QString applicationFilePath = QCoreApplication::applicationFilePath(); - const QString appPath = QFileInfo(applicationFilePath).canonicalPath(); - const QString datadir = getDataDir(); - QStringList searchPaths; - searchPaths << appPath << appPath + "/cfg" << inf.canonicalPath(); -#ifdef FILESDIR - if (FILESDIR[0]) - searchPaths << FILESDIR << FILESDIR "/cfg"; -#endif - if (!datadir.isEmpty()) - searchPaths << datadir << datadir + "/cfg"; QStringList libs; // Search the std.cfg first since other libraries could depend on it QString stdLibraryFilename; - for (const QString &sp : searchPaths) { + for (const QString &sp : projectFile->getSearchPaths("cfg")) { QDir dir(sp); dir.setSorting(QDir::Name); dir.setNameFilters(QStringList("*.cfg")); @@ -179,7 +166,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi break; } // Search other libraries - for (const QString &sp : searchPaths) { + for (const QString &sp : projectFile->getSearchPaths("cfg")) { QDir dir(sp); dir.setSorting(QDir::Name); dir.setNameFilters(QStringList("*.cfg")); @@ -218,22 +205,15 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi for (const Platform::Type builtinPlatform : builtinPlatforms) mUI->mComboBoxPlatform->addItem(platforms.get(builtinPlatform).mTitle); QStringList platformFiles; - for (QString sp : searchPaths) { - if (sp.endsWith("/cfg")) - sp = sp.mid(0,sp.length()-3) + "platforms"; + for (const QString& sp : projectFile->getSearchPaths("platforms")) { QDir dir(sp); dir.setSorting(QDir::Name); dir.setNameFilters(QStringList("*.xml")); dir.setFilter(QDir::Files | QDir::NoDotAndDotDot); for (const QFileInfo& item : dir.entryInfoList()) { const QString platformFile = item.fileName(); - - const std::vector paths = { - Path::getCurrentPath(), // TODO: do we want to look in CWD? - applicationFilePath.toStdString(), - }; Platform plat2; - if (!plat2.loadFromFile(paths, platformFile.toStdString())) + if (!plat2.loadFromFile({sp.toStdString()}, platformFile.toStdString())) continue; if (platformFiles.indexOf(platformFile) == -1) diff --git a/gui/test/projectfile/CMakeLists.txt b/gui/test/projectfile/CMakeLists.txt index 2d9c254ec5f..f9bab8ba0c7 100644 --- a/gui/test/projectfile/CMakeLists.txt +++ b/gui/test/projectfile/CMakeLists.txt @@ -4,6 +4,7 @@ add_dependencies(gui-build-deps build-projectfile-deps) add_executable(test-projectfile ${test-projectfile_SRC} testprojectfile.cpp + ${CMAKE_SOURCE_DIR}/gui/common.cpp ${CMAKE_SOURCE_DIR}/gui/projectfile.cpp ) target_include_directories(test-projectfile PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib) diff --git a/gui/test/projectfile/testprojectfile.cpp b/gui/test/projectfile/testprojectfile.cpp index 988d62e8bce..b38de056ec3 100644 --- a/gui/test/projectfile/testprojectfile.cpp +++ b/gui/test/projectfile/testprojectfile.cpp @@ -136,6 +136,24 @@ void TestProjectFile::getAddonFilePath() const QCOMPARE(ProjectFile::getAddonFilePath(tempdir.path(), filepath), filepath); } +void TestProjectFile::getSearchPaths() const +{ +#ifdef FILESDIR + const QString f(FILESDIR "\n" // example: "/usr/local/share/cppcheck\n" + FILESDIR "/dir\n"); // example: "/usr/local/share/cppcheck/dir\n" +#else + const QString f; +#endif + + QCOMPARE(ProjectFile::getSearchPaths("projectPath", "appPath", "datadir", "dir").join("\n"), + "appPath\n" + "appPath/dir\n" + "projectPath\n" + + f + + "datadir\n" + "datadir/dir"); +} + void TestProjectFile::getInlineSuppressionDefaultValue() const { ProjectFile projectFile; diff --git a/gui/test/projectfile/testprojectfile.h b/gui/test/projectfile/testprojectfile.h index 8f3e54c3008..027c7069706 100644 --- a/gui/test/projectfile/testprojectfile.h +++ b/gui/test/projectfile/testprojectfile.h @@ -28,6 +28,7 @@ private slots: void loadSimpleNoroot() const; void getAddonFilePath() const; + void getSearchPaths() const; void getInlineSuppressionDefaultValue() const; void getInlineSuppression() const; diff --git a/gui/test/resultstree/CMakeLists.txt b/gui/test/resultstree/CMakeLists.txt index 1bf8a02ffb1..a48b137e349 100644 --- a/gui/test/resultstree/CMakeLists.txt +++ b/gui/test/resultstree/CMakeLists.txt @@ -3,6 +3,7 @@ qt_wrap_cpp(test-resultstree_SRC ${CMAKE_SOURCE_DIR}/gui/resultstree.h ${CMAKE_SOURCE_DIR}/gui/resultitem.h ${CMAKE_SOURCE_DIR}/gui/applicationlist.h + ${CMAKE_SOURCE_DIR}/gui/common.h ${CMAKE_SOURCE_DIR}/gui/projectfile.h ${CMAKE_SOURCE_DIR}/gui/threadhandler.h ${CMAKE_SOURCE_DIR}/gui/threadresult.h @@ -14,6 +15,7 @@ add_executable(test-resultstree testresultstree.cpp ${CMAKE_SOURCE_DIR}/gui/resultstree.cpp ${CMAKE_SOURCE_DIR}/gui/resultitem.cpp + ${CMAKE_SOURCE_DIR}/gui/common.cpp ${CMAKE_SOURCE_DIR}/gui/erroritem.cpp ${CMAKE_SOURCE_DIR}/gui/showtypes.cpp ${CMAKE_SOURCE_DIR}/gui/report.cpp diff --git a/gui/test/resultstree/testresultstree.cpp b/gui/test/resultstree/testresultstree.cpp index ac3ba4ff78c..732ee0715d0 100644 --- a/gui/test/resultstree/testresultstree.cpp +++ b/gui/test/resultstree/testresultstree.cpp @@ -99,10 +99,6 @@ Application& ApplicationList::getApplication(const int /*unused*/) { const Application& ApplicationList::getApplication(const int index) const { return mApplications.at(index); } -QString getPath(const QString &type) { - return "/" + type; -} -void setPath(const QString & /*unused*/, const QString & /*unused*/) {} QString XmlReport::quoteMessage(const QString &message) { return message; } From 952f81c95b82ec74d115b312d071ab416a9bf976 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 14 Feb 2026 14:45:30 +0100 Subject: [PATCH 133/675] Fix #14438 fuzzing crash (null-pointer-use) in singleAssignInScope() (#8201) --- lib/tokenize.cpp | 4 ++-- .../fuzz-crash/crash-c540e04fe675639b7ead821efc2f5c037b6c89e0 | 1 + test/testgarbage.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 test/cli/fuzz-crash/crash-c540e04fe675639b7ead821efc2f5c037b6c89e0 diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 31551764b7b..7c15be961bc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9018,8 +9018,8 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::Match(tok, "? %assign%")) syntaxError(tok); - if (Token::Match(tok, "!|~ %comp%") && - !(cpp && tok->strAt(1) == ">" && Token::simpleMatch(tok->tokAt(-1), "operator"))) + if (Token::Match(tok, "[!~+-/] %comp%") && + !(cpp && Token::Match(tok->next(), "[<>]") && Token::simpleMatch(tok->tokAt(-1), "operator"))) syntaxError(tok); if (Token::Match(tok, "%comp% {") && (!cpp || tok->str() != ">")) syntaxError(tok); diff --git a/test/cli/fuzz-crash/crash-c540e04fe675639b7ead821efc2f5c037b6c89e0 b/test/cli/fuzz-crash/crash-c540e04fe675639b7ead821efc2f5c037b6c89e0 new file mode 100644 index 00000000000..f2fb80ecd28 --- /dev/null +++ b/test/cli/fuzz-crash/crash-c540e04fe675639b7ead821efc2f5c037b6c89e0 @@ -0,0 +1 @@ +o o(){i n;for(i x:v)n=n+<1;} diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 21a15082bc1..aaacfeda3ff 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -848,7 +848,7 @@ class TestGarbage : public TestFixture { } void garbageCode95() { // #6804 - ASSERT_THROW_INTERNAL(checkCode("{ } x x ; { } h h [ ] ( ) ( ) { struct x ( x ) ; int __attribute__ ( ) f ( ) { h - > first = & x ; struct x * n = h - > first ; ( ) n > } }"), AST); // do not crash + ASSERT_THROW_INTERNAL(checkCode("{ } x x ; { } h h [ ] ( ) ( ) { struct x ( x ) ; int __attribute__ ( ) f ( ) { h - > first = & x ; struct x * n = h - > first ; ( ) n > } }"), SYNTAX); // do not crash } void garbageCode96() { // #6807 From 3dc52dc576591f175cc3caeee31aed59775944d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 14 Feb 2026 14:45:54 +0100 Subject: [PATCH 134/675] Fix #14492 (Import checkers for checkers-report from addon json) (#8216) --- lib/addoninfo.cpp | 22 ++ lib/addoninfo.h | 2 + lib/checkers.cpp | 793 +---------------------------------------- lib/checkers.h | 1 - lib/checkersreport.cpp | 122 ++----- test/cli/other_test.py | 8 +- tools/get_checkers.py | 6 - 7 files changed, 55 insertions(+), 899 deletions(-) diff --git a/lib/addoninfo.cpp b/lib/addoninfo.cpp index a2426d91999..ed10435a368 100644 --- a/lib/addoninfo.cpp +++ b/lib/addoninfo.cpp @@ -114,6 +114,28 @@ static std::string parseAddonInfo(AddonInfo& addoninfo, const picojson::value &j } } + { + const auto it = obj.find("checkers"); + if (it != obj.cend()) { + const auto& val = it->second; + if (!val.is()) + return "Loading " + fileName + " failed. 'checkers' must be an array."; + for (const picojson::value &v : val.get()) { + if (!v.is()) + return "Loading " + fileName + " failed. 'checkers' entry is not an object."; + + const picojson::object& checkerObj = v.get(); + if (checkerObj.size() == 1) { + const std::string c = checkerObj.begin()->first; + if (!checkerObj.begin()->second.is()) + return "Loading " + fileName + " failed. 'checkers' entry requirement is not a string."; + const std::string req = checkerObj.begin()->second.get(); + addoninfo.checkers.emplace(c, req); + } + } + } + } + { const auto it = obj.find("executable"); if (it != obj.cend()) { diff --git a/lib/addoninfo.h b/lib/addoninfo.h index 592833c2162..dacb49be2df 100644 --- a/lib/addoninfo.h +++ b/lib/addoninfo.h @@ -22,6 +22,7 @@ #include "config.h" #include +#include struct CPPCHECKLIB AddonInfo { std::string name; @@ -31,6 +32,7 @@ struct CPPCHECKLIB AddonInfo { std::string python; // script interpreter bool ctu = false; std::string runScript; + std::map checkers; // checker name and its requirement std::string getAddonInfo(const std::string &fileName, const std::string &exename, bool debug = false); }; diff --git a/lib/checkers.cpp b/lib/checkers.cpp index a84da1bc986..e374058f332 100644 --- a/lib/checkers.cpp +++ b/lib/checkers.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -211,797 +211,6 @@ namespace checkers { {"CheckVaarg::va_start_argument",""}, }; - const std::map premiumCheckers{ - {"Autosar: A0-1-3",""}, - {"Autosar: A0-1-4",""}, - {"Autosar: A0-1-5",""}, - {"Autosar: A0-1-6",""}, - {"Autosar: A0-4-2",""}, - {"Autosar: A0-4-4",""}, - {"Autosar: A10-1-1",""}, - {"Autosar: A11-0-2",""}, - {"Autosar: A11-3-1",""}, - {"Autosar: A13-2-1",""}, - {"Autosar: A13-2-3",""}, - {"Autosar: A13-5-2",""}, - {"Autosar: A13-5-5",""}, - {"Autosar: A15-1-2",""}, - {"Autosar: A15-3-5",""}, - {"Autosar: A16-6-1",""}, - {"Autosar: A16-7-1",""}, - {"Autosar: A18-0-3",""}, - {"Autosar: A18-1-1",""}, - {"Autosar: A18-1-2",""}, - {"Autosar: A18-1-3",""}, - {"Autosar: A18-5-1",""}, - {"Autosar: A18-9-1",""}, - {"Autosar: A2-11-1",""}, - {"Autosar: A2-13-1",""}, - {"Autosar: A2-13-3",""}, - {"Autosar: A2-13-5",""}, - {"Autosar: A2-5-2",""}, - {"Autosar: A2-7-1",""}, - {"Autosar: A20-8-2","warning"}, - {"Autosar: A20-8-3","warning"}, - {"Autosar: A20-8-4",""}, - {"Autosar: A20-8-5",""}, - {"Autosar: A20-8-6",""}, - {"Autosar: A21-8-1","warning"}, - {"Autosar: A23-0-1",""}, - {"Autosar: A25-1-1","warning"}, - {"Autosar: A25-4-1","warning"}, - {"Autosar: A26-5-1",""}, - {"Autosar: A26-5-2",""}, - {"Autosar: A27-0-1","warning"}, - {"Autosar: A27-0-2",""}, - {"Autosar: A27-0-4",""}, - {"Autosar: A3-1-3",""}, - {"Autosar: A3-1-4",""}, - {"Autosar: A3-3-1",""}, - {"Autosar: A3-9-1",""}, - {"Autosar: A4-10-1",""}, - {"Autosar: A4-7-1",""}, - {"Autosar: A5-0-2",""}, - {"Autosar: A5-0-3",""}, - {"Autosar: A5-0-4",""}, - {"Autosar: A5-1-1",""}, - {"Autosar: A5-1-2",""}, - {"Autosar: A5-1-3",""}, - {"Autosar: A5-1-6",""}, - {"Autosar: A5-1-7",""}, - {"Autosar: A5-16-1",""}, - {"Autosar: A5-2-1",""}, - {"Autosar: A5-2-3",""}, - {"Autosar: A5-2-4",""}, - {"Autosar: A5-3-3",""}, - {"Autosar: A6-5-3",""}, - {"Autosar: A7-1-4",""}, - {"Autosar: A7-1-6",""}, - {"Autosar: A7-1-7",""}, - {"Autosar: A7-2-1",""}, - {"Autosar: A7-2-2",""}, - {"Autosar: A7-6-1",""}, - {"Autosar: A8-4-1",""}, - {"Autosar: A8-5-3",""}, - {"Autosar: A9-3-1",""}, - {"Cert C++: CON50-CPP",""}, - {"Cert C++: CON51-CPP",""}, - {"Cert C++: CON52-CPP",""}, - {"Cert C++: CON53-CPP",""}, - {"Cert C++: CON54-CPP",""}, - {"Cert C++: CON55-CPP",""}, - {"Cert C++: CON56-CPP",""}, - {"Cert C++: CTR50-CPP",""}, - {"Cert C++: CTR52-CPP",""}, - {"Cert C++: CTR53-CPP",""}, - {"Cert C++: CTR56-CPP",""}, - {"Cert C++: CTR57-CPP","warning"}, - {"Cert C++: CTR58-CPP","warning"}, - {"Cert C++: DCL50-CPP",""}, - {"Cert C++: DCL51-CPP",""}, - {"Cert C++: DCL52-CPP",""}, - {"Cert C++: DCL53-CPP",""}, - {"Cert C++: DCL54-CPP",""}, - {"Cert C++: DCL56-CPP",""}, - {"Cert C++: DCL58-CPP",""}, - {"Cert C++: DCL59-CPP",""}, - {"Cert C++: ERR50-CPP",""}, - {"Cert C++: ERR51-CPP",""}, - {"Cert C++: ERR52-CPP",""}, - {"Cert C++: ERR53-CPP",""}, - {"Cert C++: ERR54-CPP",""}, - {"Cert C++: ERR55-CPP",""}, - {"Cert C++: ERR56-CPP",""}, - {"Cert C++: ERR58-CPP",""}, - {"Cert C++: ERR59-CPP","warning"}, - {"Cert C++: ERR60-CPP","warning"}, - {"Cert C++: ERR61-CPP",""}, - {"Cert C++: ERR62-CPP",""}, - {"Cert C++: EXP50-CPP",""}, - {"Cert C++: EXP51-CPP",""}, - {"Cert C++: EXP54-CPP",""}, - {"Cert C++: EXP55-CPP",""}, - {"Cert C++: EXP56-CPP",""}, - {"Cert C++: EXP57-CPP",""}, - {"Cert C++: EXP58-CPP",""}, - {"Cert C++: EXP59-CPP",""}, - {"Cert C++: EXP60-CPP",""}, - {"Cert C++: FIO51-CPP",""}, - {"Cert C++: INT50-CPP",""}, - {"Cert C++: MEM51-CPP",""}, - {"Cert C++: MEM52-CPP",""}, - {"Cert C++: MEM53-CPP",""}, - {"Cert C++: MEM54-CPP",""}, - {"Cert C++: MEM55-CPP",""}, - {"Cert C++: MEM57-CPP",""}, - {"Cert C++: MSC50-CPP",""}, - {"Cert C++: MSC51-CPP",""}, - {"Cert C++: MSC53-CPP",""}, - {"Cert C++: MSC54-CPP",""}, - {"Cert C++: OOP51-CPP",""}, - {"Cert C++: OOP55-CPP",""}, - {"Cert C++: OOP56-CPP",""}, - {"Cert C++: OOP57-CPP",""}, - {"Cert C++: OOP58-CPP",""}, - {"Cert C++: STR50-CPP",""}, - {"Cert C++: STR53-CPP",""}, - {"Cert C: ARR30-C",""}, - {"Cert C: ARR32-C",""}, - {"Cert C: ARR37-C",""}, - {"Cert C: ARR38-C",""}, - {"Cert C: ARR39-C",""}, - {"Cert C: CON30-C",""}, - {"Cert C: CON31-C",""}, - {"Cert C: CON32-C",""}, - {"Cert C: CON33-C",""}, - {"Cert C: CON34-C",""}, - {"Cert C: CON35-C",""}, - {"Cert C: CON36-C",""}, - {"Cert C: CON37-C",""}, - {"Cert C: CON38-C",""}, - {"Cert C: CON39-C",""}, - {"Cert C: CON40-C",""}, - {"Cert C: CON41-C",""}, - {"Cert C: DCL03-C",""}, - {"Cert C: DCL04-C",""}, - {"Cert C: DCL05-C",""}, - {"Cert C: DCL06-C",""}, - {"Cert C: DCL20-C",""}, - {"Cert C: DCL31-C",""}, - {"Cert C: DCL36-C",""}, - {"Cert C: DCL37-C",""}, - {"Cert C: DCL38-C",""}, - {"Cert C: DCL39-C",""}, - {"Cert C: DCL40-C",""}, - {"Cert C: DCL41-C",""}, - {"Cert C: ENV30-C",""}, - {"Cert C: ENV31-C",""}, - {"Cert C: ENV32-C",""}, - {"Cert C: ENV33-C",""}, - {"Cert C: ENV34-C",""}, - {"Cert C: ERR30-C",""}, - {"Cert C: ERR32-C",""}, - {"Cert C: ERR33-C",""}, - {"Cert C: ERR34-C",""}, - {"Cert C: EXP03-C",""}, - {"Cert C: EXP05-C",""}, - {"Cert C: EXP09-C",""}, - {"Cert C: EXP13-C",""}, - {"Cert C: EXP15-C",""}, - {"Cert C: EXP19-C",""}, - {"Cert C: EXP20-C",""}, - {"Cert C: EXP30-C",""}, - {"Cert C: EXP32-C",""}, - {"Cert C: EXP34-C",""}, - {"Cert C: EXP35-C",""}, - {"Cert C: EXP36-C",""}, - {"Cert C: EXP37-C",""}, - {"Cert C: EXP39-C",""}, - {"Cert C: EXP40-C",""}, - {"Cert C: EXP42-C",""}, - {"Cert C: EXP43-C",""}, - {"Cert C: EXP44-C",""}, - {"Cert C: EXP45-C",""}, - {"Cert C: FIO30-C",""}, - {"Cert C: FIO32-C",""}, - {"Cert C: FIO34-C",""}, - {"Cert C: FIO37-C",""}, - {"Cert C: FIO38-C",""}, - {"Cert C: FIO40-C",""}, - {"Cert C: FIO41-C",""}, - {"Cert C: FIO44-C",""}, - {"Cert C: FIO45-C",""}, - {"Cert C: FLP30-C",""}, - {"Cert C: FLP36-C","portability"}, - {"Cert C: FLP37-C",""}, - {"Cert C: INT17-C",""}, - {"Cert C: INT30-C",""}, - {"Cert C: INT31-C",""}, - {"Cert C: INT32-C",""}, - {"Cert C: INT33-C",""}, - {"Cert C: INT34-C",""}, - {"Cert C: INT35-C",""}, - {"Cert C: INT36-C",""}, - {"Cert C: MEM33-C",""}, - {"Cert C: MEM35-C",""}, - {"Cert C: MEM36-C",""}, - {"Cert C: MSC30-C",""}, - {"Cert C: MSC32-C",""}, - {"Cert C: MSC33-C",""}, - {"Cert C: MSC38-C",""}, - {"Cert C: MSC39-C",""}, - {"Cert C: MSC40-C",""}, - {"Cert C: MSC41-C",""}, - {"Cert C: PRE00-C",""}, - {"Cert C: PRE01-C",""}, - {"Cert C: PRE02-C",""}, - {"Cert C: PRE04-C",""}, - {"Cert C: PRE05-C",""}, - {"Cert C: PRE06-C",""}, - {"Cert C: PRE07-C",""}, - {"Cert C: PRE08-C",""}, - {"Cert C: PRE09-C",""}, - {"Cert C: PRE10-C",""}, - {"Cert C: PRE11-C",""}, - {"Cert C: PRE12-C",""}, - {"Cert C: PRE31-C",""}, - {"Cert C: SIG30-C",""}, - {"Cert C: SIG31-C",""}, - {"Cert C: SIG34-C",""}, - {"Cert C: SIG35-C",""}, - {"Cert C: STR30-C",""}, - {"Cert C: STR31-C",""}, - {"Cert C: STR32-C",""}, - {"Cert C: STR34-C",""}, - {"Cert C: STR38-C",""}, - {"Misra C++ 2008: 3-2-3",""}, - {"Misra C++ 2008: 3-2-4",""}, - {"Misra C++ 2008: 7-5-4",""}, - {"Misra C++ 2008: M0-1-11",""}, - {"Misra C++ 2008: M0-1-12",""}, - {"Misra C++ 2008: M0-1-4",""}, - {"Misra C++ 2008: M0-1-5",""}, - {"Misra C++ 2008: M0-1-7",""}, - {"Misra C++ 2008: M0-1-8",""}, - {"Misra C++ 2008: M0-3-2",""}, - {"Misra C++ 2008: M1-0-1","portability"}, - {"Misra C++ 2008: M10-1-1",""}, - {"Misra C++ 2008: M10-1-2",""}, - {"Misra C++ 2008: M10-1-3",""}, - {"Misra C++ 2008: M10-2-1",""}, - {"Misra C++ 2008: M10-3-1",""}, - {"Misra C++ 2008: M10-3-2",""}, - {"Misra C++ 2008: M10-3-3",""}, - {"Misra C++ 2008: M11-0-1",""}, - {"Misra C++ 2008: M12-1-2",""}, - {"Misra C++ 2008: M12-8-1",""}, - {"Misra C++ 2008: M12-8-2",""}, - {"Misra C++ 2008: M14-5-1","warning"}, - {"Misra C++ 2008: M14-5-2","warning"}, - {"Misra C++ 2008: M14-5-3","warning"}, - {"Misra C++ 2008: M14-6-1","warning"}, - {"Misra C++ 2008: M14-6-2","warning"}, - {"Misra C++ 2008: M14-7-1",""}, - {"Misra C++ 2008: M14-7-2",""}, - {"Misra C++ 2008: M14-7-3",""}, - {"Misra C++ 2008: M14-8-1",""}, - {"Misra C++ 2008: M14-8-2",""}, - {"Misra C++ 2008: M15-0-3",""}, - {"Misra C++ 2008: M15-1-1",""}, - {"Misra C++ 2008: M15-1-2",""}, - {"Misra C++ 2008: M15-1-3",""}, - {"Misra C++ 2008: M15-3-2","warning"}, - {"Misra C++ 2008: M15-3-3",""}, - {"Misra C++ 2008: M15-3-4",""}, - {"Misra C++ 2008: M15-3-6",""}, - {"Misra C++ 2008: M15-3-7",""}, - {"Misra C++ 2008: M15-4-1",""}, - {"Misra C++ 2008: M15-5-2",""}, - {"Misra C++ 2008: M16-0-1",""}, - {"Misra C++ 2008: M16-0-2",""}, - {"Misra C++ 2008: M16-0-3",""}, - {"Misra C++ 2008: M16-0-4",""}, - {"Misra C++ 2008: M16-0-6",""}, - {"Misra C++ 2008: M16-0-7",""}, - {"Misra C++ 2008: M16-0-8",""}, - {"Misra C++ 2008: M16-1-1",""}, - {"Misra C++ 2008: M16-1-2",""}, - {"Misra C++ 2008: M16-2-1",""}, - {"Misra C++ 2008: M16-2-2",""}, - {"Misra C++ 2008: M16-2-3",""}, - {"Misra C++ 2008: M16-2-4",""}, - {"Misra C++ 2008: M16-2-5",""}, - {"Misra C++ 2008: M16-2-6",""}, - {"Misra C++ 2008: M16-3-1",""}, - {"Misra C++ 2008: M16-3-2",""}, - {"Misra C++ 2008: M17-0-1",""}, - {"Misra C++ 2008: M17-0-2",""}, - {"Misra C++ 2008: M17-0-3",""}, - {"Misra C++ 2008: M17-0-5",""}, - {"Misra C++ 2008: M18-0-1",""}, - {"Misra C++ 2008: M18-0-2",""}, - {"Misra C++ 2008: M18-0-3",""}, - {"Misra C++ 2008: M18-0-4",""}, - {"Misra C++ 2008: M18-0-5",""}, - {"Misra C++ 2008: M18-2-1",""}, - {"Misra C++ 2008: M18-4-1",""}, - {"Misra C++ 2008: M18-7-1",""}, - {"Misra C++ 2008: M19-3-1",""}, - {"Misra C++ 2008: M2-10-1",""}, - {"Misra C++ 2008: M2-10-3",""}, - {"Misra C++ 2008: M2-10-4",""}, - {"Misra C++ 2008: M2-10-5",""}, - {"Misra C++ 2008: M2-10-6",""}, - {"Misra C++ 2008: M2-13-2",""}, - {"Misra C++ 2008: M2-13-3",""}, - {"Misra C++ 2008: M2-13-4",""}, - {"Misra C++ 2008: M2-13-5",""}, - {"Misra C++ 2008: M2-3-1",""}, - {"Misra C++ 2008: M2-7-1",""}, - {"Misra C++ 2008: M2-7-2",""}, - {"Misra C++ 2008: M2-7-3",""}, - {"Misra C++ 2008: M27-0-1",""}, - {"Misra C++ 2008: M3-1-1",""}, - {"Misra C++ 2008: M3-1-2",""}, - {"Misra C++ 2008: M3-1-3",""}, - {"Misra C++ 2008: M3-2-1",""}, - {"Misra C++ 2008: M3-3-1",""}, - {"Misra C++ 2008: M3-3-2",""}, - {"Misra C++ 2008: M3-9-1",""}, - {"Misra C++ 2008: M3-9-2",""}, - {"Misra C++ 2008: M3-9-3",""}, - {"Misra C++ 2008: M4-10-1",""}, - {"Misra C++ 2008: M4-10-2",""}, - {"Misra C++ 2008: M4-5-1",""}, - {"Misra C++ 2008: M4-5-2",""}, - {"Misra C++ 2008: M4-5-3",""}, - {"Misra C++ 2008: M5-0-10",""}, - {"Misra C++ 2008: M5-0-11",""}, - {"Misra C++ 2008: M5-0-12",""}, - {"Misra C++ 2008: M5-0-14",""}, - {"Misra C++ 2008: M5-0-15",""}, - {"Misra C++ 2008: M5-0-2",""}, - {"Misra C++ 2008: M5-0-20",""}, - {"Misra C++ 2008: M5-0-21",""}, - {"Misra C++ 2008: M5-0-3",""}, - {"Misra C++ 2008: M5-0-4",""}, - {"Misra C++ 2008: M5-0-5",""}, - {"Misra C++ 2008: M5-0-6",""}, - {"Misra C++ 2008: M5-0-7",""}, - {"Misra C++ 2008: M5-0-8",""}, - {"Misra C++ 2008: M5-0-9",""}, - {"Misra C++ 2008: M5-14-1",""}, - {"Misra C++ 2008: M5-17-1",""}, - {"Misra C++ 2008: M5-18-1",""}, - {"Misra C++ 2008: M5-19-1",""}, - {"Misra C++ 2008: M5-2-1",""}, - {"Misra C++ 2008: M5-2-10",""}, - {"Misra C++ 2008: M5-2-11",""}, - {"Misra C++ 2008: M5-2-12",""}, - {"Misra C++ 2008: M5-2-2",""}, - {"Misra C++ 2008: M5-2-3",""}, - {"Misra C++ 2008: M5-2-5",""}, - {"Misra C++ 2008: M5-2-6",""}, - {"Misra C++ 2008: M5-2-7",""}, - {"Misra C++ 2008: M5-2-8",""}, - {"Misra C++ 2008: M5-2-9",""}, - {"Misra C++ 2008: M5-3-1",""}, - {"Misra C++ 2008: M5-3-2",""}, - {"Misra C++ 2008: M5-3-3",""}, - {"Misra C++ 2008: M6-2-1",""}, - {"Misra C++ 2008: M6-2-2",""}, - {"Misra C++ 2008: M6-2-3",""}, - {"Misra C++ 2008: M6-3-1",""}, - {"Misra C++ 2008: M6-4-1",""}, - {"Misra C++ 2008: M6-4-2",""}, - {"Misra C++ 2008: M6-4-3",""}, - {"Misra C++ 2008: M6-4-4",""}, - {"Misra C++ 2008: M6-4-5",""}, - {"Misra C++ 2008: M6-4-6",""}, - {"Misra C++ 2008: M6-4-7",""}, - {"Misra C++ 2008: M6-4-8",""}, - {"Misra C++ 2008: M6-5-1",""}, - {"Misra C++ 2008: M6-5-2",""}, - {"Misra C++ 2008: M6-5-3",""}, - {"Misra C++ 2008: M6-5-4",""}, - {"Misra C++ 2008: M6-5-5",""}, - {"Misra C++ 2008: M6-5-6",""}, - {"Misra C++ 2008: M6-6-1",""}, - {"Misra C++ 2008: M6-6-2",""}, - {"Misra C++ 2008: M6-6-3",""}, - {"Misra C++ 2008: M6-6-4",""}, - {"Misra C++ 2008: M6-6-5",""}, - {"Misra C++ 2008: M7-2-1",""}, - {"Misra C++ 2008: M7-3-1",""}, - {"Misra C++ 2008: M7-3-2",""}, - {"Misra C++ 2008: M7-3-3",""}, - {"Misra C++ 2008: M7-3-4",""}, - {"Misra C++ 2008: M7-3-5",""}, - {"Misra C++ 2008: M7-3-6",""}, - {"Misra C++ 2008: M7-4-2",""}, - {"Misra C++ 2008: M7-4-3",""}, - {"Misra C++ 2008: M7-5-3",""}, - {"Misra C++ 2008: M8-0-1",""}, - {"Misra C++ 2008: M8-3-1",""}, - {"Misra C++ 2008: M8-4-4",""}, - {"Misra C++ 2008: M8-5-2",""}, - {"Misra C++ 2008: M8-5-3",""}, - {"Misra C++ 2008: M9-3-1",""}, - {"Misra C++ 2008: M9-5-1",""}, - {"Misra C++ 2008: M9-6-2",""}, - {"Misra C++ 2008: M9-6-3",""}, - {"Misra C++ 2008: M9-6-4",""}, - {"Misra C++ 2023: 0.1.2",""}, - {"Misra C++ 2023: 0.2.1",""}, - {"Misra C++ 2023: 0.2.2",""}, - {"Misra C++ 2023: 0.2.3",""}, - {"Misra C++ 2023: 0.2.4",""}, - {"Misra C++ 2023: 10.0.1",""}, - {"Misra C++ 2023: 10.1.2",""}, - {"Misra C++ 2023: 10.2.1",""}, - {"Misra C++ 2023: 10.2.2",""}, - {"Misra C++ 2023: 10.2.3",""}, - {"Misra C++ 2023: 10.3.1",""}, - {"Misra C++ 2023: 10.4.1",""}, - {"Misra C++ 2023: 11.3.1",""}, - {"Misra C++ 2023: 11.3.2",""}, - {"Misra C++ 2023: 11.6.1",""}, - {"Misra C++ 2023: 11.6.3",""}, - {"Misra C++ 2023: 12.2.1",""}, - {"Misra C++ 2023: 12.2.2",""}, - {"Misra C++ 2023: 12.2.3",""}, - {"Misra C++ 2023: 12.3.1",""}, - {"Misra C++ 2023: 13.1.1",""}, - {"Misra C++ 2023: 13.1.2",""}, - {"Misra C++ 2023: 13.3.1",""}, - {"Misra C++ 2023: 13.3.2",""}, - {"Misra C++ 2023: 13.3.3",""}, - {"Misra C++ 2023: 13.3.4",""}, - {"Misra C++ 2023: 14.1.1",""}, - {"Misra C++ 2023: 15.0.1",""}, - {"Misra C++ 2023: 15.0.2",""}, - {"Misra C++ 2023: 15.1.2",""}, - {"Misra C++ 2023: 15.1.3",""}, - {"Misra C++ 2023: 15.1.5",""}, - {"Misra C++ 2023: 16.5.1",""}, - {"Misra C++ 2023: 16.5.2",""}, - {"Misra C++ 2023: 16.6.1",""}, - {"Misra C++ 2023: 17.8.1",""}, - {"Misra C++ 2023: 18.1.1",""}, - {"Misra C++ 2023: 18.1.2",""}, - {"Misra C++ 2023: 18.3.1",""}, - {"Misra C++ 2023: 18.3.2",""}, - {"Misra C++ 2023: 18.3.3",""}, - {"Misra C++ 2023: 18.4.1",""}, - {"Misra C++ 2023: 18.5.1",""}, - {"Misra C++ 2023: 18.5.2",""}, - {"Misra C++ 2023: 19.0.1",""}, - {"Misra C++ 2023: 19.0.2",""}, - {"Misra C++ 2023: 19.0.3",""}, - {"Misra C++ 2023: 19.0.4",""}, - {"Misra C++ 2023: 19.1.1",""}, - {"Misra C++ 2023: 19.1.2",""}, - {"Misra C++ 2023: 19.1.3",""}, - {"Misra C++ 2023: 19.2.1",""}, - {"Misra C++ 2023: 19.2.2",""}, - {"Misra C++ 2023: 19.2.3",""}, - {"Misra C++ 2023: 19.3.1",""}, - {"Misra C++ 2023: 19.3.2",""}, - {"Misra C++ 2023: 19.3.3",""}, - {"Misra C++ 2023: 19.3.4",""}, - {"Misra C++ 2023: 19.6.1",""}, - {"Misra C++ 2023: 21.10.1",""}, - {"Misra C++ 2023: 21.10.2",""}, - {"Misra C++ 2023: 21.10.3",""}, - {"Misra C++ 2023: 21.2.1",""}, - {"Misra C++ 2023: 21.2.2",""}, - {"Misra C++ 2023: 21.2.3",""}, - {"Misra C++ 2023: 21.2.4",""}, - {"Misra C++ 2023: 21.6.1",""}, - {"Misra C++ 2023: 21.6.2",""}, - {"Misra C++ 2023: 21.6.3",""}, - {"Misra C++ 2023: 21.6.4",""}, - {"Misra C++ 2023: 21.6.5",""}, - {"Misra C++ 2023: 22.3.1",""}, - {"Misra C++ 2023: 22.4.1",""}, - {"Misra C++ 2023: 23.11.1",""}, - {"Misra C++ 2023: 24.5.1",""}, - {"Misra C++ 2023: 24.5.2",""}, - {"Misra C++ 2023: 25.5.1",""}, - {"Misra C++ 2023: 25.5.2",""}, - {"Misra C++ 2023: 25.5.3",""}, - {"Misra C++ 2023: 26.3.1",""}, - {"Misra C++ 2023: 28.3.1",""}, - {"Misra C++ 2023: 28.6.1",""}, - {"Misra C++ 2023: 28.6.2",""}, - {"Misra C++ 2023: 30.0.1",""}, - {"Misra C++ 2023: 30.0.2",""}, - {"Misra C++ 2023: 4.1.1",""}, - {"Misra C++ 2023: 4.1.2",""}, - {"Misra C++ 2023: 5.0.1",""}, - {"Misra C++ 2023: 5.10.1",""}, - {"Misra C++ 2023: 5.13.1",""}, - {"Misra C++ 2023: 5.13.2",""}, - {"Misra C++ 2023: 5.13.3",""}, - {"Misra C++ 2023: 5.13.4",""}, - {"Misra C++ 2023: 5.13.5",""}, - {"Misra C++ 2023: 5.13.6",""}, - {"Misra C++ 2023: 5.13.7",""}, - {"Misra C++ 2023: 5.7.1",""}, - {"Misra C++ 2023: 5.7.2",""}, - {"Misra C++ 2023: 5.7.3",""}, - {"Misra C++ 2023: 6.0.1",""}, - {"Misra C++ 2023: 6.0.2",""}, - {"Misra C++ 2023: 6.0.3",""}, - {"Misra C++ 2023: 6.0.4",""}, - {"Misra C++ 2023: 6.2.2",""}, - {"Misra C++ 2023: 6.2.3",""}, - {"Misra C++ 2023: 6.2.4",""}, - {"Misra C++ 2023: 6.4.2",""}, - {"Misra C++ 2023: 6.4.3",""}, - {"Misra C++ 2023: 6.5.1",""}, - {"Misra C++ 2023: 6.5.2",""}, - {"Misra C++ 2023: 6.7.1",""}, - {"Misra C++ 2023: 6.7.2",""}, - {"Misra C++ 2023: 6.8.3",""}, - {"Misra C++ 2023: 6.8.4",""}, - {"Misra C++ 2023: 6.9.1",""}, - {"Misra C++ 2023: 6.9.2",""}, - {"Misra C++ 2023: 7.0.1",""}, - {"Misra C++ 2023: 7.0.2",""}, - {"Misra C++ 2023: 7.0.3",""}, - {"Misra C++ 2023: 7.0.4",""}, - {"Misra C++ 2023: 7.0.5",""}, - {"Misra C++ 2023: 7.0.6",""}, - {"Misra C++ 2023: 7.11.1",""}, - {"Misra C++ 2023: 7.11.2",""}, - {"Misra C++ 2023: 7.11.3",""}, - {"Misra C++ 2023: 8.0.1",""}, - {"Misra C++ 2023: 8.1.1",""}, - {"Misra C++ 2023: 8.1.2",""}, - {"Misra C++ 2023: 8.14.1",""}, - {"Misra C++ 2023: 8.18.2",""}, - {"Misra C++ 2023: 8.19.1",""}, - {"Misra C++ 2023: 8.2.1",""}, - {"Misra C++ 2023: 8.2.10",""}, - {"Misra C++ 2023: 8.2.11",""}, - {"Misra C++ 2023: 8.2.2",""}, - {"Misra C++ 2023: 8.2.3",""}, - {"Misra C++ 2023: 8.2.4",""}, - {"Misra C++ 2023: 8.2.5",""}, - {"Misra C++ 2023: 8.2.6",""}, - {"Misra C++ 2023: 8.2.7",""}, - {"Misra C++ 2023: 8.2.8",""}, - {"Misra C++ 2023: 8.2.9",""}, - {"Misra C++ 2023: 8.20.1",""}, - {"Misra C++ 2023: 8.3.1",""}, - {"Misra C++ 2023: 8.3.2",""}, - {"Misra C++ 2023: 9.2.1",""}, - {"Misra C++ 2023: 9.3.1",""}, - {"Misra C++ 2023: 9.4.1",""}, - {"Misra C++ 2023: 9.4.2",""}, - {"Misra C++ 2023: 9.5.1",""}, - {"Misra C++ 2023: 9.5.2",""}, - {"Misra C++ 2023: 9.6.1",""}, - {"Misra C++ 2023: 9.6.2",""}, - {"Misra C++ 2023: 9.6.3",""}, - {"Misra C++ 2023: 9.6.4",""}, - {"Misra C: 1.2",""}, - {"Misra C: 1.4",""}, - {"Misra C: 1.5",""}, - {"Misra C: 10.1",""}, - {"Misra C: 10.2",""}, - {"Misra C: 10.3",""}, - {"Misra C: 10.4",""}, - {"Misra C: 10.5",""}, - {"Misra C: 10.6",""}, - {"Misra C: 10.7",""}, - {"Misra C: 10.8",""}, - {"Misra C: 11.1",""}, - {"Misra C: 11.10",""}, - {"Misra C: 11.11",""}, - {"Misra C: 11.2",""}, - {"Misra C: 11.3",""}, - {"Misra C: 11.4",""}, - {"Misra C: 11.5",""}, - {"Misra C: 11.6",""}, - {"Misra C: 11.7",""}, - {"Misra C: 11.8",""}, - {"Misra C: 11.9",""}, - {"Misra C: 12.1",""}, - {"Misra C: 12.2",""}, - {"Misra C: 12.3",""}, - {"Misra C: 12.4",""}, - {"Misra C: 12.6",""}, - {"Misra C: 13.1",""}, - {"Misra C: 13.2",""}, - {"Misra C: 13.3",""}, - {"Misra C: 13.4",""}, - {"Misra C: 13.5",""}, - {"Misra C: 13.6",""}, - {"Misra C: 14.1",""}, - {"Misra C: 14.2",""}, - {"Misra C: 14.4",""}, - {"Misra C: 15.1",""}, - {"Misra C: 15.2",""}, - {"Misra C: 15.3",""}, - {"Misra C: 15.4",""}, - {"Misra C: 15.5",""}, - {"Misra C: 15.6",""}, - {"Misra C: 15.7",""}, - {"Misra C: 16.1",""}, - {"Misra C: 16.2",""}, - {"Misra C: 16.3",""}, - {"Misra C: 16.4",""}, - {"Misra C: 16.5",""}, - {"Misra C: 16.6",""}, - {"Misra C: 16.7",""}, - {"Misra C: 17.1",""}, - {"Misra C: 17.10",""}, - {"Misra C: 17.11",""}, - {"Misra C: 17.12",""}, - {"Misra C: 17.13",""}, - {"Misra C: 17.2",""}, - {"Misra C: 17.3",""}, - {"Misra C: 17.4",""}, - {"Misra C: 17.6",""}, - {"Misra C: 17.7",""}, - {"Misra C: 17.8",""}, - {"Misra C: 17.9",""}, - {"Misra C: 18.10",""}, - {"Misra C: 18.4",""}, - {"Misra C: 18.5",""}, - {"Misra C: 18.7",""}, - {"Misra C: 18.8",""}, - {"Misra C: 18.9",""}, - {"Misra C: 19.2",""}, - {"Misra C: 19.3",""}, - {"Misra C: 2.2",""}, - {"Misra C: 2.7",""}, - {"Misra C: 20.1",""}, - {"Misra C: 20.10",""}, - {"Misra C: 20.11",""}, - {"Misra C: 20.12",""}, - {"Misra C: 20.13",""}, - {"Misra C: 20.14",""}, - {"Misra C: 20.15",""}, - {"Misra C: 20.2",""}, - {"Misra C: 20.3",""}, - {"Misra C: 20.4",""}, - {"Misra C: 20.5",""}, - {"Misra C: 20.7",""}, - {"Misra C: 20.8",""}, - {"Misra C: 20.9",""}, - {"Misra C: 21.1",""}, - {"Misra C: 21.10",""}, - {"Misra C: 21.11",""}, - {"Misra C: 21.12",""}, - {"Misra C: 21.14",""}, - {"Misra C: 21.15",""}, - {"Misra C: 21.16",""}, - {"Misra C: 21.18",""}, - {"Misra C: 21.19",""}, - {"Misra C: 21.2",""}, - {"Misra C: 21.20",""}, - {"Misra C: 21.21",""}, - {"Misra C: 21.22",""}, - {"Misra C: 21.23",""}, - {"Misra C: 21.24",""}, - {"Misra C: 21.25","warning"}, - {"Misra C: 21.26","warning"}, - {"Misra C: 21.3",""}, - {"Misra C: 21.4",""}, - {"Misra C: 21.5",""}, - {"Misra C: 21.6",""}, - {"Misra C: 21.7",""}, - {"Misra C: 21.8",""}, - {"Misra C: 21.9",""}, - {"Misra C: 22.10",""}, - {"Misra C: 22.11",""}, - {"Misra C: 22.12",""}, - {"Misra C: 22.13",""}, - {"Misra C: 22.14",""}, - {"Misra C: 22.15",""}, - {"Misra C: 22.16","warning"}, - {"Misra C: 22.17","warning"}, - {"Misra C: 22.18","warning"}, - {"Misra C: 22.19","warning"}, - {"Misra C: 22.20",""}, - {"Misra C: 22.5",""}, - {"Misra C: 22.7",""}, - {"Misra C: 22.8",""}, - {"Misra C: 22.9",""}, - {"Misra C: 23.1",""}, - {"Misra C: 23.2",""}, - {"Misra C: 23.3",""}, - {"Misra C: 23.4",""}, - {"Misra C: 23.5",""}, - {"Misra C: 23.6",""}, - {"Misra C: 23.7",""}, - {"Misra C: 23.8",""}, - {"Misra C: 3.1",""}, - {"Misra C: 3.2",""}, - {"Misra C: 4.1",""}, - {"Misra C: 4.2",""}, - {"Misra C: 5.1",""}, - {"Misra C: 5.10",""}, - {"Misra C: 5.2",""}, - {"Misra C: 5.3",""}, - {"Misra C: 5.4",""}, - {"Misra C: 5.5",""}, - {"Misra C: 5.6",""}, - {"Misra C: 5.7",""}, - {"Misra C: 6.1",""}, - {"Misra C: 6.2",""}, - {"Misra C: 6.3",""}, - {"Misra C: 7.1",""}, - {"Misra C: 7.2",""}, - {"Misra C: 7.3",""}, - {"Misra C: 7.4","style"}, - {"Misra C: 7.5",""}, - {"Misra C: 7.6",""}, - {"Misra C: 8.1",""}, - {"Misra C: 8.10",""}, - {"Misra C: 8.11",""}, - {"Misra C: 8.12",""}, - {"Misra C: 8.14",""}, - {"Misra C: 8.15",""}, - {"Misra C: 8.16",""}, - {"Misra C: 8.17",""}, - {"Misra C: 8.18",""}, - {"Misra C: 8.19",""}, - {"Misra C: 8.2",""}, - {"Misra C: 8.3",""}, - {"Misra C: 8.4",""}, - {"Misra C: 8.5",""}, - {"Misra C: 8.6",""}, - {"Misra C: 8.7",""}, - {"Misra C: 8.8",""}, - {"Misra C: 8.9",""}, - {"Misra C: 9.2",""}, - {"Misra C: 9.3",""}, - {"Misra C: 9.4",""}, - {"Misra C: 9.5",""}, - {"Misra C: 9.6",""}, - {"Misra C: 9.7",""}, - {"Misra C: Dir 1.2",""}, - {"Misra C: Dir 4.12",""}, - {"Misra C: Dir 4.3",""}, - {"Misra C: Dir 4.4",""}, - {"Misra C: Dir 4.5",""}, - {"Misra C: Dir 4.6",""}, - {"Misra C: Dir 4.7",""}, - {"Misra C: Dir 4.9",""}, - {"PremiumCheckBufferOverrun::addressOfPointerArithmetic","warning"}, - {"PremiumCheckBufferOverrun::negativeBufferSizeCheckedNonZero","warning"}, - {"PremiumCheckHang::infiniteLoop",""}, - {"PremiumCheckHang::infiniteLoopContinue",""}, - {"PremiumCheckOther::arrayPointerComparison","style"}, - {"PremiumCheckOther::invalidPointerLiteral",""}, - {"PremiumCheckOther::knownResult","style"}, - {"PremiumCheckOther::lossOfPrecision","style"}, - {"PremiumCheckOther::pointerCast","style"}, - {"PremiumCheckOther::reassignInLoop","style"}, - {"PremiumCheckOther::unreachableCode","style"}, - {"PremiumCheckOther::useAfterFree",""}, - {"PremiumCheckStrictAlias::strictAliasCondition","warning"}, - {"PremiumCheckUninitVar::uninitmember",""}, - {"PremiumCheckUninitVar::uninitvar",""}, - {"PremiumCheckUnusedVar::unreadVariable","style"}, - {"PremiumCheckUnusedVar::unusedPrivateMember","style"}, - {"PremiumMetrics::HIS::Call",""}, - {"PremiumMetrics::HIS::Calling",""}, - {"PremiumMetrics::HIS::Comment",""}, - {"PremiumMetrics::HIS::Goto",""}, - {"PremiumMetrics::HIS::Level",""}, - {"PremiumMetrics::HIS::Param",""}, - {"PremiumMetrics::HIS::Path",""}, - {"PremiumMetrics::HIS::Stmt",""}, - {"PremiumMetrics::HIS::StmtFile",""}, - {"PremiumMetrics::HIS::VOCF",""}, - {"PremiumMetrics::HIS::return",""}, - {"PremiumMetrics::cyclomaticComplexity",""}, - }; const char Req[] = "Required"; const char Adv[] = "Advisory"; diff --git a/lib/checkers.h b/lib/checkers.h index a9329d6c08f..e7dd4164570 100644 --- a/lib/checkers.h +++ b/lib/checkers.h @@ -40,7 +40,6 @@ enum class ReportType : std::uint8_t { namespace checkers { extern CPPCHECKLIB const std::map allCheckers; - extern CPPCHECKLIB const std::map premiumCheckers; struct CPPCHECKLIB MisraInfo { int a; diff --git a/lib/checkersreport.cpp b/lib/checkersreport.cpp index a5135bed3f8..a5d9c619cb3 100644 --- a/lib/checkersreport.cpp +++ b/lib/checkersreport.cpp @@ -133,12 +133,15 @@ void CheckersReport::countCheckers() ++mActiveCheckersCount; ++mAllCheckersCount; } - for (const auto& checkReq: checkers::premiumCheckers) { - if (mActiveCheckers.count(checkReq.first) > 0) - ++mActiveCheckersCount; - ++mAllCheckersCount; + for (const auto& addonInfo: mSettings.addonInfos) { + for (const auto& checkReq: addonInfo.checkers) { + if (mActiveCheckers.count(checkReq.first) > 0) + ++mActiveCheckersCount; + ++mAllCheckersCount; + } } - if (mSettings.premiumArgs.find("misra-c-") != std::string::npos || mSettings.addons.count("misra")) { + + if (mSettings.addons.count("misra")) { const bool doUnusedFunctionOnly = Settings::unusedFunctionOnly(); for (const checkers::MisraInfo& info: checkers::misraC2012Rules) { const std::string rule = std::to_string(info.a) + "." + std::to_string(info.b); @@ -190,106 +193,33 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const fout << std::endl; } - const bool cppcheckPremium = mSettings.premium; - - auto reportSection = [&fout, cppcheckPremium] - (const std::string& title, - const Settings& settings, - const std::set& activeCheckers, - const std::map& premiumCheckers, - const std::string& substring) { + for (const auto& addonInfo: mSettings.addonInfos) { + if (addonInfo.checkers.empty()) + continue; fout << std::endl << std::endl; + std::string title; + if (mSettings.premium && addonInfo.name == "premiumaddon.json") + title = "Cppcheck Premium"; + else { + title = addonInfo.name; + if (endsWith(title, ".json")) + title.erase(title.rfind('.')); + } + title += " checkers"; fout << title << std::endl; fout << std::string(title.size(), '-') << std::endl; - if (!cppcheckPremium) { - fout << "Not available, Cppcheck Premium is not used" << std::endl; - return; - } - int maxCheckerSize = 0; - for (const auto& checkReq: premiumCheckers) { - const std::string& checker = checkReq.first; - if (checker.find(substring) != std::string::npos && checker.size() > maxCheckerSize) - maxCheckerSize = checker.size(); - } - for (const auto& checkReq: premiumCheckers) { + + for (const auto& checkReq: addonInfo.checkers) { const std::string& checker = checkReq.first; - if (checker.find(substring) == std::string::npos) - continue; - std::string req = checkReq.second; - bool active = cppcheckPremium && activeCheckers.count(checker) > 0; - if (substring == "::") { - if (req == "warning") - active &= settings.severity.isEnabled(Severity::warning); - else if (req == "style") - active &= settings.severity.isEnabled(Severity::style); - else if (req == "portability") - active &= settings.severity.isEnabled(Severity::portability); - else if (!req.empty()) - active = false; // FIXME: handle req - } + const bool active = mActiveCheckers.count(checkReq.first) > 0; + const std::string& req = checkReq.second; fout << (active ? "Yes " : "No ") << checker; - if (!cppcheckPremium) { - if (!req.empty()) - req = "premium," + req; - else - req = "premium"; - } - if (!req.empty()) - req = "require:" + req; - if (!active) - fout << std::string(maxCheckerSize + 4 - checker.size(), ' ') << req; + if (!active && !req.empty()) + fout << std::string(maxCheckerSize + 4 - checker.size(), ' ') << "require:" + req; fout << std::endl; } - }; - - reportSection("Premium checkers", mSettings, mActiveCheckers, checkers::premiumCheckers, "::"); - reportSection("Autosar", mSettings, mActiveCheckers, checkers::premiumCheckers, "Autosar: "); - reportSection("Cert C", mSettings, mActiveCheckers, checkers::premiumCheckers, "Cert C: "); - reportSection("Cert C++", mSettings, mActiveCheckers, checkers::premiumCheckers, "Cert C++: "); - - const int misraCVersion = getMisraCVersion(mSettings); - - if (misraCVersion == 0) { - fout << std::endl << std::endl; - fout << "Misra C" << std::endl; - fout << "-------" << std::endl; - fout << "Misra is not enabled" << std::endl; - } else { - fout << std::endl << std::endl; - fout << "Misra C " << misraCVersion << std::endl; - fout << "------------" << std::endl; - for (const checkers::MisraInfo& info: checkers::misraC2012Directives) { - const std::string directive = "Dir " + std::to_string(info.a) + "." + std::to_string(info.b); - const bool active = isMisraRuleActive(mActiveCheckers, directive); - fout << (active ? "Yes " : "No ") << "Misra C " << misraCVersion << ": " << directive; - std::string extra; - if (misraCVersion == 2012 && info.amendment >= 1) - extra = " amendment:" + std::to_string(info.amendment); - if (!extra.empty()) - fout << std::string(10 - directive.size(), ' ') << extra; - fout << '\n'; - } - for (const checkers::MisraInfo& info: checkers::misraC2012Rules) { - const std::string rule = std::to_string(info.a) + "." + std::to_string(info.b); - const bool active = isMisraRuleActive(mActiveCheckers, rule); - fout << (active ? "Yes " : "No ") << "Misra C " << misraCVersion << ": " << rule; - std::string extra; - if (misraCVersion == 2012 && info.amendment >= 1) - extra = " amendment:" + std::to_string(info.amendment); - std::string reqs; - if (info.amendment >= 3) - reqs += ",premium"; - if (!active && !reqs.empty()) - extra += " require:" + reqs.substr(1); - if (!extra.empty()) - fout << std::string(10 - rule.size(), ' ') << extra; - fout << '\n'; - } } - reportSection("Misra C++ 2008", mSettings, mActiveCheckers, checkers::premiumCheckers, "Misra C++ 2008: "); - reportSection("Misra C++ 2023", mSettings, mActiveCheckers, checkers::premiumCheckers, "Misra C++ 2023: "); - return fout.str(); } diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 744a68aac60..86a5c023bbc 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -4062,22 +4062,22 @@ def __test_active_checkers(tmp_path, active_cnt, total_cnt, use_misra=False, use def test_active_unusedfunction_only(tmp_path): - __test_active_checkers(tmp_path, 1, 975, use_unusedfunction_only=True) + __test_active_checkers(tmp_path, 1, 186, use_unusedfunction_only=True) def test_active_unusedfunction_only_builddir(tmp_path): checkers_exp = [ 'CheckUnusedFunctions::check' ] - __test_active_checkers(tmp_path, 1, 975, use_unusedfunction_only=True, checkers_exp=checkers_exp) + __test_active_checkers(tmp_path, 1, 186, use_unusedfunction_only=True, checkers_exp=checkers_exp) def test_active_unusedfunction_only_misra(tmp_path): - __test_active_checkers(tmp_path, 1, 1175, use_unusedfunction_only=True, use_misra=True) + __test_active_checkers(tmp_path, 1, 386, use_unusedfunction_only=True, use_misra=True) def test_active_unusedfunction_only_misra_builddir(tmp_path): checkers_exp = [ 'CheckUnusedFunctions::check' ] - __test_active_checkers(tmp_path, 1, 1175, use_unusedfunction_only=True, use_misra=True, checkers_exp=checkers_exp) + __test_active_checkers(tmp_path, 1, 386, use_unusedfunction_only=True, use_misra=True, checkers_exp=checkers_exp) diff --git a/tools/get_checkers.py b/tools/get_checkers.py index e2c9719bbfd..4594b773dc2 100644 --- a/tools/get_checkers.py +++ b/tools/get_checkers.py @@ -4,7 +4,6 @@ import re import requests - def print_checkers(glob_pattern:str): checkers = {} for filename in glob.glob(glob_pattern): @@ -49,11 +48,6 @@ def print_checkers(glob_pattern:str): print_checkers(os.path.expanduser('~/cppchecksolutions/cppcheck/lib/*.cpp')) print(" };\n") -print(' const std::map premiumCheckers{') -print_checkers(os.path.expanduser('~/cppchecksolutions/addon/src/*.cpp')) -print(' };') - - print(""" const char Req[] = "Required"; const char Adv[] = "Advisory"; From 0342d0c775e03b0c86daa67810ce2ad2296c3eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 14 Feb 2026 18:06:41 +0100 Subject: [PATCH 135/675] iwyu.yml: fixed macOS run [skip ci] (#7832) --- .github/workflows/iwyu.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 772a0da320c..9b25be2cffa 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -26,7 +26,7 @@ jobs: # image: "fedora:latest" # stdlib: libc++ # clang_inc: '-isystem/usr/lib/clang/20/include' - - os: macos-13 + - os: macos-26 image: "" stdlib: libc++ # no libstdc++ on macOS mapping_file_opt: '-Xiwyu --mapping_file=$(realpath ./macos.imp)' @@ -100,18 +100,21 @@ jobs: if: contains(matrix.os, 'macos') run: | brew install include-what-you-use pcre coreutils - ln -s iwyu_tool.py /usr/local/bin/iwyu_tool + # on Apple Silicon files are symlinked under /opt/homebrew/bin + ln -s /opt/homebrew/bin/iwyu_tool.py /usr/local/bin/iwyu_tool # Fails on OpenSUSE: # Warning: Failed to restore: Tar failed with error: Unable to locate executable file: tar. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable. # Also the shell is broken afterwards: # OCI runtime exec failed: exec failed: unable to start container process: exec: "sh": executable file not found in $PATH: unknown + # + # On macos-26 we need to perform the Python setup because the default installation is managed externally managed - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' - setup-python: 'false' + setup-python: ${{ contains(matrix.os, 'macos') }} install-deps: false cache: true From 33e45d643ffa589fb94ebf2894da36ec220cb5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 14 Feb 2026 18:06:58 +0100 Subject: [PATCH 136/675] re-worded some error messages and avoid using product name (#8074) --- lib/checkother.cpp | 2 +- lib/cppcheck.cpp | 4 ++-- lib/importproject.cpp | 4 ++-- lib/mathlib.cpp | 2 +- lib/preprocessor.cpp | 2 +- lib/templatesimplifier.cpp | 2 +- lib/token.cpp | 2 +- test/cli/helloworld_test.py | 2 +- test/cli/other_test.py | 2 +- test/testmathlib.cpp | 2 +- test/testpreprocessor.cpp | 16 ++++++++-------- test/testtoken.cpp | 2 +- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index cab4cd11868..fec362107f5 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1506,7 +1506,7 @@ void CheckOther::commaSeparatedReturnError(const Token *tok) " if (x)\n" " return a + 1,\n" " b++;\n" - "However it can be useful to use comma in macros. Cppcheck does not warn when such a " + "However it can be useful to use comma in macros. No warning is reported when such a " "macro is then used in a return statement, it is less likely such code is misunderstood.", CWE398, Certainty::normal); } diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index de3bcd1530a..faf6b2126d1 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1241,8 +1241,8 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str if (!hasValidConfig && configurations.size() > 1 && mSettings.severity.isEnabled(Severity::information)) { std::string msg; - msg = "This file is not analyzed. Cppcheck failed to extract a valid configuration. Use -v for more details."; - msg += "\nThis file is not analyzed. Cppcheck failed to extract a valid configuration. The tested configurations have these preprocessor errors:"; + msg = "This file is not analyzed. No working configuration could be extracted. Use -v for more details."; + msg += "\nThis file is not analyzed. No working configuration could be extracted. The tested configurations have these preprocessor errors:"; for (const std::string &s : configurationError) msg += '\n' + s; diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 1268c39d3c9..9706cd5c6b2 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -1443,7 +1443,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti else if (strcmp(childname, Settings::SafeChecks::XmlExternalVariables) == 0) temp.safeChecks.externalVariables = true; else { - errors.emplace_back("Unknown '" + std::string(Settings::SafeChecks::XmlRootName) + "' element '" + childname + "' in Cppcheck project file"); + errors.emplace_back("Unknown '" + std::string(Settings::SafeChecks::XmlRootName) + "' element '" + childname + "' in Cppcheck GUI project file"); return false; } } @@ -1466,7 +1466,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti else if (strcmp(name, CppcheckXml::ProjectNameElementName) == 0) ; // no-op else { - errors.emplace_back("Unknown element '" + std::string(name) + "' in Cppcheck project file"); + errors.emplace_back("Unknown element '" + std::string(name) + "' in Cppcheck GUI project file"); return false; } } diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index f065d63a935..effd03f0e7f 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -1224,7 +1224,7 @@ std::string MathLib::calculate(const std::string &first, const std::string &seco return MathLib::toString(MathLib::toBigNumber(first) ^ MathLib::toBigNumber(second)) + intsuffix(first, second); default: - throw InternalError(nullptr, std::string("Unexpected action '") + action + "' in MathLib::calculate(). Please report this to Cppcheck developers."); + throw InternalError(nullptr, std::string("Unexpected action '") + action + "' in MathLib::calculate()."); } } diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index e2475a6e0df..01e3d6f5c74 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -1008,7 +1008,7 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line } ErrorMessage errmsg(std::move(locationList), mFile0, Severity::information, (headerType==SystemHeader) ? - "Include file: <" + header + "> not found. Please note: Cppcheck does not need standard library headers to get proper results." : + "Include file: <" + header + "> not found. Please note: Standard library headers do not need to be provided to get proper results." : "Include file: \"" + header + "\" not found.", (headerType==SystemHeader) ? "missingIncludeSystem" : "missingInclude", Certainty::normal); diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 023fe5618ad..9d2eac49483 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -3152,7 +3152,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations( "templateRecursion", "TemplateSimplifier: max template recursion (" + std::to_string(mSettings.maxTemplateRecursion) - + ") reached for template '"+typeForNewName+"'. You might want to limit Cppcheck recursion.", + + ") reached for template '"+typeForNewName+"'.", Certainty::normal); mErrorLogger.reportErr(errmsg); } diff --git a/lib/token.cpp b/lib/token.cpp index f55fcc14830..5aaf0960157 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -424,7 +424,7 @@ int multiComparePercent(const Token *tok, const char*& haystack, nonneg int vari return 1; } else { // %varid% if (varid == 0) { - throw InternalError(tok, "Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers"); + throw InternalError(tok, "Internal error. Token::Match called with varid 0."); } haystack += 6; diff --git a/test/cli/helloworld_test.py b/test/cli/helloworld_test.py index 57e94aed40f..7ccc113af43 100644 --- a/test/cli/helloworld_test.py +++ b/test/cli/helloworld_test.py @@ -360,7 +360,7 @@ def test_missing_include_system(): # #11283 ] _, _, stderr = cppcheck(args, cwd=__script_dir) - assert stderr.replace('\\', '/') == 'helloworld/main.c:1:2: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n' + assert stderr.replace('\\', '/') == 'helloworld/main.c:1:2: information: Include file: not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n' def test_sarif(): diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 86a5c023bbc..1165f633e71 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -3980,7 +3980,7 @@ def test_no_valid_configuration(tmp_path): '{}:1:2: error: No header in #include [syntaxError]'.format(test_file), '{}:1:2: error: No header in #include [syntaxError]'.format(test_file), '{}:1:2: error: No header in #include [syntaxError]'.format(test_file), - '{}:0:0: information: This file is not analyzed. Cppcheck failed to extract a valid configuration. Use -v for more details. [noValidConfiguration]'.format(test_file) + '{}:0:0: information: This file is not analyzed. No working configuration could be extracted. Use -v for more details. [noValidConfiguration]'.format(test_file) ] diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index a2f9526162c..dee1d3f5fe9 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -167,7 +167,7 @@ class TestMathLib : public TestFixture { ASSERT_EQUALS("1", MathLib::calculate("0", "1", '^')); // Unknown action should throw exception - ASSERT_THROW_INTERNAL_EQUALS(MathLib::calculate("1","2",'j'),INTERNAL, "Unexpected action 'j' in MathLib::calculate(). Please report this to Cppcheck developers."); + ASSERT_THROW_INTERNAL_EQUALS(MathLib::calculate("1","2",'j'),INTERNAL, "Unexpected action 'j' in MathLib::calculate()."); } void calculate1() const { diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index f38b61b8a66..53e2b2cf3f7 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -2646,7 +2646,7 @@ class TestPreprocessor : public TestFixture { const char code[] = "#include "; (void)getcodeforcfg(settings, *this, code, "", "test.c"); - ASSERT_EQUALS("test.c:1:2: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n", errout_str()); + ASSERT_EQUALS("test.c:1:2: information: Include file: not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n", errout_str()); } // test for missing system include @@ -2661,7 +2661,7 @@ class TestPreprocessor : public TestFixture { const char code[] = "#include "; (void)getcodeforcfg(settings, *this, code, "", "test.c"); - ASSERT_EQUALS("test.c:1:2: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n", errout_str()); + ASSERT_EQUALS("test.c:1:2: information: Include file: not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n", errout_str()); } // test for existing system include in system include path @@ -2714,7 +2714,7 @@ class TestPreprocessor : public TestFixture { std::string code("#include <" + header + ">"); (void)getcodeforcfg(settings, *this, code.data(), code.size(), "", "test.c"); - ASSERT_EQUALS("test.c:1:2: information: Include file: <" + header + "> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n", errout_str()); + ASSERT_EQUALS("test.c:1:2: information: Include file: <" + header + "> not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n", errout_str()); } // test for missing local and system include @@ -2737,8 +2737,8 @@ class TestPreprocessor : public TestFixture { (void)getcodeforcfg(settings, *this, code, "", "test.c"); ASSERT_EQUALS("test.c:1:2: information: Include file: \"missing.h\" not found. [missingInclude]\n" - "test.c:2:2: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n" - "test.c:3:2: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n", errout_str()); + "test.c:2:2: information: Include file: not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n" + "test.c:3:2: information: Include file: not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n", errout_str()); } void testMissingIncludeCheckConfig() { @@ -2774,11 +2774,11 @@ class TestPreprocessor : public TestFixture { (void)getcodeforcfg(settings, *this, code.data(), code.size(), "", "test.c"); ASSERT_EQUALS("test.c:1:2: information: Include file: \"missing.h\" not found. [missingInclude]\n" - "test.c:2:2: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n" - "test.c:3:2: information: Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n" + "test.c:2:2: information: Include file: not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n" + "test.c:3:2: information: Include file: not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n" "test.c:6:2: information: Include file: \"header4.h\" not found. [missingInclude]\n" "test.c:9:2: information: Include file: \"" + missing3 + "\" not found. [missingInclude]\n" - "test.c:11:2: information: Include file: <" + missing4 + "> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n", errout_str()); + "test.c:11:2: information: Include file: <" + missing4 + "> not found. Please note: Standard library headers do not need to be provided to get proper results. [missingIncludeSystem]\n", errout_str()); } void hasInclude() { diff --git a/test/testtoken.cpp b/test/testtoken.cpp index 3c3194dba36..7b834b2164b 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -710,7 +710,7 @@ class TestToken : public TestFixture { ASSERT(var.tokenize("int a ; int b ;")); // Varid == 0 should throw exception - ASSERT_THROW_INTERNAL_EQUALS((void)Token::Match(var.tokens(), "%type% %varid% ; %type% %name%", 0),INTERNAL,"Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers"); + ASSERT_THROW_INTERNAL_EQUALS((void)Token::Match(var.tokens(), "%type% %varid% ; %type% %name%", 0),INTERNAL,"Internal error. Token::Match called with varid 0."); ASSERT_EQUALS(true, Token::Match(var.tokens(), "%type% %varid% ; %type% %name%", 1)); ASSERT_EQUALS(true, Token::Match(var.tokens(), "%type% %name% ; %type% %varid%", 2)); From 4f03f09635176eff9145d610be45179e15821b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 14 Feb 2026 18:07:35 +0100 Subject: [PATCH 137/675] fixed #13788 - CI-unixish-docker.yml: added `ubuntu:25.10` / cleanups (#7472) --- .github/workflows/CI-unixish-docker.yml | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/CI-unixish-docker.yml b/.github/workflows/CI-unixish-docker.yml index 4df9b4e9340..a73218a05e3 100644 --- a/.github/workflows/CI-unixish-docker.yml +++ b/.github/workflows/CI-unixish-docker.yml @@ -20,11 +20,7 @@ jobs: strategy: matrix: - image: ["ubuntu:24.04"] - include: - - build_gui: false - - image: "ubuntu:24.04" - build_gui: true + image: ["ubuntu:24.04", "ubuntu:25.10"] fail-fast: false # Prefer quick result runs-on: ubuntu-22.04 @@ -49,7 +45,6 @@ jobs: apt-get install -y cmake g++ make libxml2-utils libpcre3-dev - name: Install missing software (gui) on latest ubuntu - if: matrix.build_gui run: | apt-get install -y qt6-base-dev qt6-charts-dev qt6-tools-dev @@ -60,18 +55,12 @@ jobs: with: key: ${{ github.workflow }}-${{ matrix.image }} - - name: CMake build - if: ${{ !matrix.build_gui }} + - name: Run CMake run: | - mkdir cmake.output - cd cmake.output - cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. - cmake --build . -- -j$(nproc) + cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: CMake build (with GUI) - if: matrix.build_gui run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build cmake.output -- -j$(nproc) - name: Run CMake test @@ -82,7 +71,7 @@ jobs: strategy: matrix: - image: ["ubuntu:24.04"] + image: ["ubuntu:24.04", "ubuntu:25.10"] fail-fast: false # Prefer quick result runs-on: ubuntu-22.04 From 70d3545f87581a5022b97312b56f7176102ee166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 14 Feb 2026 18:08:10 +0100 Subject: [PATCH 138/675] extracted selfcheck into script (#8198) --- .github/workflows/CI-unixish.yml | 29 +---------------------------- selfcheck.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 28 deletions(-) create mode 100755 selfcheck.sh diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 14682a41a56..6a7dad5fc9a 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -695,31 +695,4 @@ jobs: - name: Self check run: | - selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude,information --exception-handling --debug-warnings --check-level=exhaustive" - cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" - gui_options="-DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt" - ec=0 - - # TODO: add --check-config - - # early exit - if [ $ec -eq 1 ]; then - exit $ec - fi - - # self check externals - ./cppcheck $selfcheck_options externals || ec=1 - # self check lib/cli - mkdir b1 - ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json frontend || ec=1 - ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json -Ifrontend cli || ec=1 - ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json --enable=internal lib || ec=1 - # check gui with qt settings - mkdir b2 - ./cppcheck $selfcheck_options $cppcheck_options $gui_options --cppcheck-build-dir=b2 --addon=naming.json -Icmake.output/gui -Ifrontend -Igui gui/*.cpp cmake.output/gui || ec=1 - # self check test and tools - ./cppcheck $selfcheck_options $cppcheck_options -Ifrontend -Icli test/*.cpp || ec=1 - ./cppcheck $selfcheck_options $cppcheck_options -Icli tools/dmake/*.cpp || ec=1 - # triage - ./cppcheck $selfcheck_options $cppcheck_options $gui_options -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage || ec=1 - exit $ec + ./selfcheck.sh diff --git a/selfcheck.sh b/selfcheck.sh new file mode 100755 index 00000000000..6a1755e337b --- /dev/null +++ b/selfcheck.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude,information --exception-handling --debug-warnings --check-level=exhaustive" +cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" +gui_options="-DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt" +ec=0 + +if [ -n "$1" ]; then + selfcheck_options="$selfcheck_options $1" +fi + +# self check externals +./cppcheck $selfcheck_options externals || ec=1 +# self check lib/cli +mkdir b1 +./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json frontend || ec=1 +./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json -Ifrontend cli || ec=1 +./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json --enable=internal lib || ec=1 +# check gui with qt settings +mkdir b2 +./cppcheck $selfcheck_options $cppcheck_options $gui_options --cppcheck-build-dir=b2 --addon=naming.json -Icmake.output/gui -Ifrontend -Igui gui/*.cpp cmake.output/gui || ec=1 +# self check test and tools +./cppcheck $selfcheck_options $cppcheck_options -Ifrontend -Icli test/*.cpp || ec=1 +./cppcheck $selfcheck_options $cppcheck_options -Icli tools/dmake/*.cpp || ec=1 +# triage +./cppcheck $selfcheck_options $cppcheck_options $gui_options -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage || ec=1 + +rm -rf b2 +rm -rf b1 + +exit $ec \ No newline at end of file From e3ef82e00051c774c947551c44fc4a84bce1a9d3 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 14 Feb 2026 18:56:48 +0100 Subject: [PATCH 139/675] Fix #14342 FN containerOutOfBounds (std::string_view of array, constructor call) (#8190) --- lib/valueflow.cpp | 39 ++++++++++++++++++++++----------------- test/teststl.cpp | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 7aa0ce4aac6..ec90fb3e302 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -6490,6 +6490,9 @@ static std::vector getContainerSizeFromConstructorArgs(const s if (astIsPointer(args[0])) { if (args.size() == 1 && args[0]->tokType() == Token::Type::eString) return {makeContainerSizeValue(Token::getStrLength(args[0]), known)}; + if (args.size() == 1 && args[0]->variable() && args[0]->variable()->isArray() && + args[0]->variable()->isConst() && args[0]->variable()->dimensions().size() == 1) + return {makeContainerSizeValue(args[0]->variable()->dimensions()[0].num, known)}; if (args.size() == 2 && astIsIntegral(args[1], false)) // { char*, count } return {makeContainerSizeValue(args[1], known)}; } else if (astIsContainer(args[0])) { @@ -6707,23 +6710,25 @@ static void valueFlowContainerSize(const TokenList& tokenlist, for (const ValueFlow::Value& value : values) setTokenValue(tok, value, settings); } - else if (Token::Match(tok->previous(), ",|( {|%str%")) { - int nArg{}; - if (const Token* funcTok = getTokenArgumentFunction(tok, nArg)) { - if (const Function* func = funcTok->function()) { - if (const Variable* var = func->getArgumentVar(nArg)) { - if (var->valueType() && var->valueType()->container && var->valueType()->container->size_templateArgNo < 0) { - auto values = tok->tokType() == Token::Type::eString - ? std::vector{makeContainerSizeValue(Token::getStrLength(tok))} - : getInitListSize(tok, var->valueType(), settings, true); - ValueFlow::Value tokValue; - tokValue.valueType = ValueFlow::Value::ValueType::TOK; - tokValue.tokvalue = tok; - tokValue.setKnown(); - values.push_back(std::move(tokValue)); - - for (const ValueFlow::Value &value : values) - setTokenValue(tok, value, settings); + else if (Token::Match(tok->previous(), ",|(") && (Token::Match(tok, "{|%str%") || settings.library.detectContainer(tok))) { + if (Token* argTok = tok->previous()->astOperand2()) { + int nArg{}; + if (const Token* funcTok = getTokenArgumentFunction(argTok, nArg)) { + if (const Function* func = funcTok->function()) { + if (const Variable* var = func->getArgumentVar(nArg)) { + if (var->valueType() && var->valueType()->container && var->valueType()->container->size_templateArgNo < 0) { + auto values = argTok->tokType() == Token::Type::eString + ? std::vector{makeContainerSizeValue(Token::getStrLength(argTok))} + : getInitListSize(argTok, var->valueType(), settings, true); + ValueFlow::Value tokValue; + tokValue.valueType = ValueFlow::Value::ValueType::TOK; + tokValue.tokvalue = argTok; + tokValue.setKnown(); + values.push_back(std::move(tokValue)); + + for (const ValueFlow::Value& value : values) + setTokenValue(argTok, value, settings); + } } } } diff --git a/test/teststl.cpp b/test/teststl.cpp index 636fd36b1d0..c24bf2a5fb1 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -980,6 +980,24 @@ class TestStl : public TestFixture { "}\n"); ASSERT_EQUALS("[test.cpp:4:13]: error: Out of bounds access in 'x[3]', if 'x' size is 1 and '3' is 3 [containerOutOfBounds]\n", errout_str()); + + checkNormal("int main() {\n" + " const char a[] = \"abc\";\n" + " std::string_view x{ a };\n" + " return x[5];\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4:13]: error: Out of bounds access in 'x[5]', if 'x' size is 4 and '5' is 5 [containerOutOfBounds]\n", + errout_str()); + + checkNormal("int f(const std::string& v) {\n" + " return v[2];\n" + "}\n" + "int main() {\n" + " std::string_view x{ \"a\" };\n" + " return f(std::string(x));\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:13]: error: Out of bounds access in 'v[2]', if 'v' size is 1 and '2' is 2 [containerOutOfBounds]\n", + errout_str()); } void outOfBoundsSymbolic() From 5fc51d1116333aa35bf33bbe14f1e40c20121488 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 14 Feb 2026 18:59:09 +0100 Subject: [PATCH 140/675] Fix #14308 FP nullPointerRedundantCheck with pointer reference parameter (*&) (#8197) --- .selfcheck_suppressions | 2 -- lib/reverseanalyzer.cpp | 4 ++-- test/testnullpointer.cpp | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.selfcheck_suppressions b/.selfcheck_suppressions index 764b8818308..69885eb2263 100644 --- a/.selfcheck_suppressions +++ b/.selfcheck_suppressions @@ -1,8 +1,6 @@ missingIncludeSystem # should not be reported - see #13387 checkersReport -# false positive - see #14308 -nullPointerRedundantCheck:externals/simplecpp/simplecpp.cpp:3246 # warnings in Qt generated code we cannot fix funcArgNamesDifferent:*/moc_checkthread.cpp diff --git a/lib/reverseanalyzer.cpp b/lib/reverseanalyzer.cpp index 671426f5d2d..6ebceb41b8f 100644 --- a/lib/reverseanalyzer.cpp +++ b/lib/reverseanalyzer.cpp @@ -298,13 +298,13 @@ namespace { if (!condTok) break; Analyzer::Action condAction = analyzeRecursive(condTok); + if (condAction.isModified()) + break; const bool inLoop = Token::Match(condTok->astTop()->previous(), "for|while ("); // Evaluate condition of for and while loops first if (inLoop) { if (Token::findmatch(tok->link(), "goto|break", tok)) break; - if (condAction.isModified()) - break; valueFlowGenericForward(condTok, analyzer, tokenlist, errorLogger, settings); } Token* thenEnd; diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 96e188075e4..f2664b05285 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -3787,6 +3787,21 @@ class TestNullPointer : public TestFixture { " g(x);\n" "}"); ASSERT_EQUALS("", errout_str()); + + check("struct T {\n" // #14308 + " bool b{};\n" + " T* next{};\n" + "};\n" + "bool g(const T*& r) {\n" + " const T* t = r;\n" + " r = t->next;\n" + " return t->b;\n" + "}\n" + "void f(const T* tok) {\n" + " if (g(tok)) {}\n" + " if (tok) {}\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void nullpointerExit() { From 90423025114c4bcc2d6a4a40abfb8d3b643e1d6f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 14 Feb 2026 19:27:18 +0100 Subject: [PATCH 141/675] Partial fix for #10976 FN autoVariables [inconclusive] (regression) (#8170) --- lib/checkautovariables.cpp | 26 +++++++++++++++++++++++--- test/testautovariables.cpp | 18 ++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 867758a3210..c164643594d 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -263,6 +263,23 @@ static bool hasOverloadedAssignment(const Token* tok, bool& inconclusive) return true; } +static bool isMemberAssignment(const Token* tok, const Token*& rhs, const Settings& settings) +{ + if (!Token::Match(tok, "[;{}] %var% . %var%")) + return false; + if (!isPtrArg(tok->next())) + return false; + const Token* assign = tok->tokAt(2)->astParent(); + while (Token::simpleMatch(assign, "[")) + assign = assign->astParent(); + if (!Token::simpleMatch(assign, "=")) + return false; + if (!isAutoVariableRHS(assign->astOperand2(), settings)) + return false; + rhs = assign->astOperand2(); + return true; +} + void CheckAutoVariables::autoVariables() { logChecker("CheckAutoVariables::autoVariables"); @@ -277,6 +294,7 @@ void CheckAutoVariables::autoVariables() continue; } // Critical assignment + const Token* rhs{}; if (Token::Match(tok, "[;{}] %var% =") && isRefPtrArg(tok->next()) && isAutoVariableRHS(tok->tokAt(2)->astOperand2(), *mSettings)) { checkAutoVariableAssignment(tok->next(), false); } else if (Token::Match(tok, "[;{}] * %var% =") && isPtrArg(tok->tokAt(2)) && isAutoVariableRHS(tok->tokAt(3)->astOperand2(), *mSettings)) { @@ -285,12 +303,12 @@ void CheckAutoVariables::autoVariables() if (!hasOverloadedAssignment(lhs, inconclusive) || (printInconclusive && inconclusive)) checkAutoVariableAssignment(tok->next(), inconclusive); tok = tok->tokAt(4); - } else if (Token::Match(tok, "[;{}] %var% . %var% =") && isPtrArg(tok->next()) && isAutoVariableRHS(tok->tokAt(4)->astOperand2(), *mSettings)) { + } else if (isMemberAssignment(tok, rhs, *mSettings)) { const Token* lhs = tok->tokAt(3); bool inconclusive = false; if (!hasOverloadedAssignment(lhs, inconclusive) || (printInconclusive && inconclusive)) checkAutoVariableAssignment(tok->next(), inconclusive); - tok = tok->tokAt(5); + tok = rhs; } else if (Token::Match(tok, "[;{}] %var% [") && Token::simpleMatch(tok->linkAt(2), "] =") && (isPtrArg(tok->next()) || isArrayArg(tok->next(), *mSettings)) && isAutoVariableRHS(tok->linkAt(2)->next()->astOperand2(), *mSettings)) { @@ -330,8 +348,10 @@ bool CheckAutoVariables::checkAutoVariableAssignment(const Token *expr, bool inc if (!startToken) startToken = Token::findsimplematch(expr, "=")->next(); for (const Token *tok = startToken; tok; tok = tok->next()) { - if (tok->str() == "}" && tok->scope()->type == ScopeType::eFunction) + if (tok->str() == "}" && tok->scope()->type == ScopeType::eFunction) { errorAutoVariableAssignment(expr, inconclusive); + return true; + } if (Token::Match(tok, "return|throw|break|continue")) { errorAutoVariableAssignment(expr, inconclusive); diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 573f29c0d48..6c1267ae288 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -711,8 +711,7 @@ class TestAutoVariables : public TestFixture { " g(&s);\n" "}"); ASSERT_EQUALS( - "[test.cpp:4:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n" - "[test.cpp:4:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n", // duplicate + "[test.cpp:4:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n", errout_str()); } @@ -4700,6 +4699,21 @@ class TestAutoVariables : public TestFixture { "}\n"); ASSERT_EQUALS("", errout_str()); + check("struct S {\n" + " int* a[1];\n" + " int* b[1][1];\n" + "};\n" + "void f(S* s) {\n" + " int i = 0;\n" + " s->a[0] = &i;\n" + "}\n" + "void g(S* s) {\n" + " int i = 0;\n" + " s->b[0][0] = &i;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:7:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n" + "[test.cpp:11:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n", + errout_str()); } void deadPointer() { From 29b92af060a231cfd6a28d863cc40a26cc693b20 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 14 Feb 2026 20:50:24 +0100 Subject: [PATCH 142/675] Fix #14481 FN constParameterPointer when returning struct member in if (#8202) --- lib/checkother.cpp | 13 ++++++++++++- test/testother.cpp | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index fec362107f5..d045fb142c8 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1838,6 +1838,17 @@ static bool isCastToInteger(const Token* tok) return tok && tok->isCast() && tok->valueType() && tok->valueType()->isIntegral() && tok->valueType()->pointer == 0; } +static const Function* getEnclosingFunction(const Variable* var) +{ + if (var->isArgument()) + return var->scope()->function; + const Scope* scope = var->scope(); + while (scope && scope->type != ScopeType::eFunction) { + scope = scope->nestedIn; + } + return scope ? scope->function : nullptr; +} + void CheckOther::checkConstPointer() { if (!mSettings->severity.isEnabled(Severity::style) && @@ -1917,7 +1928,7 @@ void CheckOther::checkConstPointer() continue; int argn = -1; if (Token::simpleMatch(gparent, "return")) { - const Function* function = gparent->scope()->function; + const Function* function = getEnclosingFunction(var); if (function && (!Function::returnsReference(function) || Function::returnsConst(function))) continue; } diff --git a/test/testother.cpp b/test/testother.cpp index 4acbe18dfea..fadb61426a4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -13214,14 +13214,14 @@ class TestOther : public TestFixture { "}\n"); ASSERT_EQUALS("", errout_str()); - check("struct A { bool x; };\n" + check("struct A { bool x; };\n" // #14481 "bool f(A* a) {\n" " if (a) {\n" " return a->x;\n" " }\n" " return false;\n" "}\n"); - ASSERT_EQUALS("", errout_str()); + ASSERT_EQUALS("[test.cpp:2:11]: (style) Parameter 'a' can be declared as pointer to const [constParameterPointer]\n", errout_str()); check("struct A { int* x; };\n" "bool f(A a) {\n" From 65c94a68fa17cbaf709fdcc567ca1d35e57b6abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 14 Feb 2026 21:00:16 +0100 Subject: [PATCH 143/675] improved errorhandling of analyzer information loading (#8159) --- cli/cmdlineparser.cpp | 3 + lib/analyzerinfo.cpp | 130 ++++++++++++++++++++++++++--------- lib/analyzerinfo.h | 9 ++- lib/checkunusedfunctions.cpp | 7 +- lib/cppcheck.cpp | 21 +++--- lib/errorlogger.cpp | 1 + lib/settings.h | 3 + test/cli/other_test.py | 100 +++++++++++++++++++++++++++ test/testcmdlineparser.cpp | 8 +++ 9 files changed, 238 insertions(+), 44 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 7c18e428023..c017e238409 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -621,6 +621,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a mSettings.cppHeaderProbe = true; } + else if (std::strcmp(argv[i], "--debug-analyzerinfo") == 0) + mSettings.debugainfo = true; + else if (std::strcmp(argv[i], "--debug-ast") == 0) mSettings.debugast = true; diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index ea6c414b7b0..d484f7d50a9 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -82,29 +83,56 @@ void AnalyzerInformation::close() } } -bool AnalyzerInformation::skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors) +bool AnalyzerInformation::skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors, bool debug) { const tinyxml2::XMLElement * const rootNode = analyzerInfoDoc.FirstChildElement(); - if (rootNode == nullptr) + if (rootNode == nullptr) { + if (debug) + std::cout << "discarding cached result - no root node found" << std::endl; return false; + } - const char *attr = rootNode->Attribute("hash"); - if (!attr || attr != std::to_string(hash)) + if (strcmp(rootNode->Name(), "analyzerinfo") != 0) { + if (debug) + std::cout << "discarding cached result - unexpected root node" << std::endl; return false; + } - // Check for invalid license error or internal error, in which case we should retry analysis - for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) { - if (std::strcmp(e->Name(), "error") == 0 && - (e->Attribute("id", "premium-invalidLicense") || - e->Attribute("id", "premium-internalError") || - e->Attribute("id", "internalError") - )) - return false; + const char * const attr = rootNode->Attribute("hash"); + if (!attr) { + if (debug) + std::cout << "discarding cached result - no 'hash' attribute found" << std::endl; + return false; + } + if (attr != std::to_string(hash)) { + if (debug) + std::cout << "discarding cached result - hash mismatch" << std::endl; + return false; } for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) { - if (std::strcmp(e->Name(), "error") == 0) - errors.emplace_back(e); + if (std::strcmp(e->Name(), "error") != 0) + continue; + + // TODO: discarding results on internalError doesn't make sense since that won't fix itself + // Check for invalid license error or internal error, in which case we should retry analysis + static const std::array s_ids{ + "premium-invalidLicense", + "premium-internalError", + "internalError" + }; + for (const auto* id : s_ids) + { + // cppcheck-suppress useStlAlgorithm + if (e->Attribute("id", id)) { + if (debug) + std::cout << "discarding cached result - '" << id << "' encountered" << std::endl; + errors.clear(); + return false; + } + } + + errors.emplace_back(e); } return true; @@ -138,27 +166,43 @@ std::string AnalyzerInformation::getAnalyzerInfoFile(const std::string &buildDir filename = sourcefile; else filename = sourcefile.substr(pos + 1); + // TODO: is this correct? the above code will return files ending in '.aN'. Also does not consider the ID return Path::join(buildDir, std::move(filename)) + ".analyzerinfo"; } -bool AnalyzerInformation::analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId, std::size_t hash, std::list &errors) +bool AnalyzerInformation::analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId, std::size_t hash, std::list &errors, bool debug) { + if (mOutputStream.is_open()) + throw std::runtime_error("analyzer information file is already open"); + if (buildDir.empty() || sourcefile.empty()) return true; - close(); const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(buildDir,sourcefile,cfg,fsFileId); - tinyxml2::XMLDocument analyzerInfoDoc; - const tinyxml2::XMLError xmlError = analyzerInfoDoc.LoadFile(analyzerInfoFile.c_str()); - if (xmlError == tinyxml2::XML_SUCCESS && skipAnalysis(analyzerInfoDoc, hash, errors)) - return false; + { + tinyxml2::XMLDocument analyzerInfoDoc; + const tinyxml2::XMLError xmlError = analyzerInfoDoc.LoadFile(analyzerInfoFile.c_str()); + if (xmlError == tinyxml2::XML_SUCCESS) { + if (skipAnalysis(analyzerInfoDoc, hash, errors, debug)) { + if (debug) + std::cout << "skipping analysis - loaded " << errors.size() << " cached finding(s) from '" << analyzerInfoFile << "'" << std::endl; + return false; + } + } + else if (xmlError != tinyxml2::XML_ERROR_FILE_NOT_FOUND) { + if (debug) + std::cout << "discarding cached result - failed to load '" << analyzerInfoFile << "' (" << tinyxml2::XMLDocument::ErrorIDToName(xmlError) << ")" << std::endl; + } + else if (debug) + std::cout << "no cached result '" << analyzerInfoFile << "' found" << std::endl; + } mOutputStream.open(analyzerInfoFile); - if (mOutputStream.is_open()) { - mOutputStream << "\n"; - mOutputStream << "\n"; - } + if (!mOutputStream.is_open()) + throw std::runtime_error("failed to open '" + analyzerInfoFile + "'"); + mOutputStream << "\n"; + mOutputStream << "\n"; return true; } @@ -175,6 +219,7 @@ void AnalyzerInformation::setFileInfo(const std::string &check, const std::strin mOutputStream << " \n" << fileInfo << " \n"; } +// TODO: report detailed errors? bool AnalyzerInformation::Info::parse(const std::string& filesTxtLine) { const std::string::size_type sep1 = filesTxtLine.find(sep); if (sep1 == std::string::npos) @@ -202,37 +247,58 @@ bool AnalyzerInformation::Info::parse(const std::string& filesTxtLine) { return true; } -// TODO: bail out on unexpected data -void AnalyzerInformation::processFilesTxt(const std::string& buildDir, const std::function& handler) +std::string AnalyzerInformation::processFilesTxt(const std::string& buildDir, const std::function& handler, bool debug) { const std::string filesTxt(buildDir + "/files.txt"); std::ifstream fin(filesTxt.c_str()); std::string filesTxtLine; while (std::getline(fin, filesTxtLine)) { AnalyzerInformation::Info filesTxtInfo; - if (!filesTxtInfo.parse(filesTxtLine)) { - return; - } + if (!filesTxtInfo.parse(filesTxtLine)) + return "failed to parse '" + filesTxtLine + "' from '" + filesTxt + "'"; + + if (filesTxtInfo.afile.empty()) + return "empty afile from '" + filesTxt + "'"; const std::string xmlfile = buildDir + '/' + filesTxtInfo.afile; tinyxml2::XMLDocument doc; const tinyxml2::XMLError error = doc.LoadFile(xmlfile.c_str()); + if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) { + /* FIXME: this can currently not be reported as an error because: + * - --clang does not generate any analyzer information - see #14456 + * - markup files might not generate analyzer information + * - files with preprocessor errors might not generate analyzer information + */ + if (debug) + std::cout << "'" + xmlfile + "' from '" + filesTxt + "' not found"; + continue; + } + if (error != tinyxml2::XML_SUCCESS) - return; + return "failed to load '" + xmlfile + "' from '" + filesTxt + "'"; const tinyxml2::XMLElement * const rootNode = doc.FirstChildElement(); if (rootNode == nullptr) - return; + return "no root node found in '" + xmlfile + "' from '" + filesTxt + "'"; + + if (strcmp(rootNode->Name(), "analyzerinfo") != 0) + return "unexpected root node in '" + xmlfile + "' from '" + filesTxt + "'"; for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) { if (std::strcmp(e->Name(), "FileInfo") != 0) continue; const char *checkattr = e->Attribute("check"); - if (checkattr == nullptr) + if (checkattr == nullptr) { + if (debug) + std::cout << "'check' attribute missing in 'FileInfo' in '" << xmlfile << "' from '" << filesTxt + "'"; continue; + } handler(checkattr, e, filesTxtInfo); } } + + // TODO: error on empty file? + return ""; } diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 1547ef50f16..5435be62560 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -61,7 +61,10 @@ class CPPCHECKLIB AnalyzerInformation { /** Close current TU.analyzerinfo file */ void close(); - bool analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId, std::size_t hash, std::list &errors); + /** + * @throws std::runtime_error thrown if the output file is already open or the output file cannot be opened + */ + bool analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId, std::size_t hash, std::list &errors, bool debug = false); void reportErr(const ErrorMessage &msg); void setFileInfo(const std::string &check, const std::string &fileInfo); static std::string getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId); @@ -77,14 +80,14 @@ class CPPCHECKLIB AnalyzerInformation { std::string sourceFile; }; - static void processFilesTxt(const std::string& buildDir, const std::function& handler); + static std::string processFilesTxt(const std::string& buildDir, const std::function& handler, bool debug = false); protected: static std::string getFilesTxt(const std::list &sourcefiles, const std::list &fileSettings); static std::string getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fsFileId); - static bool skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors); + static bool skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors, bool debug = false); private: std::ofstream mOutputStream; diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index f6daec51f20..8f7c3ab3812 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -482,7 +482,12 @@ void CheckUnusedFunctions::analyseWholeProgram(const Settings &settings, ErrorLo } }; - AnalyzerInformation::processFilesTxt(buildDir, handler); + const std::string err = AnalyzerInformation::processFilesTxt(buildDir, handler, settings.debugainfo); + if (!err.empty()) { + const ErrorMessage errmsg({}, "", Severity::error, err, "internalError", Certainty::normal); + errorLogger.reportErr(errmsg); + return; + } for (auto decl = decls.cbegin(); decl != decls.cend(); ++decl) { const std::string &functionName = stripTemplateParameters(decl->first); diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index faf6b2126d1..80b43228a58 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -973,7 +973,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str mLogger->setAnalyzerInfo(nullptr); std::list errors; - analyzerInformation->analyzeFile(mSettings.buildDir, file.spath(), cfgname, file.fsFileId(), hash, errors); + analyzerInformation->analyzeFile(mSettings.buildDir, file.spath(), cfgname, file.fsFileId(), hash, errors, mSettings.debugainfo); analyzerInformation->setFileInfo("CheckUnusedFunctions", mUnusedFunctionsCheck->analyzerInfo(tokenizer)); analyzerInformation->close(); } @@ -1019,7 +1019,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str // Calculate hash so it can be compared with old hash / future hashes const std::size_t hash = calculateHash(preprocessor, file.spath()); std::list errors; - if (!analyzerInformation->analyzeFile(mSettings.buildDir, file.spath(), cfgname, file.fsFileId(), hash, errors)) { + if (!analyzerInformation->analyzeFile(mSettings.buildDir, file.spath(), cfgname, file.fsFileId(), hash, errors, mSettings.debugainfo)) { while (!errors.empty()) { mErrorLogger.reportErr(errors.front()); errors.pop_front(); @@ -1860,12 +1860,17 @@ unsigned int CppCheck::analyseWholeProgram(const std::string &buildDir, const st } }; - AnalyzerInformation::processFilesTxt(buildDir, handler); - - // Analyse the tokens - // cppcheck-suppress shadowFunction - TODO: fix this - for (Check *check : Check::instances()) - check->analyseWholeProgram(ctuFileInfo, fileInfoList, mSettings, mErrorLogger); + const std::string err = AnalyzerInformation::processFilesTxt(buildDir, handler, mSettings.debugainfo); + if (!err.empty()) { + const ErrorMessage errmsg({}, "", Severity::error, err, "internalError", Certainty::normal); + mErrorLogger.reportErr(errmsg); + } + else { + // Analyse the tokens + // cppcheck-suppress shadowFunction - TODO: fix this + for (Check *check : Check::instances()) + check->analyseWholeProgram(ctuFileInfo, fileInfoList, mSettings, mErrorLogger); + } for (Check::FileInfo *fi : fileInfoList) delete fi; diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index e62ed6b806d..13f66c13d1a 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -162,6 +162,7 @@ ErrorMessage::ErrorMessage(ErrorPath errorPath, const TokenList *tokenList, Seve // hash = calculateWarningHash(tokenList, hashWarning.str()); } +// TODO: improve errorhandling? ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg) : severity(Severity::none), cwe(0U), diff --git a/lib/settings.h b/lib/settings.h index 04541cda08c..6521ba4581d 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -189,6 +189,9 @@ class CPPCHECKLIB WARN_UNUSED Settings { /** @brief Are we running from DACA script? */ bool daca{}; + /** @brief Is --debug-analyzerinfo given? */ + bool debugainfo{}; + /** @brief Is --debug-ast given? */ bool debugast{}; diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 1165f633e71..b8433bceef3 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -4081,3 +4081,103 @@ def test_active_unusedfunction_only_misra_builddir(tmp_path): 'CheckUnusedFunctions::check' ] __test_active_checkers(tmp_path, 1, 386, use_unusedfunction_only=True, use_misra=True, checkers_exp=checkers_exp) + + +def test_analyzerinfo(tmp_path): + test_file = tmp_path / 'test.c' + with open(test_file, "w") as f: + f.write( +"""void f() +{ + (void)(*((int*)0)); +} +""") + + build_dir = tmp_path / 'b1' + os.makedirs(build_dir) + + test_a1_file = build_dir / 'test.a1' + + args = [ + '-q', + '--debug-analyzerinfo', + '--template=simple', + '--cppcheck-build-dir={}'.format(build_dir), + '--enable=all', + str(test_file) + ] + + stderr_exp = [ + '{}:3:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file), + "{}:1:6: style: The function 'f' is never used. [unusedFunction]".format(test_file) + ] + + def run_and_assert_cppcheck(stdout_exp): + exitcode, stdout, stderr = cppcheck(args) + assert exitcode == 0, stdout + assert stdout.splitlines() == stdout_exp + assert stderr.splitlines() == stderr_exp + + test_a1_file_s = str(test_a1_file).replace('\\', '/') + + # no cached results + run_and_assert_cppcheck([ + "no cached result '{}' found".format(test_a1_file_s) + ]) + + # cached results + run_and_assert_cppcheck([ + "skipping analysis - loaded 1 cached finding(s) from '{}'".format(test_a1_file_s) + ]) + + # modified file + with open(test_file, 'a') as f: + f.write('\n#define DEF') + + run_and_assert_cppcheck([ + "discarding cached result - hash mismatch" # TODO: add filename + ]) + + # invalid XML + with open(test_a1_file, 'a') as f: + f.write('.') + + run_and_assert_cppcheck([ + "discarding cached result - failed to load '{}' (XML_ERROR_PARSING_TEXT)".format(test_a1_file_s) + ]) + + # missing root node + with open(test_a1_file, 'w') as f: + f.write('') + + run_and_assert_cppcheck([ + "discarding cached result - no root node found" # TODO: add filename + ]) + + # mismatched root node + with open(test_a1_file, 'w') as f: + f.write('') + + run_and_assert_cppcheck([ + "discarding cached result - unexpected root node" # TODO: add filename + ]) + + # missing 'hash' attribute + with open(test_a1_file, 'w') as f: + f.write('') + + run_and_assert_cppcheck([ + "discarding cached result - no 'hash' attribute found" # TODO: add filename + ]) + + # invalid 'hash' attribute + with open(test_a1_file, 'w') as f: + f.write('') + + run_and_assert_cppcheck([ + "discarding cached result - hash mismatch" # TODO: add filename + ]) + + # TODO: + # - invalid error + # - internalError diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 3b343cbc92e..b6690f8d5c7 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -493,6 +493,7 @@ class TestCmdlineParser : public TestFixture { TEST_CASE(safetyOverride); TEST_CASE(noSafety); TEST_CASE(noSafetyOverride); + TEST_CASE(debugAnalyzerinfo); TEST_CASE(ignorepaths1); TEST_CASE(ignorepaths2); @@ -3424,6 +3425,13 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS(false, settings->safety); } + void debugAnalyzerinfo() { + REDIRECT; + const char * const argv[] = {"cppcheck", "--debug-analyzerinfo", "file.cpp"}; + ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parseFromArgs(argv)); + ASSERT_EQUALS(true, settings->debugainfo); + } + void ignorepaths1() { REDIRECT; const char * const argv[] = {"cppcheck", "-isrc", "file.cpp"}; From 781277ce8a339e379b881d4fe13d9a82bf1f5e9c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 15 Feb 2026 09:54:23 +0100 Subject: [PATCH 144/675] Fix #14477 internalAstError with fold expression in template (#8203) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Marjamäki --- lib/templatesimplifier.cpp | 11 +++++++++-- test/testsimplifytemplate.cpp | 14 +++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 9d2eac49483..16b4bd18cd9 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -2104,8 +2104,6 @@ void TemplateSimplifier::expandTemplate( Token * const beforeTypeToken = mTokenList.back(); bool pointerType = false; const bool isVariadicTemplateArg = templateDeclaration.isVariadic() && itype + 1 == typeParametersInDeclaration.size(); - if (isVariadicTemplateArg && mTypesUsedInTemplateInstantiation.size() > 1 && !Token::Match(tok3->next(), "...|<")) - continue; if (isVariadicTemplateArg && Token::Match(tok3, "%name% ... %name%")) tok3 = tok3->tokAt(2); if (!isVariadicTemplateArg && copy && Token::Match(mTypesUsedInTemplateInstantiation[itype].token(), "%num% ,|>|>>") && @@ -2130,6 +2128,7 @@ void TemplateSimplifier::expandTemplate( } } const std::string endStr(isVariadicTemplateArg ? ">" : ",>"); + Token* begPar = nullptr; for (Token *typetok = mTypesUsedInTemplateInstantiation[itype].token(); typetok && (typeindentlevel > 0 || endStr.find(typetok->str()[0]) == std::string::npos); typetok = typetok->next()) { @@ -2153,6 +2152,10 @@ void TemplateSimplifier::expandTemplate( --typeindentlevel; Token *back; if (copy) { + if (isVariadicTemplateArg && typetok == mTypesUsedInTemplateInstantiation[itype].token() && typetok->isLiteral()) { + mTokenList.addtoken("(", mTokenList.back()); + begPar = mTokenList.back(); + } mTokenList.addtoken(typetok, tok3); back = mTokenList.back(); } else @@ -2181,6 +2184,10 @@ void TemplateSimplifier::expandTemplate( if (copy) back->templateArgFrom(typetok); } + if (begPar) { + mTokenList.addtoken(")", mTokenList.back()); + Token::createMutualLinks(begPar, mTokenList.back()); + } if (pointerType && Token::simpleMatch(beforeTypeToken, "const")) { mTokenList.addtoken(beforeTypeToken); beforeTypeToken->deleteThis(); diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 52df0597f92..fb95cd8c136 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -6372,7 +6372,7 @@ class TestSimplifyTemplate : public TestFixture { "class E<1,3> { " "template < int ... I > " "int f ( int n , std :: integer_sequence < int , I ... > ) { " - "return ( ( ( I == n ) ? : 0 ) + ... ) ; " + "return ( ( ( I == n ) ? ( 1 , 3 ) : 0 ) + ... ) ; " // TODO the simplification is not quite correct "} " "} ;"; ASSERT_EQUALS(expected, tok(code)); @@ -6390,6 +6390,18 @@ class TestSimplifyTemplate : public TestFixture { "A a ; " "struct A { } ;"; ASSERT_EQUALS(expected2, tok(code2)); + + const char code3[] = "template \n" // #14477 + " int f() {\n" + " return (0 | ... | (1, 2, 4));\n" + "}\n" + "int main() {\n" + " return f<1, 2, 4>();\n" + "}\n"; + const char expected3[] = "int f<1,2,4> ( ) ; " + "int main ( ) { return f<1,2,4> ( ) ; } " + "int f<1,2,4> ( ) { return ( 0 | ... | ( 1 , 2 , 4 ) ) ; }"; + ASSERT_EQUALS(expected3, tok(code3)); } void template_variable_1() { From a150ff48eed15a6351729c9770e4ed926a5d6887 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 15 Feb 2026 12:51:46 +0100 Subject: [PATCH 145/675] Fix #14486 FP selfInitialization with local class derived from template (#8208) --- lib/tokenize.cpp | 2 +- test/testvarid.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7c15be961bc..d0e46b54542 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -108,7 +108,7 @@ static bool isClassStructUnionEnumStart(const Token * tok) if (!Token::Match(tok->previous(), "class|struct|union|enum|%name%|>|>> {")) return false; const Token * tok2 = tok->previous(); - while (tok2 && !Token::Match(tok2, "class|struct|union|enum|{|}|)|;|>|>>")) + while (tok2 && !Token::Match(tok2, "class|struct|union|enum|{|}|)|;")) tok2 = tok2->previous(); return Token::Match(tok2, "class|struct|union|enum") && !Token::simpleMatch(tok2->tokAt(-1), "->"); } diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 32bff9c5724..55627299e1d 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -149,6 +149,7 @@ class TestVarID : public TestFixture { TEST_CASE(varid_in_class26); TEST_CASE(varid_in_class27); TEST_CASE(varid_in_class28); + TEST_CASE(varid_in_class29); TEST_CASE(varid_namespace_1); // #7272 TEST_CASE(varid_namespace_2); // #7000 TEST_CASE(varid_namespace_3); // #8627 @@ -2380,6 +2381,28 @@ class TestVarID : public TestFixture { ASSERT_EQUALS(expected, tokenize(code)); } + void varid_in_class29() { + const char code[] = "struct S {\n" // #14486 + " const int& r;\n" + " explicit S(const int& r) : r(r) {}\n" + " static void f() {\n" + " struct T : std::vector {\n" + " bool g() const { return empty(); }\n" + " };\n" + " }\n" + "};\n"; + const char expected[] = "1: struct S {\n" + "2: const int & r@1 ;\n" + "3: explicit S ( const int & r@2 ) : r@1 ( r@2 ) { }\n" + "4: static void f ( ) {\n" + "5: struct T : std :: vector < int > {\n" + "6: bool g ( ) const { return empty ( ) ; }\n" + "7: } ;\n" + "8: }\n" + "9: } ;\n"; + ASSERT_EQUALS(expected, tokenize(code)); + } + void varid_namespace_1() { // #7272 const char code[] = "namespace Blah {\n" " struct foo { int x;};\n" From 6d033040559757483e7133ea1e62978b45e02f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 16 Feb 2026 09:10:03 +0100 Subject: [PATCH 146/675] testrunner: merged `ASSERT_THROW_EQUALS_2` with (unused) `ASSERT_THROW_EQUALS` (#8219) --- test/fixture.h | 3 +-- test/testpath.cpp | 4 ++-- test/testpreprocessor.cpp | 2 +- test/testprogrammemory.cpp | 4 ++-- test/testsymboldatabase.cpp | 6 +++--- test/testutils.cpp | 36 ++++++++++++++++++------------------ 6 files changed, 27 insertions(+), 28 deletions(-) diff --git a/test/fixture.h b/test/fixture.h index 5983ae66a3a..2d519f40f45 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -331,8 +331,7 @@ class TestInstance { #define ASSERT_EQUALS_ENUM_LOC( EXPECTED, ACTUAL, FILE_, LINE_ ) assertEqualsEnum(FILE_, LINE_, (EXPECTED), (ACTUAL)) #define ASSERT_EQUALS_ENUM_LOC_MSG( EXPECTED, ACTUAL, MSG, FILE_, LINE_ ) assertEqualsEnum(FILE_, LINE_, (EXPECTED), (ACTUAL), MSG) #define TODO_ASSERT_EQUALS_ENUM( WANTED, CURRENT, ACTUAL ) todoAssertEqualsEnum(__FILE__, __LINE__, WANTED, CURRENT, ACTUAL) -#define ASSERT_THROW_EQUALS( CMD, EXCEPTION, EXPECTED ) do { try { (void)(CMD); assertThrowFail(__FILE__, __LINE__); } catch (const EXCEPTION&e) { assertEquals(__FILE__, __LINE__, EXPECTED, e.errorMessage); } catch (...) { assertThrowFail(__FILE__, __LINE__); } } while (false) -#define ASSERT_THROW_EQUALS_2( CMD, EXCEPTION, EXPECTED ) do { try { (void)(CMD); assertThrowFail(__FILE__, __LINE__); } catch (const AssertFailedError&) { throw; } catch (const EXCEPTION&e) { assertEquals(__FILE__, __LINE__, EXPECTED, e.what()); } catch (...) { assertThrowFail(__FILE__, __LINE__); } } while (false) +#define ASSERT_THROW_EQUALS( CMD, EXCEPTION, EXPECTED ) do { try { (void)(CMD); assertThrowFail(__FILE__, __LINE__); } catch (const AssertFailedError&) { throw; } catch (const EXCEPTION&e) { assertEquals(__FILE__, __LINE__, EXPECTED, e.what()); } catch (...) { assertThrowFail(__FILE__, __LINE__); } } while (false) #define ASSERT_THROW_INTERNAL( CMD, TYPE ) do { try { (void)(CMD); assertThrowFail(__FILE__, __LINE__); } catch (const AssertFailedError&) { throw; } catch (const InternalError& e) { assertEqualsEnum(__FILE__, __LINE__, InternalError::TYPE, e.type); } catch (...) { assertThrowFail(__FILE__, __LINE__); } } while (false) #define ASSERT_THROW_INTERNAL_EQUALS( CMD, TYPE, EXPECTED ) do { try { (void)(CMD); assertThrowFail(__FILE__, __LINE__); } catch (const AssertFailedError&) { throw; } catch (const InternalError& e) { assertEqualsEnum(__FILE__, __LINE__, InternalError::TYPE, e.type); assertEquals(__FILE__, __LINE__, EXPECTED, e.errorMessage); } catch (...) { assertThrowFail(__FILE__, __LINE__); } } while (false) #define ASSERT_NO_THROW( CMD ) do { try { (void)(CMD); } catch (const AssertFailedError&) { throw; } catch (...) { assertNoThrowFail(__FILE__, __LINE__, true); } } while (false) diff --git a/test/testpath.cpp b/test/testpath.cpp index 7c181e28afb..5f4770f1cff 100644 --- a/test/testpath.cpp +++ b/test/testpath.cpp @@ -533,7 +533,7 @@ class TestPath : public TestFixture { #ifndef _WIN32 // the underlying realpath() call only returns something if the path actually exists - ASSERT_THROW_EQUALS_2(Path::getAbsoluteFilePath("testabspath2.txt"), std::runtime_error, "path 'testabspath2.txt' does not exist"); + ASSERT_THROW_EQUALS(Path::getAbsoluteFilePath("testabspath2.txt"), std::runtime_error, "path 'testabspath2.txt' does not exist"); #else ASSERT_EQUALS(Path::toNativeSeparators(Path::join(cwd, "testabspath2.txt")), Path::getAbsoluteFilePath("testabspath2.txt")); #endif @@ -572,7 +572,7 @@ class TestPath : public TestFixture { #endif #ifndef _WIN32 - ASSERT_THROW_EQUALS_2(Path::getAbsoluteFilePath("C:\\path\\files.txt"), std::runtime_error, "path 'C:\\path\\files.txt' does not exist"); + ASSERT_THROW_EQUALS(Path::getAbsoluteFilePath("C:\\path\\files.txt"), std::runtime_error, "path 'C:\\path\\files.txt' does not exist"); #endif // TODO: test UNC paths diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 53e2b2cf3f7..c53fed82e01 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -2866,7 +2866,7 @@ class TestPreprocessor : public TestFixture { std::vector files; TokenList tokenlist{settingsDefault, Standards::Language::CPP}; // TODO: can this happen from application code? if yes we need to turn it into a proper error - ASSERT_THROW_EQUALS_2(preprocess(code, files, "test.cpp", tokenlist, dui), std::runtime_error, "unexpected simplecpp::Output type 9"); + ASSERT_THROW_EQUALS(preprocess(code, files, "test.cpp", tokenlist, dui), std::runtime_error, "unexpected simplecpp::Output type 9"); ASSERT(!tokenlist.front()); // nothing is tokenized when an unknown standard is provided } } diff --git a/test/testprogrammemory.cpp b/test/testprogrammemory.cpp index a6cf933d843..6d7c185e80f 100644 --- a/test/testprogrammemory.cpp +++ b/test/testprogrammemory.cpp @@ -98,8 +98,8 @@ class TestProgramMemory : public TestFixture { void at() const { ProgramMemory pm; - ASSERT_THROW_EQUALS_2(pm.at(123), std::out_of_range, "ProgramMemory::at"); - ASSERT_THROW_EQUALS_2(utils::as_const(pm).at(123), std::out_of_range, "ProgramMemory::at"); + ASSERT_THROW_EQUALS(pm.at(123), std::out_of_range, "ProgramMemory::at"); + ASSERT_THROW_EQUALS(utils::as_const(pm).at(123), std::out_of_range, "ProgramMemory::at"); } }; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index e106bb4ccd8..19c6fab336a 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -1872,11 +1872,11 @@ class TestSymbolDatabase : public TestFixture { // TODO: we should provide our own error message #ifdef _MSC_VER - ASSERT_THROW_EQUALS_2(db->getVariableFromVarId(3), std::out_of_range, "invalid vector subscript"); + ASSERT_THROW_EQUALS(db->getVariableFromVarId(3), std::out_of_range, "invalid vector subscript"); #elif !defined(_LIBCPP_VERSION) - ASSERT_THROW_EQUALS_2(db->getVariableFromVarId(3), std::out_of_range, "vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)"); + ASSERT_THROW_EQUALS(db->getVariableFromVarId(3), std::out_of_range, "vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)"); #else - ASSERT_THROW_EQUALS_2(db->getVariableFromVarId(3), std::out_of_range, "vector"); + ASSERT_THROW_EQUALS(db->getVariableFromVarId(3), std::out_of_range, "vector"); #endif } diff --git a/test/testutils.cpp b/test/testutils.cpp index 0aad2c447a1..2526591e11f 100644 --- a/test/testutils.cpp +++ b/test/testutils.cpp @@ -225,24 +225,24 @@ class TestUtils : public TestFixture { ASSERT_EQUALS(1, ::strToInt("1")); ASSERT_EQUALS(-1, ::strToInt("-1")); ASSERT_EQUALS(1, ::strToInt("1")); - ASSERT_THROW_EQUALS_2(::strToInt(""), std::runtime_error, "converting '' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt(""), std::runtime_error, "converting '' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt(" "), std::runtime_error, "converting ' ' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt(" "), std::runtime_error, "converting ' ' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt("-1"), std::runtime_error, "converting '-1' to integer failed - needs to be positive"); - ASSERT_THROW_EQUALS_2(::strToInt("1ms"), std::runtime_error, "converting '1ms' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt("1.0"), std::runtime_error, "converting '1.0' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt("one"), std::runtime_error, "converting 'one' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt("1ms"), std::runtime_error, "converting '1ms' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt("1.0"), std::runtime_error, "converting '1.0' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt("one"), std::runtime_error, "converting 'one' to integer failed - not an integer"); - ASSERT_THROW_EQUALS_2(::strToInt(std::to_string(static_cast(std::numeric_limits::max()) + 1)), std::runtime_error, "converting '2147483648' to integer failed - out of range (limits)"); - ASSERT_THROW_EQUALS_2(::strToInt(std::to_string(static_cast(std::numeric_limits::min()) - 1)), std::runtime_error, "converting '-2147483649' to integer failed - out of range (limits)"); - ASSERT_THROW_EQUALS_2(::strToInt(std::to_string(static_cast(std::numeric_limits::max()) + 1)), std::runtime_error, "converting '128' to integer failed - out of range (limits)"); - ASSERT_THROW_EQUALS_2(::strToInt(std::to_string(static_cast(std::numeric_limits::min()) - 1)), std::runtime_error, "converting '-129' to integer failed - out of range (limits)"); - ASSERT_THROW_EQUALS_2(::strToInt(std::to_string(static_cast(std::numeric_limits::max()) + 1)), std::runtime_error, "converting '4294967296' to integer failed - out of range (limits)"); - ASSERT_THROW_EQUALS_2(::strToInt("9223372036854775808"), std::runtime_error, "converting '9223372036854775808' to integer failed - out of range (stoll)"); // LLONG_MAX + 1 - ASSERT_THROW_EQUALS_2(::strToInt("18446744073709551616"), std::runtime_error, "converting '18446744073709551616' to integer failed - out of range (stoull)"); // ULLONG_MAX + 1 + ASSERT_THROW_EQUALS(::strToInt(""), std::runtime_error, "converting '' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt(""), std::runtime_error, "converting '' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt(" "), std::runtime_error, "converting ' ' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt(" "), std::runtime_error, "converting ' ' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt("-1"), std::runtime_error, "converting '-1' to integer failed - needs to be positive"); + ASSERT_THROW_EQUALS(::strToInt("1ms"), std::runtime_error, "converting '1ms' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt("1.0"), std::runtime_error, "converting '1.0' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt("one"), std::runtime_error, "converting 'one' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt("1ms"), std::runtime_error, "converting '1ms' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt("1.0"), std::runtime_error, "converting '1.0' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt("one"), std::runtime_error, "converting 'one' to integer failed - not an integer"); + ASSERT_THROW_EQUALS(::strToInt(std::to_string(static_cast(std::numeric_limits::max()) + 1)), std::runtime_error, "converting '2147483648' to integer failed - out of range (limits)"); + ASSERT_THROW_EQUALS(::strToInt(std::to_string(static_cast(std::numeric_limits::min()) - 1)), std::runtime_error, "converting '-2147483649' to integer failed - out of range (limits)"); + ASSERT_THROW_EQUALS(::strToInt(std::to_string(static_cast(std::numeric_limits::max()) + 1)), std::runtime_error, "converting '128' to integer failed - out of range (limits)"); + ASSERT_THROW_EQUALS(::strToInt(std::to_string(static_cast(std::numeric_limits::min()) - 1)), std::runtime_error, "converting '-129' to integer failed - out of range (limits)"); + ASSERT_THROW_EQUALS(::strToInt(std::to_string(static_cast(std::numeric_limits::max()) + 1)), std::runtime_error, "converting '4294967296' to integer failed - out of range (limits)"); + ASSERT_THROW_EQUALS(::strToInt("9223372036854775808"), std::runtime_error, "converting '9223372036854775808' to integer failed - out of range (stoll)"); // LLONG_MAX + 1 + ASSERT_THROW_EQUALS(::strToInt("18446744073709551616"), std::runtime_error, "converting '18446744073709551616' to integer failed - out of range (stoull)"); // ULLONG_MAX + 1 { long tmp; From f7130c3b40ba94ffbef0b35b1afcfc0eccdd4588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 17 Feb 2026 00:33:35 +0100 Subject: [PATCH 147/675] fixed #14495 - test/cli/performance_test.py::test_stack_overflow_AST: increased timeout (#8226) --- test/cli/performance_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/cli/performance_test.py b/test/cli/performance_test.py index fe3408a2e61..55da3b3b04e 100644 --- a/test/cli/performance_test.py +++ b/test/cli/performance_test.py @@ -146,8 +146,7 @@ def test_slow_exprid(tmpdir): my_env["DISABLE_VALUEFLOW"] = "1" cppcheck([filename], env=my_env) -@pytest.mark.skipif(sys.platform == 'darwin', reason='GitHub macOS runners are too slow') -@pytest.mark.timeout(30) +@pytest.mark.timeout(35) def test_stack_overflow_AST(tmpdir): # 14435 filename = os.path.join(tmpdir, 'hang.cpp') From 24c7f0bf28f1dcd38765ab651bd595b9466e3f0a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:23:03 +0100 Subject: [PATCH 148/675] Fix #14403 FP ignoredReturnValue for wxPanel::Layout() (#8224) --- cfg/wxwidgets.cfg | 8 ++++++-- test/cfg/wxwidgets.cpp | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cfg/wxwidgets.cfg b/cfg/wxwidgets.cfg index c1370373b54..9dea60761d1 100644 --- a/cfg/wxwidgets.cfg +++ b/cfg/wxwidgets.cfg @@ -17078,12 +17078,16 @@ wxItemKind kind = wxITEM_NORMAL) --> - - + false + + + + false + diff --git a/test/cfg/wxwidgets.cpp b/test/cfg/wxwidgets.cpp index 983f3e1bbc3..c25dfa8e1b4 100644 --- a/test/cfg/wxwidgets.cpp +++ b/test/cfg/wxwidgets.cpp @@ -972,6 +972,10 @@ void ignoredReturnValue_wxDC_GetSizeMM(const wxDC &dc, wxCoord *width, wxCoord * (void)dc.GetSizeMM(); } +void ignoredReturnValue_wxPanel_Layout(wxPanel* panel) { // #14403 + panel->Layout(); +} + wxSizerItem* invalidFunctionArgBool_wxSizer_Add(wxSizer *sizer, wxWindow * window, const wxSizerFlags &flags) { // No warning is expected for From 0a5b103a7783be2691d162c8613cc4439db0685a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 17 Feb 2026 20:51:24 +0100 Subject: [PATCH 149/675] Fix #14496 FN variableScope with nullptr (#8221) --- lib/checkother.cpp | 2 ++ test/testother.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index d045fb142c8..4aaa887d7f0 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1163,6 +1163,8 @@ static bool isSimpleExpr(const Token* tok, const Variable* var, const Settings& return false; if (tok->isNumber() || tok->tokType() == Token::eString || tok->tokType() == Token::eChar || tok->isBoolean()) return true; + if (isNullOperand(tok)) + return true; bool needsCheck = tok->varId() > 0; if (!needsCheck) { if (tok->isArithmeticalOp()) diff --git a/test/testother.cpp b/test/testother.cpp index fadb61426a4..0ccd482c353 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -121,6 +121,7 @@ class TestOther : public TestFixture { TEST_CASE(varScope41); // #11845 TEST_CASE(varScope42); TEST_CASE(varScope43); + TEST_CASE(varScope44); TEST_CASE(oldStylePointerCast); TEST_CASE(intToPointerCast); @@ -1945,6 +1946,32 @@ class TestOther : public TestFixture { ASSERT_EQUALS("[test.cpp:3:12]: (style) The scope of the variable 'x' can be reduced. [variableScope]\n", errout_str()); } + void varScope44() { // #14496 + check("char* f() {\n" + " char* p = nullptr;\n" + " {\n" + " p = strdup(\"abc\");\n" + " if (p) {\n" + " return p;\n" + " }\n" + " }\n" + " return nullptr;\n" + "}\n" + "char* g() {\n" + " char* q = NULL;\n" + " {\n" + " q = strdup(\"abc\");\n" + " if (q) {\n" + " return q;\n" + " }\n" + " }\n" + " return nullptr;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:11]: (style) The scope of the variable 'p' can be reduced. [variableScope]\n" + "[test.cpp:12:11]: (style) The scope of the variable 'q' can be reduced. [variableScope]\n", + errout_str()); + } + #define checkOldStylePointerCast(...) checkOldStylePointerCast_(__FILE__, __LINE__, __VA_ARGS__) template void checkOldStylePointerCast_(const char* file, int line, const char (&code)[size], Standards::cppstd_t std = Standards::CPPLatest) { From 85583d95c680b337bd544af14cc51e3caeb0be06 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 18 Feb 2026 09:18:11 +0100 Subject: [PATCH 150/675] Fix #14172 FN leakReturnValNotUsed with scope operator (regression) (#8225) Co-authored-by: chrchr-github --- lib/checkmemoryleak.cpp | 5 ++++- test/testmemleak.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index ac6329bcf86..542f4e9fc49 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1098,7 +1098,10 @@ void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope) if (allocType == No) continue; - if (tok != tok->next()->astOperand1() && !isNew) + const Token* ftok = tok->next()->astOperand1(); + while (Token::simpleMatch(ftok, "::")) + ftok = ftok->astOperand2() ? ftok->astOperand2() : ftok->astOperand1(); + if (tok != ftok && !isNew) continue; if (isReopenStandardStream(tok)) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 406f46de902..26877650584 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -2752,6 +2752,18 @@ class TestMemleakNoVar : public TestFixture { " if (std::freopen(NULL, \"w+b\", fp2) == NULL) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void f() {\n" // #14172 + " if (malloc(4) == nullptr) {}\n" + " if (::malloc(4) == nullptr) {}\n" + " if (std::malloc(4) == nullptr) {}\n" + " if (::std::malloc(4) == nullptr) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:9]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:3:11]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:4:14]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n" + "[test.cpp:5:16]: (error) Return value of allocation function 'malloc' is not stored. [leakReturnValNotUsed]\n", + errout_str()); } void smartPointerFunctionParam() { From 1f72150a46282d64dedb012be2be83e93f24f700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 19 Feb 2026 10:01:06 +0100 Subject: [PATCH 151/675] added some more @throws doxygen comments (#8220) --- lib/filesettings.h | 3 +++ lib/utils.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/filesettings.h b/lib/filesettings.h index 5a5ece9366b..b51f092d6b4 100644 --- a/lib/filesettings.h +++ b/lib/filesettings.h @@ -34,6 +34,9 @@ class FileWithDetails { public: + /** + * @throws std::runtime_error thrown if given path is empty + */ FileWithDetails(std::string path, Standards::Language lang, std::size_t size) : mLang(lang) , mSize(size) diff --git a/lib/utils.h b/lib/utils.h index c84c72236c1..90bb67c087f 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -281,6 +281,9 @@ bool strToInt(const std::string& str, T &num, std::string* err = nullptr) return true; } +/** + * @throws std::runtime_error thrown if conversion failed + */ template T strToInt(const std::string& str) { From 179f04a09847b11bc35586281546d154a3f2ec62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 19 Feb 2026 22:01:17 +0100 Subject: [PATCH 152/675] Fix #14290 (GUI: detailed progress view that shows what files the threads are working on) (#8217) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ludvig Gunne Lindström --- .selfcheck_suppressions | 2 +- gui/checkthread.cpp | 23 +++++++--- gui/checkthread.h | 16 +++++-- gui/gui.pro | 5 ++- gui/mainwindow.cpp | 17 ++++++++ gui/mainwindow.h | 3 ++ gui/mainwindow.ui | 19 ++++++--- gui/resultsview.cpp | 2 +- gui/resultsview.h | 2 +- gui/test/resultstree/testresultstree.cpp | 14 +++++- gui/threaddetails.cpp | 54 ++++++++++++++++++++++++ gui/threaddetails.h | 44 +++++++++++++++++++ gui/threaddetails.ui | 28 ++++++++++++ gui/threadhandler.cpp | 46 +++++++++++++++++--- gui/threadhandler.h | 32 ++++++++++++++ gui/threadresult.cpp | 24 +++++++---- gui/threadresult.h | 34 +++++++-------- 17 files changed, 314 insertions(+), 51 deletions(-) create mode 100644 gui/threaddetails.cpp create mode 100644 gui/threaddetails.h create mode 100644 gui/threaddetails.ui diff --git a/.selfcheck_suppressions b/.selfcheck_suppressions index 69885eb2263..171a5a997d7 100644 --- a/.selfcheck_suppressions +++ b/.selfcheck_suppressions @@ -10,7 +10,7 @@ funcArgNamesDifferent:*/moc_resultsview.cpp funcArgNamesDifferent:*/moc_threadhandler.cpp funcArgNamesDifferent:*/moc_threadresult.cpp naming-varname:*/gui/ui_*.h -functionStatic:*/ui_fileview.h +functionStatic:*/gui/ui_*.h # --debug-warnings suppressions valueFlowBailout diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index e10bf1ddf5a..ab20602a09b 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -105,8 +105,9 @@ int CheckThread::executeCommand(std::string exe, std::vector args, } -CheckThread::CheckThread(ThreadResult &result) : - mResult(result) +CheckThread::CheckThread(ThreadResult &result, int threadIndex) + : mResult(result) + , mThreadIndex(threadIndex) {} void CheckThread::setSettings(const Settings &settings, std::shared_ptr supprs) @@ -147,9 +148,14 @@ void CheckThread::run() while (file && mState == Running) { const std::string& fname = file->spath(); qDebug() << "Checking file" << QString::fromStdString(fname); + + const Details details{ mThreadIndex, QString::fromStdString(fname), QTime::currentTime(), }; + emit startCheck(details); + cppcheck.check(*file); runAddonsAndTools(mSettings, nullptr, QString::fromStdString(fname)); - emit fileChecked(QString::fromStdString(fname)); + + emit finishCheck(details); if (mState == Running) mResult.getNextFile(file); @@ -160,9 +166,15 @@ void CheckThread::run() while (fileSettings && mState == Running) { const std::string& fname = fileSettings->filename(); qDebug() << "Checking file" << QString::fromStdString(fname); - cppcheck.check(*fileSettings); + + const Details details{ mThreadIndex, QString::fromStdString(fname), QTime::currentTime(), }; + emit startCheck(details); + + cppcheck.check(*file); runAddonsAndTools(mSettings, fileSettings, QString::fromStdString(fname)); - emit fileChecked(QString::fromStdString(fname)); + + emit finishCheck(details); + if (mState == Running) mResult.getNextFileSettings(fileSettings); @@ -486,3 +498,4 @@ QString CheckThread::clangTidyCmd() return QString(); } + diff --git a/gui/checkthread.h b/gui/checkthread.h index 4247a45094c..e78f1580440 100644 --- a/gui/checkthread.h +++ b/gui/checkthread.h @@ -36,6 +36,7 @@ #include #include #include +#include class ThreadResult; @@ -49,7 +50,14 @@ class ThreadResult; class CheckThread : public QThread { Q_OBJECT public: - explicit CheckThread(ThreadResult &result); + struct Details { + int threadIndex; + QString file; + QTime startTime; + }; + +public: + CheckThread(ThreadResult &result, int threadIndex); /** * @brief Set settings for cppcheck @@ -102,8 +110,8 @@ class CheckThread : public QThread { */ void done(); - // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code - void fileChecked(const QString &file); + void startCheck(CheckThread::Details details); + void finishCheck(CheckThread::Details details); protected: /** @@ -126,6 +134,7 @@ class CheckThread : public QThread { std::atomic mState{Ready}; ThreadResult &mResult; + int mThreadIndex{}; Settings mSettings; std::shared_ptr mSuppressions; @@ -150,5 +159,6 @@ class CheckThread : public QThread { QStringList mClangIncludePaths; QList mSuppressionsUi; }; +Q_DECLARE_METATYPE(CheckThread::Details); /// @} #endif // CHECKTHREAD_H diff --git a/gui/gui.pro b/gui/gui.pro index 132f113d270..8706e86c86e 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -70,7 +70,8 @@ FORMS = about.ui \ librarydialog.ui \ libraryaddfunctiondialog.ui \ libraryeditargdialog.ui \ - newsuppressiondialog.ui + newsuppressiondialog.ui \ + threaddetails.ui TRANSLATIONS = cppcheck_de.ts \ cppcheck_es.ts \ @@ -156,6 +157,7 @@ HEADERS += aboutdialog.h \ settingsdialog.h \ showtypes.h \ statsdialog.h \ + threaddetails.h \ threadhandler.h \ threadresult.h \ translationhandler.h \ @@ -199,6 +201,7 @@ SOURCES += aboutdialog.cpp \ settingsdialog.cpp \ showtypes.cpp \ statsdialog.cpp \ + threaddetails.cpp \ threadhandler.cpp \ threadresult.cpp \ translationhandler.cpp \ diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 6d0a1a8d5ce..c0d42a32d0d 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -53,6 +53,7 @@ #include "threadresult.h" #include "translationhandler.h" #include "utils.h" +#include "threaddetails.h" #include "ui_mainwindow.h" @@ -183,6 +184,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : connect(mUI->mActionShowHidden, &QAction::triggered, mUI->mResults, &ResultsView::showHiddenResults); connect(mUI->mActionViewStats, &QAction::triggered, this, &MainWindow::showStatistics); connect(mUI->mActionLibraryEditor, &QAction::triggered, this, &MainWindow::showLibraryEditor); + connect(mUI->mActionShowThreadDetails, &QAction::triggered, this, &MainWindow::showThreadDetails); connect(mUI->mActionReanalyzeModified, &QAction::triggered, this, &MainWindow::reAnalyzeModified); connect(mUI->mActionReanalyzeAll, &QAction::triggered, this, &MainWindow::reAnalyzeAll); @@ -1069,6 +1071,7 @@ bool MainWindow::getCppcheckSettings(Settings& settings, Suppressions& supprs) settings.exename = QCoreApplication::applicationFilePath().toStdString(); settings.templateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]"; + settings.reportProgress = 10; // default to --check-level=normal for GUI for now settings.setCheckLevel(Settings::CheckLevel::normal); @@ -2109,6 +2112,20 @@ void MainWindow::showLibraryEditor() libraryDialog.exec(); } +void MainWindow::showThreadDetails() +{ + if (ThreadDetails::instance()) + return; + auto* threadDetails = new ThreadDetails(this); + connect(mThread, &ThreadHandler::threadDetailsUpdated, + threadDetails, &ThreadDetails::threadDetailsUpdated, Qt::QueuedConnection); + connect(mThread, &ThreadHandler::progress, + threadDetails, &ThreadDetails::progress, Qt::QueuedConnection); + threadDetails->setAttribute(Qt::WA_DeleteOnClose); + threadDetails->show(); + mThread->emitThreadDetailsUpdated(); +} + void MainWindow::filterResults() { mUI->mResults->filterResults(mLineEditFilter->text()); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 76fda4f0de6..e29d4d48f5b 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -200,6 +200,9 @@ public slots: /** @brief Slot for showing the library editor */ void showLibraryEditor(); + /** @brief Slot for showing the thread details window */ + void showThreadDetails(); + private slots: /** @brief Slot for checkthread's done signal */ diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index a90949344e2..551874d3225 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -64,7 +64,7 @@ - QLayout::SetDefaultConstraint + QLayout::SizeConstraint::SetDefaultConstraint @@ -84,13 +84,13 @@ Checking for updates - Qt::RichText + Qt::TextFormat::RichText true - Qt::TextBrowserInteraction + Qt::TextInteractionFlag::TextBrowserInteraction @@ -104,7 +104,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -124,7 +124,7 @@ 0 0 640 - 22 + 21 @@ -192,6 +192,7 @@ + @@ -1040,6 +1041,14 @@ EULA... + + + Thread Details + + + Show thread details + + diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 8336a697878..b8ff3d8c598 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -162,7 +162,7 @@ void ResultsView::setResultsSource(ResultsTree::ResultsSource source) mUI->mTree->setResultsSource(source); } -void ResultsView::progress(int value, const QString& description) +void ResultsView::filesCheckedProgress(int value, const QString& description) { mUI->mProgress->setValue(value); mUI->mProgress->setFormat(QString("%p% (%1)").arg(description)); diff --git a/gui/resultsview.h b/gui/resultsview.h index 770f9c0c3fa..500d40df981 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -307,7 +307,7 @@ public slots: * @param value Current progress value * @param description Description to accompany the progress */ - void progress(int value, const QString& description); + void filesCheckedProgress(int value, const QString& description); /** * @brief Slot for new error to be displayed diff --git a/gui/test/resultstree/testresultstree.cpp b/gui/test/resultstree/testresultstree.cpp index 732ee0715d0..afda38e0075 100644 --- a/gui/test/resultstree/testresultstree.cpp +++ b/gui/test/resultstree/testresultstree.cpp @@ -93,6 +93,14 @@ void ThreadHandler::stop() { void ThreadHandler::threadDone() { throw 1; } +// NOLINTBEGIN(performance-unnecessary-value-param) +void ThreadHandler::startCheck(CheckThread::Details /*unused*/) { + throw 1; +} +void ThreadHandler::finishCheck(CheckThread::Details /*unused*/) { + throw 1; +} +// NOLINTEND(performance-unnecessary-value-param) Application& ApplicationList::getApplication(const int /*unused*/) { throw 1; } @@ -106,7 +114,8 @@ QString XmlReport::unquoteMessage(const QString &message) { return message; } XmlReport::XmlReport(const QString& filename) : Report(filename) {} -void ThreadResult::fileChecked(const QString & /*unused*/) { +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void ThreadResult::finishCheck(CheckThread::Details /*unused*/) { throw 1; } void ThreadResult::reportOut(const std::string & /*unused*/, Color /*unused*/) { @@ -115,6 +124,9 @@ void ThreadResult::reportOut(const std::string & /*unused*/, Color /*unused*/) { void ThreadResult::reportErr(const ErrorMessage & /*unused*/) { throw 1; } +void ThreadResult::reportProgress(const std::string &/*filename*/, const char /*stage*/[], const std::size_t /*value*/) { + throw 1; +} // Test... diff --git a/gui/threaddetails.cpp b/gui/threaddetails.cpp new file mode 100644 index 00000000000..9036c18305d --- /dev/null +++ b/gui/threaddetails.cpp @@ -0,0 +1,54 @@ +#include "threaddetails.h" +#include "ui_threaddetails.h" + +#include + +ThreadDetails* ThreadDetails::mInstance; + +ThreadDetails::ThreadDetails(QWidget *parent) + : QWidget(parent) + , mUi(new Ui::ThreadDetails) +{ + mInstance = this; + setWindowFlags(Qt::Window); + mUi->setupUi(this); + connect(&mTimer, &QTimer::timeout, this, &ThreadDetails::updateUI); + mTimer.start(1000); +} + +ThreadDetails::~ThreadDetails() +{ + mInstance = nullptr; + delete mUi; +} + +// NOLINTNEXTLINE(performance-unnecessary-value-param) - false positive +void ThreadDetails::threadDetailsUpdated(QMap threadDetails) +{ + QMutexLocker locker(&mMutex); + mThreadDetails = threadDetails; + if (threadDetails.empty()) { + mProgress.clear(); + } +} + +// cppcheck-suppress passedByValue +// NOLINTNEXTLINE(performance-unnecessary-value-param) - false positive +void ThreadDetails::progress(QString filename, QString stage, std::size_t value) { + QMutexLocker locker(&mMutex); + mProgress[filename] = {QString(), stage + QString(value > 0 ? ": %1%" : "").arg(value)}; +} + +void ThreadDetails::updateUI() { + QString text("Thread\tStart time\tFile/Progress\n"); + { + QMutexLocker locker(&mMutex); + for (const auto& td: mThreadDetails) { + auto& timeProgress = mProgress[td.file]; + if (timeProgress.first.isEmpty() && !timeProgress.second.isEmpty()) + timeProgress.first = QTime::currentTime().toString(Qt::TextDate); + text += QString("%1\t%2\t%3\n\t%4\t%5\n").arg(td.threadIndex).arg(td.startTime.toString(Qt::TextDate)).arg(td.file).arg(timeProgress.first).arg(timeProgress.second); + } + } + mUi->plainTextEdit->setPlainText(text); +} diff --git a/gui/threaddetails.h b/gui/threaddetails.h new file mode 100644 index 00000000000..253b53d5407 --- /dev/null +++ b/gui/threaddetails.h @@ -0,0 +1,44 @@ +#ifndef THREADDETAILS_H +#define THREADDETAILS_H + +#include +#include +#include +#include +#include "checkthread.h" + +namespace Ui { + class ThreadDetails; +} + +class ThreadDetails : public QWidget +{ + Q_OBJECT + +public: + explicit ThreadDetails(QWidget *parent = nullptr); + ~ThreadDetails() override; + + static ThreadDetails* instance() { + return mInstance; + } + +public slots: + void threadDetailsUpdated(QMap threadDetails); + void progress(QString filename, QString stage, std::size_t value); + +private slots: + void updateUI(); + +private: + static ThreadDetails* mInstance; + Ui::ThreadDetails *mUi; + QMap> mProgress; + QMap mThreadDetails; + QTimer mTimer; + + /** accessing mProgress and mThreadDetails in slots that are triggered from different threads */ + QMutex mMutex; +}; + +#endif // THREADDETAILS_H diff --git a/gui/threaddetails.ui b/gui/threaddetails.ui new file mode 100644 index 00000000000..420340cf77d --- /dev/null +++ b/gui/threaddetails.ui @@ -0,0 +1,28 @@ + + + ThreadDetails + + + + 0 + 0 + 640 + 300 + + + + Thread Details + + + + + + true + + + + + + + + diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index ad4d0e2a61d..55f60de673d 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -146,11 +146,15 @@ void ThreadHandler::createThreads(const int count) removeThreads(); //Create new threads for (int i = mThreads.size(); i < count; i++) { - mThreads << new CheckThread(mResults); + mThreads << new CheckThread(mResults, i + 1); connect(mThreads.last(), &CheckThread::done, this, &ThreadHandler::threadDone, Qt::QueuedConnection); - connect(mThreads.last(), &CheckThread::fileChecked, - &mResults, &ThreadResult::fileChecked, Qt::QueuedConnection); + connect(mThreads.last(), &CheckThread::finishCheck, + &mResults, &ThreadResult::finishCheck, Qt::QueuedConnection); + connect(mThreads.last(), &CheckThread::startCheck, + this, &ThreadHandler::startCheck, Qt::QueuedConnection); + connect(mThreads.last(), &CheckThread::finishCheck, + this, &ThreadHandler::finishCheck, Qt::QueuedConnection); } } @@ -164,8 +168,12 @@ void ThreadHandler::removeThreads() } disconnect(thread, &CheckThread::done, this, &ThreadHandler::threadDone); - disconnect(thread, &CheckThread::fileChecked, - &mResults, &ThreadResult::fileChecked); + disconnect(thread, &CheckThread::finishCheck, + &mResults, &ThreadResult::finishCheck); + disconnect(mThreads.last(), &CheckThread::startCheck, + this, &ThreadHandler::startCheck); + disconnect(mThreads.last(), &CheckThread::finishCheck, + this, &ThreadHandler::finishCheck); delete thread; } @@ -215,8 +223,8 @@ void ThreadHandler::stop() void ThreadHandler::initialize(const ResultsView *view) { - connect(&mResults, &ThreadResult::progress, - view, &ResultsView::progress); + connect(&mResults, &ThreadResult::filesCheckedProgress, + view, &ResultsView::filesCheckedProgress); connect(&mResults, &ThreadResult::error, view, &ResultsView::error); @@ -226,6 +234,9 @@ void ThreadHandler::initialize(const ResultsView *view) connect(&mResults, &ThreadResult::debugError, this, &ThreadHandler::debugError); + + connect(&mResults, &ThreadResult::progress, + this, &ThreadHandler::progress); } void ThreadHandler::loadSettings(const QSettings &settings) @@ -317,3 +328,24 @@ void ThreadHandler::setCheckStartTime(QDateTime checkStartTime) { mCheckStartTime = std::move(checkStartTime); } + +// cppcheck-suppress passedByValueCallback +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void ThreadHandler::startCheck(CheckThread::Details details) +{ + mThreadDetails[details.threadIndex] = details; + emitThreadDetailsUpdated(); +} + +// cppcheck-suppress passedByValueCallback +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void ThreadHandler::finishCheck(CheckThread::Details details) +{ + mThreadDetails.remove(details.threadIndex); + emitThreadDetailsUpdated(); +} + +void ThreadHandler::emitThreadDetailsUpdated() +{ + emit threadDetailsUpdated(mThreadDetails); +} diff --git a/gui/threadhandler.h b/gui/threadhandler.h index cc578bd5643..9f3d01f17e6 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -178,6 +178,11 @@ class ThreadHandler : public QObject { */ void setCheckStartTime(QDateTime checkStartTime); + /** + * @brief Emit the threadDetailsUpdated signal + */ + void emitThreadDetailsUpdated(); + signals: /** * @brief Signal that all threads are done @@ -191,6 +196,11 @@ class ThreadHandler : public QObject { // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code void debugError(const ErrorItem &item); + /** + * @brief Emitted when thread details are updated. + */ + void threadDetailsUpdated(QMap threadDetails); + public slots: /** @@ -198,6 +208,22 @@ public slots: * */ void stop(); + + /** + * @brief Slot threads use to signal this class that it started checking a file + * @param details Details about what file is being checked and by what thread + */ + void startCheck(CheckThread::Details details); + + /** + * @brief Slot threads use to signal this class that it finish checking a file + * @param details Details about what file finished being checked and by what thread + */ + void finishCheck(CheckThread::Details details); + +signals: + void progress(QString filename, QString stage, std::size_t value); + protected slots: /** * @brief Slot that a single thread is done @@ -285,6 +311,12 @@ protected slots: Settings mCheckSettings; std::shared_ptr mCheckSuppressions; /// @} + + /** + * @brief Details about currently running threads + */ + QMap mThreadDetails; + private: /** diff --git a/gui/threadresult.cpp b/gui/threadresult.cpp index ea858c92e4a..f3a7e67ab16 100644 --- a/gui/threadresult.cpp +++ b/gui/threadresult.cpp @@ -34,18 +34,19 @@ void ThreadResult::reportOut(const std::string &outmsg, Color /*c*/) emit log(QString::fromStdString(outmsg)); } -void ThreadResult::fileChecked(const QString &file) +// NOLINTNEXTLINE(performance-unnecessary-value-param) +void ThreadResult::finishCheck(CheckThread::Details details) { std::lock_guard locker(mutex); - mProgress += QFile(file).size(); + mCheckedFileSize += QFile(details.file).size(); mFilesChecked++; - if (mMaxProgress > 0) { - const int value = static_cast(PROGRESS_MAX * mProgress / mMaxProgress); + if (mTotalFileSize > 0) { + const int value = static_cast(PROGRESS_MAX * mCheckedFileSize / mTotalFileSize); const QString description = tr("%1 of %2 files checked").arg(mFilesChecked).arg(mTotalFiles); - emit progress(value, description); + emit filesCheckedProgress(value, description); } } @@ -59,6 +60,11 @@ void ThreadResult::reportErr(const ErrorMessage &msg) emit debugError(item); } +// NOLINTNEXTLINE(readability-avoid-const-params-in-decls) - false positive this is an overload +void ThreadResult::reportProgress(const std::string &filename, const char stage[], const std::size_t value) { + emit progress(QString::fromStdString(filename), stage, value); +} + void ThreadResult::getNextFile(const FileWithDetails*& file) { std::lock_guard locker(mutex); @@ -87,7 +93,7 @@ void ThreadResult::setFiles(std::list files) mTotalFiles = files.size(); mFiles = std::move(files); mItNextFile = mFiles.cbegin(); - mProgress = 0; + mCheckedFileSize = 0; mFilesChecked = 0; // Determine the total size of all of the files to check, so that we can @@ -95,7 +101,7 @@ void ThreadResult::setFiles(std::list files) quint64 sizeOfFiles = std::accumulate(mFiles.cbegin(), mFiles.cend(), 0, [](quint64 total, const FileWithDetails& file) { return total + file.size(); }); - mMaxProgress = sizeOfFiles; + mTotalFileSize = sizeOfFiles; } void ThreadResult::setProject(const ImportProject &prj) @@ -105,13 +111,13 @@ void ThreadResult::setProject(const ImportProject &prj) mItNextFile = mFiles.cbegin(); mFileSettings = prj.fileSettings; mItNextFileSettings = mFileSettings.cbegin(); - mProgress = 0; + mCheckedFileSize = 0; mFilesChecked = 0; mTotalFiles = prj.fileSettings.size(); // Determine the total size of all of the files to check, so that we can // show an accurate progress estimate - mMaxProgress = std::accumulate(prj.fileSettings.begin(), prj.fileSettings.end(), quint64{ 0 }, [](quint64 v, const FileSettings& fs) { + mTotalFileSize = std::accumulate(prj.fileSettings.begin(), prj.fileSettings.end(), quint64{ 0 }, [](quint64 v, const FileSettings& fs) { return v + QFile(QString::fromStdString(fs.filename())).size(); }); } diff --git a/gui/threadresult.h b/gui/threadresult.h index dc7b5c0372a..b7bece3e28c 100644 --- a/gui/threadresult.h +++ b/gui/threadresult.h @@ -23,6 +23,7 @@ #include "color.h" #include "errorlogger.h" #include "filesettings.h" +#include "checkthread.h" #include #include @@ -83,22 +84,25 @@ class ThreadResult : public QObject, public ErrorLogger { { (void) metric; } + // NOLINTNEXTLINE(readability-avoid-const-params-in-decls) - false positive this is an overload + void reportProgress(const std::string &filename, const char stage[], const std::size_t value) final; public slots: /** - * @brief Slot threads use to signal this class that a specific file is checked - * @param file File that is checked + * @brief Slot threads use to signal this class that it finish checking a file + * @param details Details about what file finished being checked and by what thread */ - void fileChecked(const QString &file); + void finishCheck(CheckThread::Details details); + signals: /** - * @brief Progress signal - * @param value Current progress - * @param description Description of the current stage + * @brief Files checked progress + * @param value Current progress (0 - PROGRESS_MAX) + * @param description Description of the current stage (example: "13/45 files checked") */ // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code - void progress(int value, const QString& description); + void filesCheckedProgress(int value, const QString& description); /** * @brief Signal of a new error @@ -124,6 +128,8 @@ public slots: // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code void debugError(const ErrorItem &item); + void progress(QString filename, QString stage, std::size_t value); + protected: /** @@ -142,17 +148,11 @@ public slots: std::list mFileSettings; std::list::const_iterator mItNextFileSettings{mFileSettings.cbegin()}; - /** - * @brief Max progress - * - */ - quint64 mMaxProgress{}; + /** @brief Total file size */ + quint64 mTotalFileSize{}; - /** - * @brief Current progress - * - */ - quint64 mProgress{}; + /** @brief File size of checked files */ + quint64 mCheckedFileSize{}; /** * @brief Current number of files checked From b021c4f23c9bc7dabfadc9a0b81eea5d5f9fd5a7 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 20 Feb 2026 08:24:12 +0100 Subject: [PATCH 153/675] Fix #14497 FN variableScope (else branch, regression) (#8227) --- lib/checkother.cpp | 2 +- lib/tokenize.cpp | 4 ++-- test/testother.cpp | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 4aaa887d7f0..cf5ecb65b91 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1292,7 +1292,7 @@ void CheckOther::checkVariableScope() tok = tok->link(); // parse else if blocks.. - } else if (Token::simpleMatch(tok, "else { if (") && Token::simpleMatch(tok->linkAt(3), ") {")) { + } else if (Token::simpleMatch(tok, "else { if (") && tok->next()->isSimplifiedScope() && Token::simpleMatch(tok->linkAt(3), ") {")) { tok = tok->next(); } else if (tok->varId() == var->declarationId() || tok->str() == "goto") { reduce = false; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d0e46b54542..bb3957fb9ae 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7964,8 +7964,8 @@ void Tokenizer::elseif() if (Token::Match(tok2, "}|;")) { if (tok2->next() && tok2->strAt(1) != "else") { - tok->insertToken("{"); - tok2->insertToken("}"); + tok->insertToken("{")->isSimplifiedScope(true); + tok2->insertToken("}")->isSimplifiedScope(true); Token::createMutualLinks(tok->next(), tok2->next()); break; } diff --git a/test/testother.cpp b/test/testother.cpp index 0ccd482c353..06512a930c9 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -122,6 +122,7 @@ class TestOther : public TestFixture { TEST_CASE(varScope42); TEST_CASE(varScope43); TEST_CASE(varScope44); + TEST_CASE(varScope45); TEST_CASE(oldStylePointerCast); TEST_CASE(intToPointerCast); @@ -1972,6 +1973,17 @@ class TestOther : public TestFixture { errout_str()); } + void varScope45() { + check("void g(int x, int y) {\n" // #14497 + " int a = x, b = y;\n" + " if (a) {}\n" + " else {\n" + " if (b) {}\n" + " }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:16]: (style) The scope of the variable 'b' can be reduced. [variableScope]\n", errout_str()); + } + #define checkOldStylePointerCast(...) checkOldStylePointerCast_(__FILE__, __LINE__, __VA_ARGS__) template void checkOldStylePointerCast_(const char* file, int line, const char (&code)[size], Standards::cppstd_t std = Standards::CPPLatest) { From 0a3f445513de3f9f6df47e89b327fa0f31eadeff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 20 Feb 2026 11:14:26 +0100 Subject: [PATCH 154/675] fixed #14506 - `arrayIndexThenCheck` had the wrong severity check (#8229) --- lib/checkbufferoverrun.cpp | 4 +-- test/testbufferoverrun.cpp | 55 +++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index b052fd52b51..1b3e8bfbef9 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -706,10 +706,10 @@ void CheckBufferOverrun::bufferOverflowError(const Token *tok, const ValueFlow:: void CheckBufferOverrun::arrayIndexThenCheck() { - if (!mSettings->severity.isEnabled(Severity::portability)) + if (!mSettings->severity.isEnabled(Severity::style)) return; - logChecker("CheckBufferOverrun::arrayIndexThenCheck"); + logChecker("CheckBufferOverrun::arrayIndexThenCheck"); // style const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase(); for (const Scope * const scope : symbolDatabase->functionScopes) { diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 2f2027c13af..91118c3dab5 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -35,8 +35,9 @@ class TestBufferOverrun : public TestFixture { TestBufferOverrun() : TestFixture("TestBufferOverrun") {} private: - /*const*/ Settings settings0 = settingsBuilder().library("std.cfg").severity(Severity::warning).severity(Severity::style).severity(Severity::portability).build(); + /*const*/ Settings settings0 = settingsBuilder().library("std.cfg").severity(Severity::warning).severity(Severity::style).build(); const Settings settings0_i = settingsBuilder(settings0).certainty(Certainty::inconclusive).build(); + const Settings settings0_p = settingsBuilder(settings0).severity(Severity::portability).build(); const Settings settings1 = settingsBuilder(settings0).severity(Severity::performance).certainty(Certainty::inconclusive).build(); struct CheckOptions @@ -3789,40 +3790,40 @@ class TestBufferOverrun : public TestFixture { check("void f() {\n" " char a[10];\n" " char *p = a + 100;\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:3:17]: (portability) Undefined behaviour, pointer arithmetic 'a+100' is out of bounds. [pointerOutOfBounds]\n", errout_str()); check("char *f() {\n" " char a[10];\n" " return a + 100;\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:3:14]: (portability) Undefined behaviour, pointer arithmetic 'a+100' is out of bounds. [pointerOutOfBounds]\n", errout_str()); check("void f(int i) {\n" " char x[10];\n" " if (i == 123) {}\n" " dostuff(x+i);\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:3:11] -> [test.cpp:4:14]: (portability) Undefined behaviour, when 'i' is 123 the pointer arithmetic 'x+i' is out of bounds. [pointerOutOfBoundsCond]\n", errout_str()); check("void f(int i) {\n" " char x[10];\n" " if (i == -1) {}\n" " dostuff(x+i);\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:3:11] -> [test.cpp:4:14]: (portability) Undefined behaviour, when 'i' is -1 the pointer arithmetic 'x+i' is out of bounds. [pointerOutOfBoundsCond]\n", errout_str()); check("void f() {\n" // #6350 - fp when there is cast of buffer " wchar_t buf[64];\n" " p = (unsigned char *) buf + sizeof (buf);\n" - "}", dinit(CheckOptions, $.cpp = false)); + "}", settings0_p, false); ASSERT_EQUALS("", errout_str()); check("int f() {\n" " const char d[] = \"0123456789\";\n" " char *cp = d + 3;\n" " return cp - d;\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("", errout_str()); } @@ -3831,7 +3832,7 @@ class TestBufferOverrun : public TestFixture { " char *p = malloc(10);\n" " p += 100;\n" " free(p);" - "}"); + "}", settings0_p); TODO_ASSERT_EQUALS("[test.cpp:3]: (portability) Undefined behaviour, pointer arithmetic 'p+100' is out of bounds.\n", "", errout_str()); check("void f() {\n" @@ -3839,7 +3840,7 @@ class TestBufferOverrun : public TestFixture { " p += 10;\n" " *p = 0;\n" " free(p);" - "}"); + "}", settings0_p); TODO_ASSERT_EQUALS("[test.cpp:4]: (error) p is out of bounds.\n", "", errout_str()); check("void f() {\n" @@ -3848,7 +3849,7 @@ class TestBufferOverrun : public TestFixture { " p -= 10;\n" " *p = 0;\n" " free(p);" - "}"); + "}", settings0_p); ASSERT_EQUALS("", errout_str()); check("void f() {\n" @@ -3857,7 +3858,7 @@ class TestBufferOverrun : public TestFixture { " p = p - 1;\n" " *p = 0;\n" " free(p);" - "}"); + "}", settings0_p); ASSERT_EQUALS("", errout_str()); } @@ -3865,7 +3866,7 @@ class TestBufferOverrun : public TestFixture { check("struct S { int a[10]; };\n" "void f(struct S *s) {\n" " int *p = s->a + 100;\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:3:19]: (portability) Undefined behaviour, pointer arithmetic 's->a+100' is out of bounds. [pointerOutOfBounds]\n", errout_str()); check("template class Vector\n" @@ -3881,36 +3882,36 @@ class TestBufferOverrun : public TestFixture { " const T* P2 = PDat + 1;\n" " const T* P1 = P2 - 1;\n" "}\n" - "Vector> Foo;\n"); + "Vector> Foo;\n", settings0_p); ASSERT_EQUALS("", errout_str()); } void pointer_out_of_bounds_4() { check("const char* f() {\n" " g(\"Hello\" + 6);\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("", errout_str()); check("const char* f() {\n" " g(\"Hello\" + 7);\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:2:15]: (portability) Undefined behaviour, pointer arithmetic '\"Hello\"+7' is out of bounds. [pointerOutOfBounds]\n", errout_str()); check("const char16_t* f() {\n" " g(u\"Hello\" + 6);\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("", errout_str()); check("const char16_t* f() {\n" " g(u\"Hello\" + 7);\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:2:16]: (portability) Undefined behaviour, pointer arithmetic 'u\"Hello\"+7' is out of bounds. [pointerOutOfBounds]\n", errout_str()); check("void f() {\n" // #4647 " int val = 5;\n" " std::string hi = \"hi\" + val;\n" " std::cout << hi << std::endl;\n" - "}\n"); + "}\n", settings0_p); ASSERT_EQUALS("[test.cpp:3:27]: (portability) Undefined behaviour, pointer arithmetic '\"hi\"+val' is out of bounds. [pointerOutOfBounds]\n", errout_str()); check("void f(const char* s, int len) {\n" // #11026 @@ -3920,7 +3921,7 @@ class TestBufferOverrun : public TestFixture { "void g() {\n" " f(\"a\", 1);\n" " f(\"bbb\", 3);\n" - "}\n"); + "}\n", settings0_p); ASSERT_EQUALS("", errout_str()); check("void f(int i, const char* a) {\n" // #11140 @@ -3933,14 +3934,14 @@ class TestBufferOverrun : public TestFixture { "void h() {\n" " for (int i = 0; \"012\"[i]; ++i)\n" " f(i, \"345\");\n" - "}\n"); + "}\n", settings0_p); ASSERT_EQUALS("", errout_str()); } void pointer_out_of_bounds_5() { // #10227 check("int foo(char str[6]) {\n" " return !((0 && *(\"STRING\" + 14) == 0) || memcmp(str, \"STRING\", 6) == 0);\n" - "}\n"); + "}\n", settings0_p); ASSERT_EQUALS("", errout_str()); } @@ -3950,26 +3951,26 @@ class TestBufferOverrun : public TestFixture { check("char *f() {\n" " char x[10];\n" " return x-1;\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:3:13]: (portability) Undefined behaviour, pointer arithmetic 'x-1' is out of bounds. [pointerOutOfBounds]\n", errout_str()); check("void f(int i) {\n" " char x[10];\n" " if (i == 123) {}\n" " dostuff(x-i);\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:3:11] -> [test.cpp:4:14]: (portability) Undefined behaviour, when 'i' is 123 the pointer arithmetic 'x-i' is out of bounds. [pointerOutOfBoundsCond]\n", errout_str()); check("void f(int i) {\n" " char x[10];\n" " if (i == -20) {}\n" " dostuff(x-i);\n" - "}"); + "}", settings0_p); TODO_ASSERT_EQUALS("[test.cpp:4]: (portability) Undefined behaviour, when 'i' is -20 the pointer arithmetic 'x-i' is out of bounds.\n", "", errout_str()); check("void f(const char *x[10]) {\n" " return x-4;\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("", errout_str()); } @@ -5296,14 +5297,14 @@ class TestBufferOverrun : public TestFixture { check("void f() {\n" " char arr[10];\n" " char *p = arr + 20;\n" - "}"); + "}", settings0_p); ASSERT_EQUALS("[test.cpp:3:19]: (portability) Undefined behaviour, pointer arithmetic 'arr+20' is out of bounds. [pointerOutOfBounds]\n", errout_str()); check("char(*g())[1];\n" // #7950 "void f() {\n" " int a[2];\n" " int* b = a + sizeof(*g());\n" - "}\n"); + "}\n", settings0_p); ASSERT_EQUALS("", errout_str()); } From 62ebc009688b911d89a2d1d6190c77c87b83eec1 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 21 Feb 2026 10:08:13 +0100 Subject: [PATCH 155/675] Fix #12944 FP uninitvar reported in lambda (#8237) --- lib/valueflow.cpp | 7 +++++-- test/testuninitvar.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ec90fb3e302..94dde440368 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5958,9 +5958,12 @@ static Token* findStartToken(const Variable* var, Token* start, const Library& l })) return first->previous(); // Compute the outer scope - while (scope && scope->nestedIn != var->scope()) + while (scope && scope->nestedIn != var->scope()) { + if (scope->type == ScopeType::eLambda && !Token::simpleMatch(scope->bodyEnd, "} (")) + return start; scope = scope->nestedIn; - if (!scope) + } + if (!scope || (scope->type == ScopeType::eLambda && !Token::simpleMatch(scope->bodyEnd, "} ("))) return start; auto* tok = const_cast(scope->bodyStart); if (!tok) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 15467db7971..ad9dee0fcac 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -6663,6 +6663,26 @@ class TestUninitVar : public TestFixture { " return ret;\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + valueFlowUninit("int f() {\n" // #12944 + " int i;\n" + " auto x = [&]() { return i; };\n" + " i = 5;\n" + " return x();\n" + "}\n" + "int g() {\n" + " int i;\n" + " {\n" + " auto x = [&]() { return i; };\n" + " i = 5;\n" + " return x();\n" + " }\n" + "}\n" + "int h() {\n" + " int j;\n" + " return [&]() { return j; }();\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:17:27]: (error) Uninitialized variable: j [uninitvar]\n", errout_str()); } void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value From 0007ba8b23b1eb769902d08776d7c78475b80e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 21 Feb 2026 12:57:10 +0100 Subject: [PATCH 156/675] fixed #14383 - clear `PATH` in selfchecks and explicitly provide executable locations (#8239) --- selfcheck.sh | 26 +++++++++++++++++--------- selfcheck_san.sh | 16 ++++++++-------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/selfcheck.sh b/selfcheck.sh index 6a1755e337b..7f919334c18 100755 --- a/selfcheck.sh +++ b/selfcheck.sh @@ -3,29 +3,37 @@ selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude,information --exception-handling --debug-warnings --check-level=exhaustive" cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" gui_options="-DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt" -ec=0 +naming_options="--addon-python=$(command -v python) --addon=naming.json" if [ -n "$1" ]; then selfcheck_options="$selfcheck_options $1" fi +mkdir_cmd=$(command -v mkdir) +rm_cmd=$(command -v rm) + +# clear PATH to prevent unintentional process invocations +export PATH= + +ec=0 + # self check externals ./cppcheck $selfcheck_options externals || ec=1 # self check lib/cli -mkdir b1 -./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json frontend || ec=1 -./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json -Ifrontend cli || ec=1 -./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json --enable=internal lib || ec=1 +$mkdir_cmd b1 +./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 $naming_options frontend || ec=1 +./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 $naming_options -Ifrontend cli || ec=1 +./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 $naming_options --enable=internal lib || ec=1 # check gui with qt settings -mkdir b2 -./cppcheck $selfcheck_options $cppcheck_options $gui_options --cppcheck-build-dir=b2 --addon=naming.json -Icmake.output/gui -Ifrontend -Igui gui/*.cpp cmake.output/gui || ec=1 +$mkdir_cmd b2 +./cppcheck $selfcheck_options $cppcheck_options $gui_options --cppcheck-build-dir=b2 $naming_options -Icmake.output/gui -Ifrontend -Igui gui/*.cpp cmake.output/gui || ec=1 # self check test and tools ./cppcheck $selfcheck_options $cppcheck_options -Ifrontend -Icli test/*.cpp || ec=1 ./cppcheck $selfcheck_options $cppcheck_options -Icli tools/dmake/*.cpp || ec=1 # triage ./cppcheck $selfcheck_options $cppcheck_options $gui_options -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage || ec=1 -rm -rf b2 -rm -rf b1 +$rm_cmd -rf b2 +$rm_cmd -rf b1 exit $ec \ No newline at end of file diff --git a/selfcheck_san.sh b/selfcheck_san.sh index f300d8be2df..5c8fef353c2 100755 --- a/selfcheck_san.sh +++ b/selfcheck_san.sh @@ -8,6 +8,10 @@ selfcheck_options="$selfcheck_options $selfcheck_options_extra" cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" qt_options="--library=qt -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_MOC_HAS_STRINGDATA" qt_options="$qt_options --suppress=autoNoType:*/moc_*.cpp --suppress=symbolDatabaseWarning:*/moc_*.cpp" +naming_options="--addon-python=$(command -v python) --addon=naming.json" + +# clear PATH to prevent unintentional process invocations +export PATH= ec=0 @@ -15,25 +19,21 @@ $cmake_output/bin/cppcheck $selfcheck_options \ externals \ || ec=1 -$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options \ - --addon=naming.json \ +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options $naming_options \ frontend \ || ec=1 -$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options \ - --addon=naming.json \ +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options $naming_options \ -Ifrontend \ cli \ || ec=1 -$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options \ - --addon=naming.json \ +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options $naming_options \ --enable=internal \ lib \ || ec=1 -$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options $qt_options \ - --addon=naming.json \ +$cmake_output/bin/cppcheck $selfcheck_options $cppcheck_options $naming_options $qt_options \ --suppress=constVariablePointer:*/moc_*.cpp \ -DQT_CHARTS_LIB \ -I$cmake_output/gui -Ifrontend -Igui \ From b8e93951d5bf2ef378cf819b129c4b87e81c757a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 21 Feb 2026 12:59:10 +0100 Subject: [PATCH 157/675] tools/check-errorids.sh: match errors ID in output which are not followed by a newline (#8238) fixes e.g. `UnionZeroInit` shown as having no test coverage --- tools/check-errorids.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check-errorids.sh b/tools/check-errorids.sh index ffef62fea42..8bd343411cc 100755 --- a/tools/check-errorids.sh +++ b/tools/check-errorids.sh @@ -23,7 +23,7 @@ echo '' echo 'no test coverage:' $SCRIPT_DIR/../cppcheck --errorlist | grep -h -o -P 'id=\"[a-zA-Z0-9_]*\"' | sed 's/\id=//' | tr -d '\"' | sort -u | \ while read -r id; do - grep -h -o -P "\[$id\]\\\\n\"" $SCRIPT_DIR/../test/*.cpp > /dev/null + grep -h -o -P "\[$id\][\\\\n]*\"" $SCRIPT_DIR/../test/*.cpp > /dev/null # shellcheck disable=SC2181 if [ $? -ne 0 ]; then echo $id From a5db405d702b2e51572dcaae36bc8d9a3e955ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Sat, 21 Feb 2026 15:19:29 +0100 Subject: [PATCH 158/675] Fix #14483: false negative: unusedStructMember (member pointer) (#8228) --- lib/symboldatabase.cpp | 20 ++++++++++++++++++++ test/testother.cpp | 2 +- test/testunusedvar.cpp | 16 ++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f5ffa4e1604..f1c2ee0a14a 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5266,6 +5266,26 @@ const Variable *Scope::getVariable(const std::string &varname) const static const Token* skipPointers(const Token* tok) { + const Token *start = tok; + bool memberPointer = false; + while (tok) { + if (Token::simpleMatch(tok, "::")) { + tok = tok->next(); + continue; + } + if (Token::Match(tok, "%type% ::")) { + tok = tok->tokAt(2); + memberPointer = true; + continue; + } + if (Token::Match(tok, "%type% <") && tok->linkAt(1)) { + tok = tok->linkAt(1)->next(); + continue; + } + break; + } + if (memberPointer && !Token::simpleMatch(tok, "*")) + return start; while (Token::Match(tok, "*|&|&&") || (Token::Match(tok, "( [*&]") && Token::Match(tok->link()->next(), "(|["))) { tok = tok->next(); if (tok && tok->strAt(-1) == "(" && Token::Match(tok, "%type% ::")) diff --git a/test/testother.cpp b/test/testother.cpp index 06512a930c9..21a640a3c7d 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -10468,7 +10468,7 @@ class TestOther : public TestFixture { // Member variable pointers check("void podMemPtrs() {\n" - " int POD::*memptr;\n" + " const int POD::*memptr;\n" " memptr = &POD::a;\n" " memptr = &POD::b;\n" " if (memptr)\n" diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 0a676d00218..50f67823b4e 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -77,6 +77,8 @@ class TestUnusedVar : public TestFixture { TEST_CASE(structmember29); // #14075 TEST_CASE(structmember30); // #14131 TEST_CASE(structmember31); // #14130 + TEST_CASE(structmember32); // #14483 + TEST_CASE(structmember33); TEST_CASE(structmember_macro); TEST_CASE(structmember_template_argument); // #13887 - do not report that member used in template argument is unused TEST_CASE(classmember); @@ -2066,6 +2068,20 @@ class TestUnusedVar : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void structmember32() { // #14483 + checkStructMemberUsage("struct S {\n" + " int S::* mp;\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:2:12]: (style) struct member 'S::mp' is never used. [unusedStructMember]\n", errout_str()); + } + + void structmember33() { + checkStructMemberUsage("struct S {\n" + " int A::B::C::* mp;\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:2:23]: (style) struct member 'S::mp' is never used. [unusedStructMember]\n", errout_str()); + } + void structmember_macro() { checkStructMemberUsageP("#define S(n) struct n { int a, b, c; };\n" "S(unused);\n"); From ba14d48fb315c20fa71e0e61266fa3158121c0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 21 Feb 2026 20:19:14 +0100 Subject: [PATCH 159/675] made `Scope::findInNestedListRecursive()` const (#8236) --- lib/symboldatabase.cpp | 6 +++--- lib/symboldatabase.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f1c2ee0a14a..50ee932d6fa 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6530,7 +6530,7 @@ Type* Scope::findType(const std::string& name) //--------------------------------------------------------------------------- -Scope *Scope::findInNestedListRecursive(const std::string & name) +const Scope *Scope::findInNestedListRecursive(const std::string & name) const { auto it = std::find_if(nestedList.cbegin(), nestedList.cend(), [&](const Scope* s) { return s->className == name; @@ -6538,8 +6538,8 @@ Scope *Scope::findInNestedListRecursive(const std::string & name) if (it != nestedList.end()) return *it; - for (Scope* scope: nestedList) { - Scope *child = scope->findInNestedListRecursive(name); + for (const Scope* scope: nestedList) { + const Scope *child = scope->findInNestedListRecursive(name); if (child) return child; } diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 954b31cc05b..0eaa0aab9ee 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1157,7 +1157,7 @@ class CPPCHECKLIB Scope { * @brief find if name is in nested list * @param name name of nested scope */ - Scope *findInNestedListRecursive(const std::string & name); + const Scope *findInNestedListRecursive(const std::string & name) const; void addVariable(const Token *token_, const Token *start_, const Token *end_, AccessControl access_, const Type *type_, From e1cfdb9dc73438bfbee5c6a5a8d9beeb84a7fda0 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 21 Feb 2026 20:26:39 +0100 Subject: [PATCH 160/675] Fix #12742 FP containerOutOfBounds for increment in loop (#8230) --- lib/valueflow.cpp | 2 +- test/teststl.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 94dde440368..867076574c5 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4531,7 +4531,7 @@ struct ConditionHandler { } // Variable changed in loop code - const Token* const start = top; + const Token* const start = top->strAt(-1) == "for" ? top->astOperand2() : top; // skip init statement const Token* const block = top->link()->next(); const Token* const end = block->link(); diff --git a/test/teststl.cpp b/test/teststl.cpp index c24bf2a5fb1..cc4856628df 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1010,6 +1010,12 @@ class TestStl : public TestFixture { ASSERT_EQUALS( "[test.cpp:2:12] -> [test.cpp:4:21]: (warning) Either the condition 'col>textline.size()' is redundant or 'col' can have the value textline.size(). Expression 'textline[col]' causes access out of bounds. [containerOutOfBounds]\n", errout_str()); + + check("void f(const std::vector& v) {\n" // #12742 + " for (unsigned i = 0; i < v.size();)\n" + " (void)v[i++];\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void outOfBoundsIndexExpression() { From d163087b8cbd933836154add46fe5e972327ab3c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 23 Feb 2026 18:33:46 +0100 Subject: [PATCH 161/675] Refs #12832: donate_cpu_lib: Add library detection fro AVR, MSUnitTest, SELinux, SFML, Zephyr (#8250) --- tools/donate_cpu_lib.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/donate_cpu_lib.py b/tools/donate_cpu_lib.py index 2f2cea803ae..44d3157bc40 100644 --- a/tools/donate_cpu_lib.py +++ b/tools/donate_cpu_lib.py @@ -16,7 +16,7 @@ # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # changes) -CLIENT_VERSION = "1.3.69" +CLIENT_VERSION = "1.3.70" # Timeout for analysis with Cppcheck in seconds CPPCHECK_TIMEOUT = 30 * 60 @@ -684,7 +684,8 @@ def upload_nodata(package): class LibraryIncludes: def __init__(self): - include_mappings = {'boost': ['', '', '','', '', '', ''], 'cairo': [''], 'cppunit': ['', '', ''], 'microsoft_atl': [''], 'microsoft_sal': [''], + 'microsoft_unittest': [''], 'motif': ['', '"prtypes.h"'], 'ntl': ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], - #'selinux': ['', '"sqlite3.h"'], 'tinyxml2': [''], } From 923430d2f3a5d49129f798e38504bd343a9ed486 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 23 Feb 2026 19:50:53 +0100 Subject: [PATCH 162/675] Fix #14518 FP KnownConditionTrueFalse: std::string constructed from char array (#8242) --- lib/valueflow.cpp | 2 +- test/testvalueflow.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 867076574c5..3fa48223e51 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -6494,7 +6494,7 @@ static std::vector getContainerSizeFromConstructorArgs(const s if (args.size() == 1 && args[0]->tokType() == Token::Type::eString) return {makeContainerSizeValue(Token::getStrLength(args[0]), known)}; if (args.size() == 1 && args[0]->variable() && args[0]->variable()->isArray() && - args[0]->variable()->isConst() && args[0]->variable()->dimensions().size() == 1) + args[0]->variable()->isConst() && args[0]->variable()->dimensions().size() == 1 && args[0]->variable()->dimensions()[0].known) return {makeContainerSizeValue(args[0]->variable()->dimensions()[0].num, known)}; if (args.size() == 2 && astIsIntegral(args[1], false)) // { char*, count } return {makeContainerSizeValue(args[1], known)}; diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 79ad6e45b30..6eb807bdd11 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -7406,6 +7406,12 @@ class TestValueFlow : public TestFixture { " return a[0];\n" "}"; ASSERT(!isKnownContainerSizeValue(tokenValues(code, "a ["), 6).empty()); + + code = "void f(const char a[]) {\n" // #14518 + " std::string s(a);\n" + " if (s.empty()) {}\n" + "}"; + ASSERT(!isKnownContainerSizeValue(tokenValues(code, "s ."), 0).empty()); } void valueFlowContainerElement() From 6c20dbe27f8a60ac3211ad759fcaaadf64c1c3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Tue, 24 Feb 2026 01:12:12 +0100 Subject: [PATCH 163/675] Add tests for #14479 & #14480: False negatives with member pointers (#8244) These were fixed by a5db405d702b2e51572dcaae36bc8d9a3e955ee9 --- test/testuninitvar.cpp | 11 +++++++++++ test/testunusedvar.cpp | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index ad9dee0fcac..b48db6ef972 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -97,6 +97,7 @@ class TestUninitVar : public TestFixture { TEST_CASE(uninitvar_memberfunction); TEST_CASE(uninitvar_nonmember); // crash in ycmd test TEST_CASE(uninitvarDesignatedInitializers); + TEST_CASE(uninitvarMemberPointer); TEST_CASE(isVariableUsageDeref); // *p TEST_CASE(isVariableUsageDerefValueflow); // *p @@ -7825,6 +7826,16 @@ class TestUninitVar : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void uninitvarMemberPointer() { + checkUninitVar("void f()\n" + "{\n" + " struct S {};\n" + " int S::* mp;\n" + " if (mp) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5:7]: (error) Uninitialized variable: mp [legacyUninitvar]\n", errout_str()); + } + void isVariableUsageDeref() { // *p checkUninitVar("void f() {\n" diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 50f67823b4e..43b5d2abe40 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -154,6 +154,7 @@ class TestUnusedVar : public TestFixture { TEST_CASE(localvar69); TEST_CASE(localvar70); TEST_CASE(localvar71); + TEST_CASE(localvar72); TEST_CASE(localvarloops); // loops TEST_CASE(localvaralias1); TEST_CASE(localvaralias2); // ticket #1637 @@ -4046,6 +4047,15 @@ class TestUnusedVar : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void localvar72() { + functionVariableUsage("void f()\n" + "{\n" + " struct S {};\n" + " int S::* mp;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4:12]: (style) Unused variable: mp [unusedVariable]\n", errout_str()); + } + void localvarloops() { // loops functionVariableUsage("void fun(int c) {\n" From 1a9bdeb51f713e3269adae06c39678541adace32 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 24 Feb 2026 08:23:57 +0100 Subject: [PATCH 164/675] Fix #14510 FP constParameterPointer (lambda decaying to function pointer) (#8234) Co-authored-by: chrchr-github --- lib/checkother.cpp | 2 ++ test/testother.cpp | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index cf5ecb65b91..de6e295e04a 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1869,6 +1869,8 @@ void CheckOther::checkConstPointer() continue; if (!var->isLocal() && !var->isArgument()) continue; + if (var->isArgument() && var->scope() && var->scope()->type == ScopeType::eLambda) + continue; const Token* const nameTok = var->nameToken(); if (tok == nameTok && var->isLocal() && !astIsRangeBasedForDecl(nameTok)) { if (var->isReference() && var->isPointer()) { diff --git a/test/testother.cpp b/test/testother.cpp index 21a640a3c7d..6bc2db7e983 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4676,6 +4676,27 @@ class TestOther : public TestFixture { ASSERT_EQUALS("[test.cpp:1:18]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n" "[test.cpp:4:18]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str()); + + check("using fp_t = int (*)(int*);\n" // #14510 + "fp_t g_fp;\n" + "struct S { fp_t m_fp; };\n" + "void g(fp_t);\n" + "S f(S* s) {\n" + " g_fp = [](int* p) { return *p; };\n" + " s->m_fp = [](int* p) { return *p; };\n" + " g([](int* p) { return *p; });\n" + " auto x = [](int* p) { return *p; };\n" + " g(x);\n" + " return { [](int* p) { return *p; } };\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + + check("void f() {\n" + " int i = 0;\n" + " auto x = [&]() { int* p = &i; if (*p) {} };\n" + " x();\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:27]: (style) Variable 'p' can be declared as pointer to const [constVariablePointer]\n", errout_str()); } void constArray() { From 5f6aebeecd616ecc370524d0ea202e05708597eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 24 Feb 2026 08:41:43 +0100 Subject: [PATCH 165/675] Fix #14516 (Review progress messages) (#8241) --- .github/workflows/selfcheck.yml | 2 +- lib/cppcheck.cpp | 4 +++ lib/errorlogger.h | 36 +++++++++++++++++++ lib/symboldatabase.cpp | 11 +++--- lib/tokenize.cpp | 10 +++--- lib/valueflow.cpp | 4 +++ test/cli/other_test.py | 64 +++++++++++++++++++++++++++++++-- 7 files changed, 115 insertions(+), 16 deletions(-) diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index d0c0f233dd2..804de21a0b4 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -121,7 +121,7 @@ jobs: - name: Self check (unusedFunction / no test / no gui) run: | - supprs="--suppress=unusedFunction:lib/errorlogger.h:196 --suppress=unusedFunction:lib/importproject.cpp:1531 --suppress=unusedFunction:lib/importproject.cpp:1555" + supprs="--suppress=unusedFunction:lib/errorlogger.h:197 --suppress=unusedFunction:lib/importproject.cpp:1531 --suppress=unusedFunction:lib/importproject.cpp:1555" ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib -D__CPPCHECK__ -D__GNUC__ --enable=unusedFunction,information --exception-handling -rp=. --project=cmake.output.notest_nogui/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr $supprs env: DISABLE_VALUEFLOW: 1 diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 80b43228a58..d74c19f4ea7 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1316,6 +1316,8 @@ void CppCheck::internalError(const std::string &filename, const std::string &msg void CppCheck::checkNormalTokens(const Tokenizer &tokenizer, AnalyzerInformation* analyzerInformation, const std::string& currentConfig) { + const ProgressReporter progressReporter(mErrorLogger, mSettings.reportProgress, tokenizer.list.getSourceFilePath(), "Run checkers"); + CheckUnusedFunctions unusedFunctionsChecker; // TODO: this should actually be the behavior if only "--enable=unusedFunction" is specified - see #10648 @@ -1514,6 +1516,8 @@ void CppCheck::executeAddons(const std::vector& files, const std::s if (isCtuInfo && addonInfo.name != "misra" && !addonInfo.ctu) continue; + ProgressReporter progressReporter(mErrorLogger, mSettings.reportProgress, files.front(), "addon:" + addonInfo.name + (isCtuInfo ? " (ctu)" : "")); + std::vector results; try { diff --git a/lib/errorlogger.h b/lib/errorlogger.h index f8806bbbdca..19d423f7f02 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -286,6 +287,41 @@ class CPPCHECKLIB ErrorLogger { static const std::set mCriticalErrorIds; }; +/// RAII class for reporting progress messages +class CPPCHECKLIB ProgressReporter { +public: + ProgressReporter(ErrorLogger& e, int reportProgressInterval, std::string filename, std::string stage) : + mErrorLogger(e), + mReportProgressInterval(reportProgressInterval), + mFilename(std::move(filename)), + mStage(std::move(stage)) { + report(0); + } + + ~ProgressReporter() { + mErrorLogger.reportProgress(mFilename, mStage.c_str(), 100); + } + + void report(int value) { + if (mReportProgressInterval < 0 || value == mLastValue) + return; + const std::time_t t = std::time(nullptr); + if (t >= mLastTime + mReportProgressInterval) { + mErrorLogger.reportProgress(mFilename, mStage.c_str(), value); + mLastTime = t; + mLastValue = value; + } + } + +private: + ErrorLogger& mErrorLogger; + const int mReportProgressInterval; + const std::string mFilename; + const std::string mStage; + std::time_t mLastTime{0}; + int mLastValue{-1}; +}; + /** Replace substring. Example replaceStr("1,NR,3", "NR", "2") => "1,2,3" */ std::string replaceStr(std::string s, const std::string &from, const std::string &to); diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 50ee932d6fa..c997a907501 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -174,8 +174,6 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() // Store current access in each scope (depends on evaluation progress) std::map access; - const bool doProgress = (mSettings.reportProgress != -1); - std::map> forwardDecls; const std::function findForwardDeclScope = [&](const Token *tok, Scope *startScope) { @@ -200,13 +198,14 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() return it->second.count(tok->str()) > 0 ? startScope : nullptr; }; + ProgressReporter progressReporter(mErrorLogger, mSettings.reportProgress, mTokenizer.list.getSourceFilePath(), "SymbolDatabase (find all scopes)"); + // find all scopes for (const Token *tok = mTokenizer.tokens(); tok; tok = tok ? tok->next() : nullptr) { // #5593 suggested to add here: - if (doProgress) - mErrorLogger.reportProgress(mTokenizer.list.getSourceFilePath(), - "SymbolDatabase", - tok->progressValue()); + + progressReporter.report(tok->progressValue()); + // Locate next class if ((tok->isCpp() && tok->isKeyword() && ((Token::Match(tok, "class|struct|union|namespace ::| %name% final| {|:|::|<") && diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index bb3957fb9ae..9f07767edc7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1167,11 +1167,10 @@ void Tokenizer::simplifyTypedefCpp() std::vector spaceInfo(1); const std::time_t maxTime = mSettings.typedefMaxTime > 0 ? std::time(nullptr) + mSettings.typedefMaxTime: 0; - const bool doProgress = (mSettings.reportProgress != -1) && !list.getFiles().empty(); + ProgressReporter progressReporter(mErrorLogger, mSettings.reportProgress, list.getSourceFilePath(), "Tokenize (typedef)"); for (Token *tok = list.front(); tok; tok = tok->next()) { - if (doProgress) - mErrorLogger.reportProgress(list.getFiles()[0], "Tokenize (typedef)", tok->progressValue()); + progressReporter.report(tok->progressValue()); if (Settings::terminated()) return; @@ -2932,11 +2931,10 @@ bool Tokenizer::simplifyUsing() }; std::list usingList; - const bool doProgress = (mSettings.reportProgress != -1) && !list.getFiles().empty(); + ProgressReporter progressReporter(mErrorLogger, mSettings.reportProgress, list.getSourceFilePath(), "Tokenize (using)"); for (Token *tok = list.front(); tok; tok = tok->next()) { - if (doProgress) - mErrorLogger.reportProgress(list.getFiles()[0], "Tokenize (using)", tok->progressValue()); + progressReporter.report(tok->progressValue()); if (Settings::terminated()) return substitute; diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 3fa48223e51..e824ba75a5a 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -7210,7 +7210,9 @@ struct ValueFlowPassRunner { std::size_t n = state.settings.vfOptions.maxIterations; while (n > 0 && values != getTotalValues()) { values = getTotalValues(); + const std::string passnum = std::to_string(state.settings.vfOptions.maxIterations - n + 1); if (std::any_of(passes.begin(), passes.end(), [&](const ValuePtr& pass) { + ProgressReporter progressReporter(state.errorLogger, state.settings.reportProgress >= 0, state.tokenlist.getSourceFilePath(), std::string("ValueFlow::") + pass->name() + (' ' + passnum)); return run(pass); })) return true; @@ -7354,6 +7356,8 @@ void ValueFlow::setValues(TokenList& tokenlist, const Settings& settings, TimerResultsIntf* timerResults) { + ProgressReporter progressReporter(errorLogger, settings.reportProgress, tokenlist.getSourceFilePath(), "ValueFlow"); + for (Token* tok = tokenlist.front(); tok; tok = tok->next()) tok->clearValueFlow(); diff --git a/test/cli/other_test.py b/test/cli/other_test.py index b8433bceef3..5a6662faf56 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -169,9 +169,67 @@ def test_progress(tmpdir): "progress: Tokenize (typedef) 62%\n" "progress: Tokenize (typedef) 75%\n" "progress: Tokenize (typedef) 87%\n" - "progress: SymbolDatabase 0%\n" - "progress: SymbolDatabase 12%\n" - "progress: SymbolDatabase 87%\n" + "progress: Tokenize (typedef) 100%\n" + "progress: SymbolDatabase (find all scopes) 0%\n" + "progress: SymbolDatabase (find all scopes) 12%\n" + "progress: SymbolDatabase (find all scopes) 87%\n" + "progress: SymbolDatabase (find all scopes) 100%\n" + "progress: ValueFlow 0%\n" + "progress: ValueFlow::valueFlowImpossibleValues(tokenlist, settings) 1 0%\n" + "progress: ValueFlow::valueFlowImpossibleValues(tokenlist, settings) 1 100%\n" + "progress: ValueFlow::valueFlowSymbolicOperators(symboldatabase, settings) 1 0%\n" + "progress: ValueFlow::valueFlowSymbolicOperators(symboldatabase, settings) 1 100%\n" + "progress: ValueFlow::valueFlowCondition(SymbolicConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 0%\n" + "progress: ValueFlow::valueFlowCondition(SymbolicConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 100%\n" + "progress: ValueFlow::valueFlowSymbolicInfer(symboldatabase, settings) 1 0%\n" + "progress: ValueFlow::valueFlowSymbolicInfer(symboldatabase, settings) 1 100%\n" + "progress: ValueFlow::valueFlowArrayBool(tokenlist, settings) 1 0%\n" + "progress: ValueFlow::valueFlowArrayBool(tokenlist, settings) 1 100%\n" + "progress: ValueFlow::valueFlowArrayElement(tokenlist, settings) 1 0%\n" + "progress: ValueFlow::valueFlowArrayElement(tokenlist, settings) 1 100%\n" + "progress: ValueFlow::valueFlowRightShift(tokenlist, settings) 1 0%\n" + "progress: ValueFlow::valueFlowRightShift(tokenlist, settings) 1 100%\n" + "progress: ValueFlow::valueFlowCondition(ContainerConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 0%\n" + "progress: ValueFlow::valueFlowCondition(ContainerConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 100%\n" + "progress: ValueFlow::valueFlowAfterAssign(tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 0%\n" + "progress: ValueFlow::valueFlowAfterAssign(tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 100%\n" + "progress: ValueFlow::valueFlowAfterSwap(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowAfterSwap(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowCondition(SimpleConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 0%\n" + "progress: ValueFlow::valueFlowCondition(SimpleConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 100%\n" + "progress: ValueFlow::valueFlowInferCondition(tokenlist, settings) 1 0%\n" + "progress: ValueFlow::valueFlowInferCondition(tokenlist, settings) 1 100%\n" + "progress: ValueFlow::valueFlowSwitchVariable(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowSwitchVariable(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowForLoop(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowForLoop(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowSubFunction(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowSubFunction(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowFunctionReturn(tokenlist, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowFunctionReturn(tokenlist, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowLifetime(tokenlist, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowLifetime(tokenlist, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowFunctionDefaultParameter(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowFunctionDefaultParameter(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowUninit(tokenlist, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowUninit(tokenlist, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowAfterMove(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowAfterMove(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowSmartPointer(tokenlist, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowSmartPointer(tokenlist, errorLogger, settings) 1 100%\n" + "progress: ValueFlow::valueFlowIterators(tokenlist, settings) 1 0%\n" + "progress: ValueFlow::valueFlowIterators(tokenlist, settings) 1 100%\n" + "progress: ValueFlow::valueFlowCondition(IteratorConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 0%\n" + "progress: ValueFlow::valueFlowCondition(IteratorConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 100%\n" + "progress: ValueFlow::valueFlowIteratorInfer(tokenlist, settings) 1 0%\n" + "progress: ValueFlow::valueFlowIteratorInfer(tokenlist, settings) 1 100%\n" + "progress: ValueFlow::valueFlowContainerSize(tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 0%\n" + "progress: ValueFlow::valueFlowContainerSize(tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 100%\n" + "progress: ValueFlow::valueFlowSafeFunctions(tokenlist, symboldatabase, errorLogger, settings) 1 0%\n" + "progress: ValueFlow::valueFlowSafeFunctions(tokenlist, symboldatabase, errorLogger, settings) 1 100%\n" + "progress: ValueFlow 100%\n" + "progress: Run checkers 0%\n" + "progress: Run checkers 100%\n" ) assert stderr == "" From bd33cf532330d21b39d4810bbf34fdfaa2a67c85 Mon Sep 17 00:00:00 2001 From: ceJce Date: Tue, 24 Feb 2026 08:57:57 +0100 Subject: [PATCH 166/675] Fix #11389 Do not warn for truncLongCastReturn if operands have known valid int (#8192) This fix handles the first example in ticket, i.e. when the value is known to be a valid int: long f() { int n = 1; return n << 12; } --- lib/checktype.cpp | 8 ++++++-- test/testtype.cpp | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 68b6580d270..509d13b54e0 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -383,8 +383,12 @@ void CheckType::checkLongCast() const ValueType *type = tok->astOperand1()->valueType(); if (type && checkTypeCombination(*type, *retVt, *mSettings) && type->pointer == 0U && - type->originalTypeName.empty()) - ret = tok; + type->originalTypeName.empty()) { + if (!tok->astOperand1()->hasKnownIntValue()) { + ret = tok; + } else if (!mSettings->platform.isIntValue(tok->astOperand1()->getKnownIntValue())) + ret = tok; + } } // All return statements must have problem otherwise no warning if (ret != tok) { diff --git a/test/testtype.cpp b/test/testtype.cpp index b8cfae820d5..ea31fbdc313 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -465,6 +465,26 @@ class TestType : public TestFixture { check(code2, dinit(CheckOptions, $.settings = &settingsWin)); ASSERT_EQUALS("[test.cpp:2:3]: (style) int result is returned as long long value. If the return value is long long to avoid loss of information, then you have loss of information. [truncLongCastReturn]\n", errout_str()); + const char code3[] = "long f() {\n" + " int n = 1;\n" + " return n << 12;\n" + "}\n"; + check(code3, dinit(CheckOptions, $.settings = &settings)); + ASSERT_EQUALS("", errout_str()); + + const char code4[] = "long f(int n) {\n" + " return n << 12;\n" + "}\n"; + check(code4, dinit(CheckOptions, $.settings = &settings)); + ASSERT_EQUALS("[test.cpp:2:5]: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. [truncLongCastReturn]\n", errout_str()); + + const char code5[] = "long f() {\n" + " unsigned int n = 1U << 20;\n" + " return n << 20;\n" + "}\n"; + check(code5, dinit(CheckOptions, $.settings = &settings)); + ASSERT_EQUALS("[test.cpp:3:5]: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. [truncLongCastReturn]\n", errout_str()); + // typedef check("size_t f(int x, int y) {\n" " return x * y;\n" From bed8dbee3e11f78ce4e4c63bdf5415dd2f473eec Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 24 Feb 2026 14:42:32 +0100 Subject: [PATCH 167/675] Fix #12609 FN redundantCopyLocalConst (copy from variable) (#8251) Co-authored-by: chrchr-github --- lib/checkother.cpp | 83 ++++++++++++++++++++++++++++++---------------- test/testother.cpp | 41 ++++++++++++++++++++++- 2 files changed, 95 insertions(+), 29 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index de6e295e04a..c4c4cf049b2 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3292,10 +3292,63 @@ static bool constructorTakesReference(const Scope * const classScope) }); } +static bool isLargeObject(const Variable* var, const Settings& settings) +{ + return var && !var->isGlobal() && + (!var->type() || !var->type()->classScope || + (var->valueType() && var->valueType()->getSizeOf(settings, ValueType::Accuracy::LowerBound, ValueType::SizeOf::Pointer) > 2 * settings.platform.sizeof_pointer)); +} + //--------------------------------------------------------------------------- // This check rule works for checking the "const A a = getA()" usage when getA() returns "const A &" or "A &". // In most scenarios, "const A & a = getA()" will be more efficient. //--------------------------------------------------------------------------- +static bool checkFunctionReturnsRef(const Token* tok, const Settings& settings) +{ + if (!Token::Match(tok->previous(), "%name% (")) + return false; + if (!Token::Match(tok->link(), ") )|}| ;")) // bailout for usage like "const A a = getA()+3" + return false; + const Token* dot = tok->astOperand1(); + if (Token::simpleMatch(dot, ".")) { + const Token* varTok = dot->astOperand1(); + const int indirect = varTok->valueType() ? varTok->valueType()->pointer : 0; + if (isVariableChanged(tok, tok->scope()->bodyEnd, indirect, varTok->varId(), /*globalvar*/ true, settings)) + return false; + if (isTemporary(dot, &settings.library, /*unknown*/ true)) + return false; + } + if (exprDependsOnThis(tok->previous())) + return false; + const Function* func = tok->previous()->function(); + if (func && func->tokenDef->strAt(-1) == "&") { + const Scope* fScope = func->functionScope; + if (fScope && fScope->bodyEnd && Token::Match(fScope->bodyEnd->tokAt(-3), "return %var% ;")) { + const Token* varTok = fScope->bodyEnd->tokAt(-2); + if (isLargeObject(varTok->variable(), settings)) + return true; + } + } + return false; +} + +static bool checkVariableAssignment(const Token* tok, const Settings& settings) +{ + if (!Token::Match(tok, "%var% ;")) + return false; + const Variable* var = tok->variable(); + if (!var || !isLargeObject(var, settings)) + return false; + if (findVariableChanged(tok->tokAt(2), tok->scope()->bodyEnd, /*indirect*/ 0, var->declarationId(), /*globalvar*/ false, settings)) + return false; + if (var->isLocal() || (var->isArgument() && !var->isReference())) + return true; + const Scope* scope = tok->scope(); + while (scope && scope->type != ScopeType::eFunction) + scope = scope->nestedIn; + return scope && scope->function && (!scope->functionOf || scope->function->isConst() || scope->function->isStatic()); +} + void CheckOther::checkRedundantCopy() { if (!mSettings->severity.isEnabled(Severity::performance) || mTokenizer->isC() || !mSettings->certainty.isEnabled(Certainty::inconclusive)) @@ -3328,35 +3381,9 @@ void CheckOther::checkRedundantCopy() const Token* tok = startTok->next()->astOperand2(); if (!tok) continue; - if (!Token::Match(tok->previous(), "%name% (")) - continue; - if (!Token::Match(tok->link(), ") )|}| ;")) // bailout for usage like "const A a = getA()+3" + if (!checkFunctionReturnsRef(tok, *mSettings) && !checkVariableAssignment(tok, *mSettings)) continue; - - const Token* dot = tok->astOperand1(); - if (Token::simpleMatch(dot, ".")) { - const Token* varTok = dot->astOperand1(); - const int indirect = varTok->valueType() ? varTok->valueType()->pointer : 0; - if (isVariableChanged(tok, tok->scope()->bodyEnd, indirect, varTok->varId(), /*globalvar*/ true, *mSettings)) - continue; - if (isTemporary(dot, &mSettings->library, /*unknown*/ true)) - continue; - } - if (exprDependsOnThis(tok->previous())) - continue; - - const Function* func = tok->previous()->function(); - if (func && func->tokenDef->strAt(-1) == "&") { - const Scope* fScope = func->functionScope; - if (fScope && fScope->bodyEnd && Token::Match(fScope->bodyEnd->tokAt(-3), "return %var% ;")) { - const Token* varTok = fScope->bodyEnd->tokAt(-2); - if (varTok->variable() && !varTok->variable()->isGlobal() && - (!varTok->variable()->type() || !varTok->variable()->type()->classScope || - (varTok->variable()->valueType() && - varTok->variable()->valueType()->getSizeOf(*mSettings, ValueType::Accuracy::LowerBound, ValueType::SizeOf::Pointer) > 2 * mSettings->platform.sizeof_pointer))) - redundantCopyError(startTok, startTok->str()); - } - } + redundantCopyError(startTok, startTok->str()); } } diff --git a/test/testother.cpp b/test/testother.cpp index 6bc2db7e983..c2781cbab6c 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2702,7 +2702,9 @@ class TestOther : public TestFixture { check("void f(std::string str) {\n" " std::string s2 = str;\n" "}"); - ASSERT_EQUALS("[test.cpp:1:20]: (performance) Function parameter 'str' should be passed by const reference. [passedByValue]\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2:17]: (performance, inconclusive) Use const reference for 's2' to avoid unnecessary data copying. [redundantCopyLocalConst]\n" + "[test.cpp:1:20]: (performance) Function parameter 'str' should be passed by const reference. [passedByValue]\n", + errout_str()); check("void f(std::string str) {\n" " std::string& s2 = str;\n" @@ -9905,6 +9907,43 @@ class TestOther : public TestFixture { " if (s.empty()) {}\n" "}\n"); ASSERT_EQUALS("[test.cpp:6:16]: (performance, inconclusive) Use const reference for 's' to avoid unnecessary data copying. [redundantCopyLocalConst]\n", errout_str()); + + check("void f1(const std::string& s) {\n" + " std::string s1 = s;\n" + " (void)s1;\n" + "}\n" + "void f2() {\n" + " const std::string s;\n" + " std::string s1 = s;\n" + " (void)s1;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:17]: (performance, inconclusive) Use const reference for 's1' to avoid unnecessary data copying. [redundantCopyLocalConst]\n" + "[test.cpp:7:17]: (performance, inconclusive) Use const reference for 's1' to avoid unnecessary data copying. [redundantCopyLocalConst]\n", + errout_str()); + + check("struct S {\n" + " std::string m;\n" + " int f(const std::string& s);\n" + "};\n" + "int S::f(const std::string& s) {\n" + " std::string c = s;\n" + " m.clear();\n" + " return c.size();\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + + check("struct S {\n" + " std::string m;\n" + " int f(std::string s);\n" + "};\n" + "int S::f(std::string s) {\n" + " s += m;\n" + " std::string c = s;\n" + " m.clear();\n" + " return c.size();\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:7:17]: (performance, inconclusive) Use const reference for 'c' to avoid unnecessary data copying. [redundantCopyLocalConst]\n", + errout_str()); } void checkNegativeShift() { From 15424d0a2ade483d9b39715832313f04c9c321e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 24 Feb 2026 17:55:36 +0100 Subject: [PATCH 168/675] Fix #14527 (createrelease: uploading files tweaks) (#8254) --- createrelease | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/createrelease b/createrelease index 47f9dd74ab2..e89cd5cdf04 100755 --- a/createrelease +++ b/createrelease @@ -47,6 +47,9 @@ # # Create 2.18.x branch # git checkout -b 2.18.x ; git push -u origin 2.18.x +# in fork: +# * add upstream: git remote add upstream git@github.com:danmar/cppcheck.git +# * add branch: git fetch upstream 2.19.x # # Release notes: # - ensure safety critical issues are listed properly @@ -127,28 +130,26 @@ cd ~/cppcheck git checkout $tag rm -rf upload -mkdir -p upload +mkdir -p upload/htdocs upload/frs +# htdocs make clean +make -j12 +rm -f cppcheck.cfg +./cppcheck --version > upload/htdocs/version.txt +# TODO manual, update version on webpage -# Create archives.. +# frs git archive --format=tar --prefix=$releasename/ $tag | gzip > upload/$releasename.tar.gz git archive --format=tar --prefix=$releasename/ $tag | bzip2 > upload/$releasename.tar.bz2 git archive --format=zip -9 --prefix=$releasename/ $tag > upload/$releasename.zip +cp releasenotes.txt upload/frs/README.md +# TODO msi + cd upload -scp $releasename.* danielmarjamaki,cppcheck@frs.sourceforge.net:/home/frs/project/c/cp/cppcheck/cppcheck/$folder/ -rm $releasename.* +scp frs/* danielmarjamaki,cppcheck@frs.sourceforge.net:/home/frs/project/c/cp/cppcheck/cppcheck/$folder/ +scp htdocs/* danielmarjamaki,cppcheck@web.sourceforge.net:htdocs/ cd .. - -# Generate version.txt -make -j12 -rm -f cppcheck.cfg -./cppcheck --version > upload/version.txt - -cd ~/cppcheck/upload -scp version.txt danielmarjamaki,cppcheck@web.sourceforge.net:htdocs/ - -cd ~/cppcheck rm -rf upload # Local cppcheck binary From afc317e16dd8034d65c1288bfee07b78f2098def Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 24 Feb 2026 18:52:26 +0100 Subject: [PATCH 169/675] Partial fix for #14524 FN memleak with C++ cast (#8249) --- lib/checkmemoryleak.cpp | 3 +++ test/testmemleak.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 542f4e9fc49..b2ea542b964 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -56,6 +56,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2, { // What we may have... // * var = (char *)malloc(10); + // * var = static_cast(malloc(10)); // * var = new char[10]; // * var = strdup("hello"); // * var = strndup("hello", 3); @@ -63,6 +64,8 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2, tok2 = tok2->link(); tok2 = tok2 ? tok2->next() : nullptr; } + if (tok2 && tok2->isCpp() && tok2->isKeyword() && endsWith(tok2->str(), "_cast")) + tok2 = tok2->astParent()->next(); if (!tok2) return No; if (tok2->str() == "::") diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 26877650584..30d55e47413 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -1674,6 +1674,7 @@ class TestMemleakStructMember : public TestFixture { TEST_CASE(assign3); TEST_CASE(assign4); // #11019 TEST_CASE(assign5); + TEST_CASE(assign6); // Failed allocation TEST_CASE(failedAllocation); @@ -1955,6 +1956,15 @@ class TestMemleakStructMember : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void assign6() { + check("struct S { S* p; };\n" // #14524 + "void f() {\n" + " S s;\n" + " s.p = static_cast(malloc(sizeof(S)));\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5:1]: (error) Memory leak: s.p [memleak]\n", errout_str()); + } + void failedAllocation() { check("static struct ABC * foo()\n" "{\n" From 4d8eab36d21c8333097d367cc902a17448725fc8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 25 Feb 2026 08:06:07 +0100 Subject: [PATCH 170/675] Fix #14390 Inconsistent functionConst with pointers in container member (#8248) --- lib/checkclass.cpp | 6 ++++-- test/testclass.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index f56c799b247..6321bf3c9ea 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2545,8 +2545,10 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member } } } else if (lhs->str() == ":" && lhs->astParent() && lhs->astParent()->str() == "(") { // range-based for-loop (C++11) - // TODO: We could additionally check what is done with the elements to avoid false negatives. Here we just rely on "const" keyword being used. - if (lhs->astParent()->strAt(1) != "const") + const Variable* loopVar = lhs->astOperand1()->variable(); + if (!loopVar || !loopVar->valueType()) + return false; + if (!loopVar->valueType()->isConst(loopVar->valueType()->pointer)) return false; } else { if (lhs->isAssignmentOp()) { diff --git a/test/testclass.cpp b/test/testclass.cpp index 04f298774d1..ff486e3e450 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -7741,6 +7741,19 @@ class TestClass : public TestFixture { " }\n" "};"); ASSERT_EQUALS("[test.cpp:8:10]: (style, inconclusive) Technically the member function 'Fred::f2' can be const. [functionConst]\n", errout_str()); + + checkConst("struct T {\n" // #14390 + " std::vector v;\n" + " void f() {\n" + " for (const auto& p : v)\n" + " *p = 0;\n" + " }\n" + " void g() {\n" + " for (auto* p : v)\n" + " *p = 0;\n" + " }\n" + "};\n"); + ASSERT_EQUALS("", errout_str()); } void const_shared_ptr() { // #8674 From da9399d250176f6e00a7bd281a0598e436f69633 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:57:55 +0100 Subject: [PATCH 171/675] Fix #14534 FN redundantInitialization (std::string, initialization with string, regression) (#8262) --- lib/checkother.cpp | 2 +- test/testother.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index c4c4cf049b2..ce42524f02d 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -631,7 +631,7 @@ void CheckOther::checkRedundantAssignment() [&](const Token *rhs) { if (Token::simpleMatch(rhs, "{ 0 }")) return ChildrenToVisit::none; - if (Token::Match(rhs, "%str%|%num%|%name%") && !rhs->varId()) + if (Token::Match(rhs, "%num%|%name%") && !rhs->varId()) return ChildrenToVisit::none; if (Token::Match(rhs, ":: %name%") && rhs->hasKnownIntValue()) return ChildrenToVisit::none; diff --git a/test/testother.cpp b/test/testother.cpp index c2781cbab6c..d49d3e540d2 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -10613,6 +10613,21 @@ class TestOther : public TestFixture { ASSERT_EQUALS( "[test.cpp:2:10]: (style) Variable 'a' can be declared as pointer to const [constVariablePointer]\n", errout_str()); + + check("std::string f() {\n" // #14534 + " std::string s = \"abc\";\n" + " s = \"def\";\n" + " return s;\n" + "}\n" + "const char* g() {\n" + " const char* p = \"abc\";\n" + " p = \"def\";\n" + " return p;\n" + "}"); + ASSERT_EQUALS( + "[test.cpp:2:19] -> [test.cpp:3:7]: (style) Redundant initialization for 's'. The initialized value is overwritten before it is read. [redundantInitialization]\n" + "[test.cpp:7:19] -> [test.cpp:8:7]: (style) Redundant initialization for 'p'. The initialized value is overwritten before it is read. [redundantInitialization]\n", + errout_str()); } void redundantVarAssignment_struct() { From 9bb6ee84a828ce18f78d75a185591906516ee84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 25 Feb 2026 20:46:42 +0100 Subject: [PATCH 172/675] Fix #14532 (Release 2.20: Update Cppcheck Premium checkers mapping) (#8260) --- lib/checkclass.cpp | 18 ++++++++------- lib/checkersidmapping.cpp | 13 +++++------ lib/checkexceptionsafety.cpp | 2 +- lib/checkother.cpp | 2 +- lib/settings.cpp | 43 ++++++++++++++++++++++++++++++++---- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 6321bf3c9ea..a72603c782b 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2750,15 +2750,17 @@ namespace { // avoid one-definition-rule violation void CheckClass::initializerListOrder() { - if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("initializerList")) - return; + if (!mSettings->isPremiumEnabled("initializerList")) { + if (!mSettings->severity.isEnabled(Severity::style)) + return; - // This check is not inconclusive. However it only determines if the initialization - // order is incorrect. It does not determine if being out of order causes - // a real error. Out of order is not necessarily an error but you can never - // have an error if the list is in order so this enforces defensive programming. - if (!mSettings->certainty.isEnabled(Certainty::inconclusive)) - return; + // This check is not inconclusive. However it only determines if the initialization + // order is incorrect. It does not determine if being out of order causes + // a real error. Out of order is not necessarily an error but you can never + // have an error if the list is in order so this enforces defensive programming. + if (!mSettings->certainty.isEnabled(Certainty::inconclusive)) + return; + } logChecker("CheckClass::initializerListOrder"); // style,inconclusive diff --git a/lib/checkersidmapping.cpp b/lib/checkersidmapping.cpp index 5b0e6705c4c..e9636843853 100644 --- a/lib/checkersidmapping.cpp +++ b/lib/checkersidmapping.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ std::vector checkers::idMappingAutosar{ {"m0-1-1", "unreachableCode,duplicateBreak"}, {"m0-1-2", "unsignedLessThanZero"}, {"m0-1-3", "unusedVariable,unusedStructMember"}, - {"a0-1-1", "unreadVariable,unusedValue,redundantAssignment"}, + {"a0-1-1", "unreadVariable,redundantAssignment"}, {"m0-1-9", "redundantAssignment,redundantInitialization"}, {"m0-1-10", "unusedFunction"}, {"m0-2-1", "overlappingWriteUnion,overlappingWriteFunction"}, @@ -41,7 +41,6 @@ std::vector checkers::idMappingAutosar{ {"m5-0-17", "comparePointers"}, {"m5-0-18", "comparePointers"}, {"a5-1-4", "returnDanglingLifetime"}, - {"a5-2-2", "cstyleCast"}, {"a5-2-5", "arrayIndexOutOfBounds,arrayIndexOutOfBoundsCond,pointerOutOfBounds,pointerOutOfBoundsCond,negativeIndex,arrayIndexThenCheck,bufferAccessOutOfBounds,objectIndex,argumentSize"}, {"m5-3-4", "sizeofFunctionCall"}, {"a5-3-2", "nullPointer,nullPointerRedundantCheck,nullPointerArithmetic,nullPointerArithmeticRedundantCheck,nullPointerDefaultArg"}, @@ -99,13 +98,13 @@ std::vector checkers::idMappingCertCpp{ {"CTR51", "eraseDereference"}, {"CTR54", "comparePointers"}, {"CTR55", "containerOutOfBounds"}, - {"DCL57", "deallocThrow,exceptThrowInDestructor"}, + {"DCL57", "exceptDeallocThrow,exceptThrowInDestructor"}, {"DCL60", "ctuOneDefinitionRuleViolation"}, {"ERR57", "memleak"}, {"EXP52", "sizeofCalculation"}, {"EXP53", "uninitvar,uninitdata,uninitStructMember"}, {"EXP54", "uninitvar,danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime"}, - {"EXP61", "danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime"}, + {"EXP61", "danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime,deallocuse,deallocret"}, {"EXP63", "accessMoved"}, {"FIO50", "IOWithoutPositioning"}, {"MEM50", "deallocuse"}, @@ -124,7 +123,7 @@ std::vector checkers::idMappingMisraC{ {"1.1", "syntaxError"}, {"1.3", "error"}, {"2.1", "duplicateBreak,unreachableCode"}, - {"2.2", "constStatement,redundantCondition,redundantAssignment,redundantAssignInSwitch,unreadVariable"}, + {"2.2", "constStatement,redundantCondition,redundantAssignment,redundantAssignInSwitch,unreadVariable,unusedFunction"}, {"2.6", "unusedLabel"}, {"2.8", "unusedVariable"}, {"5.3", "shadowVariable"}, @@ -168,7 +167,7 @@ std::vector checkers::idMappingMisraCpp2008{ {"5-0-16", "pointerOutOfBounds"}, {"5-0-17", "comparePointers"}, {"5-0-18", "comparePointers"}, - {"5-2-4", "cstyleCast"}, + {"5-2-4", "cstyleCast,dangerousTypeCast"}, {"5-3-4", "sizeofFunctionCall"}, {"5-8-1", "shiftTooManyBits"}, {"6-6-5", "missingReturn"}, diff --git a/lib/checkexceptionsafety.cpp b/lib/checkexceptionsafety.cpp index 36cec717d90..61f1ad8c784 100644 --- a/lib/checkexceptionsafety.cpp +++ b/lib/checkexceptionsafety.cpp @@ -95,7 +95,7 @@ void CheckExceptionSafety::destructorsError(const Token * const tok, const std:: void CheckExceptionSafety::deallocThrow() { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("exceptDeallocThrow")) return; logChecker("CheckExceptionSafety::deallocThrow"); // warning diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ce42524f02d..ac8284bddba 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -415,7 +415,7 @@ void CheckOther::warningDangerousTypeCast() // Only valid on C++ code if (!mTokenizer->isCPP()) return; - if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("cstyleCast")) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("dangerousTypeCast")) return; logChecker("CheckOther::warningDangerousTypeCast"); // warning,c++ diff --git a/lib/settings.cpp b/lib/settings.cpp index 8e4b8d2a6d4..305af5a143c 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -354,7 +354,6 @@ static const std::set autosarCheckers{ "bufferAccessOutOfBounds", "comparePointers", "constParameter", - "cstyleCast", "ctuOneDefinitionRuleViolation", "doubleFree", "duplInheritedMember", @@ -396,7 +395,6 @@ static const std::set autosarCheckers{ "unsignedLessThanZero", "unusedFunction", "unusedStructMember", - "unusedValue", "unusedVariable", "useInitializationList", "variableScope", @@ -459,6 +457,14 @@ static const std::set certCCheckers{ static const std::set certCppCheckers{ "IOWithoutPositioning", "accessMoved", + "argumentSize", + "arrayIndexOutOfBounds", + "arrayIndexOutOfBoundsCond", + "arrayIndexThenCheck", + "autoVariables", + "autovarInvalidDeallocation", + "bitwiseOnBoolean", + "bufferAccessOutOfBounds", "comparePointers", "containerOutOfBounds", "ctuOneDefinitionRuleViolation", @@ -466,25 +472,50 @@ static const std::set certCppCheckers{ "danglingReference", "danglingTempReference", "danglingTemporaryLifetime", - "deallocThrow", + "deallocret", "deallocuse", "doubleFree", "eraseDereference", + "exceptDeallocThrow", "exceptThrowInDestructor", + "floatConversionOverflow", "initializerList", + "integerOverflow", "invalidContainer", + "invalidFunctionArg", + "invalidLengthModifierError", + "invalidLifetime", + "invalidScanfFormatWidth", + "invalidscanf", + "leakReturnValNotUsed", + "leakUnsafeArgAlloc", "memleak", + "memleakOnRealloc", "mismatchAllocDealloc", "missingReturn", + "negativeIndex", "nullPointer", + "nullPointerArithmetic", + "nullPointerArithmeticRedundantCheck", + "nullPointerDefaultArg", + "nullPointerRedundantCheck", + "objectIndex", "operatorEqToSelf", + "pointerOutOfBounds", + "pointerOutOfBoundsCond", + "preprocessorErrorDirective", + "resourceLeak", "returnDanglingLifetime", "sizeofCalculation", + "stringLiteralWrite", "uninitStructMember", "uninitdata", "uninitvar", + "useClosedFile", "virtualCallInConstructor", - "virtualDestructor" + "virtualDestructor", + "wrongPrintfScanfArgNum", + "wrongPrintfScanfParameterPositionError" }; static const std::set misrac2012Checkers{ @@ -524,6 +555,7 @@ static const std::set misrac2012Checkers{ "unknownEvaluationOrder", "unreachableCode", "unreadVariable", + "unusedFunction", "unusedLabel", "unusedVariable", "useClosedFile", @@ -567,6 +599,7 @@ static const std::set misrac2023Checkers{ "unknownEvaluationOrder", "unreachableCode", "unreadVariable", + "unusedFunction", "unusedLabel", "unusedVariable", "useClosedFile", @@ -610,6 +643,7 @@ static const std::set misrac2025Checkers{ "unknownEvaluationOrder", "unreachableCode", "unreadVariable", + "unusedFunction", "unusedLabel", "unusedVariable", "useClosedFile", @@ -623,6 +657,7 @@ static const std::set misracpp2008Checkers{ "constVariable", "cstyleCast", "ctuOneDefinitionRuleViolation", + "dangerousTypeCast", "danglingLifetime", "duplInheritedMember", "duplicateBreak", From 6293b2c5886cd16b8f358d19a91a7dec5088a1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Wed, 25 Feb 2026 21:11:44 +0100 Subject: [PATCH 173/675] improved `--debug-analyzerinfo` output (#8255) --- lib/analyzerinfo.cpp | 48 +++++++++++++------------------- lib/analyzerinfo.h | 2 +- test/cli/other_test.py | 17 +++++------ test/testanalyzerinformation.cpp | 44 ++++++++++++++++++++++++----- 4 files changed, 66 insertions(+), 45 deletions(-) diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index d484f7d50a9..30a6910eef4 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -83,32 +83,20 @@ void AnalyzerInformation::close() } } -bool AnalyzerInformation::skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors, bool debug) +std::string AnalyzerInformation::skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors) { const tinyxml2::XMLElement * const rootNode = analyzerInfoDoc.FirstChildElement(); - if (rootNode == nullptr) { - if (debug) - std::cout << "discarding cached result - no root node found" << std::endl; - return false; - } + if (rootNode == nullptr) + return "no root node found"; - if (strcmp(rootNode->Name(), "analyzerinfo") != 0) { - if (debug) - std::cout << "discarding cached result - unexpected root node" << std::endl; - return false; - } + if (strcmp(rootNode->Name(), "analyzerinfo") != 0) + return "unexpected root node"; const char * const attr = rootNode->Attribute("hash"); - if (!attr) { - if (debug) - std::cout << "discarding cached result - no 'hash' attribute found" << std::endl; - return false; - } - if (attr != std::to_string(hash)) { - if (debug) - std::cout << "discarding cached result - hash mismatch" << std::endl; - return false; - } + if (!attr) + return "no 'hash' attribute found"; + if (attr != std::to_string(hash)) + return "hash mismatch"; for (const tinyxml2::XMLElement *e = rootNode->FirstChildElement(); e; e = e->NextSiblingElement()) { if (std::strcmp(e->Name(), "error") != 0) @@ -125,17 +113,15 @@ bool AnalyzerInformation::skipAnalysis(const tinyxml2::XMLDocument &analyzerInfo { // cppcheck-suppress useStlAlgorithm if (e->Attribute("id", id)) { - if (debug) - std::cout << "discarding cached result - '" << id << "' encountered" << std::endl; errors.clear(); - return false; + return std::string("'") + id + "' encountered"; } } errors.emplace_back(e); } - return true; + return ""; } std::string AnalyzerInformation::getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fsFileId) @@ -184,18 +170,22 @@ bool AnalyzerInformation::analyzeFile(const std::string &buildDir, const std::st tinyxml2::XMLDocument analyzerInfoDoc; const tinyxml2::XMLError xmlError = analyzerInfoDoc.LoadFile(analyzerInfoFile.c_str()); if (xmlError == tinyxml2::XML_SUCCESS) { - if (skipAnalysis(analyzerInfoDoc, hash, errors, debug)) { + const std::string err = skipAnalysis(analyzerInfoDoc, hash, errors); + if (err.empty()) { if (debug) - std::cout << "skipping analysis - loaded " << errors.size() << " cached finding(s) from '" << analyzerInfoFile << "'" << std::endl; + std::cout << "skipping analysis - loaded " << errors.size() << " cached finding(s) from '" << analyzerInfoFile << "' for '" << sourcefile << "'" << std::endl; return false; } + if (debug) { + std::cout << "discarding cached result from '" << analyzerInfoFile << "' for '" << sourcefile << "' - " << err << std::endl; + } } else if (xmlError != tinyxml2::XML_ERROR_FILE_NOT_FOUND) { if (debug) - std::cout << "discarding cached result - failed to load '" << analyzerInfoFile << "' (" << tinyxml2::XMLDocument::ErrorIDToName(xmlError) << ")" << std::endl; + std::cout << "discarding cached result - failed to load '" << analyzerInfoFile << "' for '" << sourcefile << "' (" << tinyxml2::XMLDocument::ErrorIDToName(xmlError) << ")" << std::endl; } else if (debug) - std::cout << "no cached result '" << analyzerInfoFile << "' found" << std::endl; + std::cout << "no cached result '" << analyzerInfoFile << "' for '" << sourcefile << "' found" << std::endl; } mOutputStream.open(analyzerInfoFile); diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 5435be62560..e2830bfbcb1 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -87,7 +87,7 @@ class CPPCHECKLIB AnalyzerInformation { static std::string getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, int fsFileId); - static bool skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors, bool debug = false); + static std::string skipAnalysis(const tinyxml2::XMLDocument &analyzerInfoDoc, std::size_t hash, std::list &errors); private: std::ofstream mOutputStream; diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 5a6662faf56..1a80b06d929 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -4176,16 +4176,17 @@ def run_and_assert_cppcheck(stdout_exp): assert stdout.splitlines() == stdout_exp assert stderr.splitlines() == stderr_exp + test_file_s = str(test_file).replace('\\', '/') test_a1_file_s = str(test_a1_file).replace('\\', '/') # no cached results run_and_assert_cppcheck([ - "no cached result '{}' found".format(test_a1_file_s) + "no cached result '{}' for '{}' found".format(test_a1_file_s, test_file_s) ]) # cached results run_and_assert_cppcheck([ - "skipping analysis - loaded 1 cached finding(s) from '{}'".format(test_a1_file_s) + "skipping analysis - loaded 1 cached finding(s) from '{}' for '{}'".format(test_a1_file_s, test_file_s) ]) # modified file @@ -4193,7 +4194,7 @@ def run_and_assert_cppcheck(stdout_exp): f.write('\n#define DEF') run_and_assert_cppcheck([ - "discarding cached result - hash mismatch" # TODO: add filename + "discarding cached result from '{}' for '{}' - hash mismatch".format(test_a1_file_s, test_file_s) ]) # invalid XML @@ -4201,7 +4202,7 @@ def run_and_assert_cppcheck(stdout_exp): f.write('.') run_and_assert_cppcheck([ - "discarding cached result - failed to load '{}' (XML_ERROR_PARSING_TEXT)".format(test_a1_file_s) + "discarding cached result - failed to load '{}' for '{}' (XML_ERROR_PARSING_TEXT)".format(test_a1_file_s, test_file_s) ]) # missing root node @@ -4209,7 +4210,7 @@ def run_and_assert_cppcheck(stdout_exp): f.write('') run_and_assert_cppcheck([ - "discarding cached result - no root node found" # TODO: add filename + "discarding cached result from '{}' for '{}' - no root node found".format(test_a1_file_s, test_file_s) ]) # mismatched root node @@ -4217,7 +4218,7 @@ def run_and_assert_cppcheck(stdout_exp): f.write('') run_and_assert_cppcheck([ - "discarding cached result - unexpected root node" # TODO: add filename + "discarding cached result from '{}' for '{}' - unexpected root node".format(test_a1_file_s, test_file_s) ]) # missing 'hash' attribute @@ -4225,7 +4226,7 @@ def run_and_assert_cppcheck(stdout_exp): f.write('') run_and_assert_cppcheck([ - "discarding cached result - no 'hash' attribute found" # TODO: add filename + "discarding cached result from '{}' for '{}' - no 'hash' attribute found".format(test_a1_file_s, test_file_s) ]) # invalid 'hash' attribute @@ -4233,7 +4234,7 @@ def run_and_assert_cppcheck(stdout_exp): f.write('') run_and_assert_cppcheck([ - "discarding cached result - hash mismatch" # TODO: add filename + "discarding cached result from '{}' for '{}' - hash mismatch".format(test_a1_file_s, test_file_s) ]) # TODO: diff --git a/test/testanalyzerinformation.cpp b/test/testanalyzerinformation.cpp index a92a8c37b1a..22f868ffb1d 100644 --- a/test/testanalyzerinformation.cpp +++ b/test/testanalyzerinformation.cpp @@ -126,7 +126,7 @@ class TestAnalyzerInformation : public TestFixture { ); ASSERT_EQUALS(tinyxml2::XML_SUCCESS, xmlError); - ASSERT_EQUALS(false, AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); + ASSERT_EQUALS("'premium-invalidLicense' encountered", AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); ASSERT_EQUALS(0, errorList.size()); } @@ -145,7 +145,7 @@ class TestAnalyzerInformation : public TestFixture { ); ASSERT_EQUALS(tinyxml2::XML_SUCCESS, xmlError); - ASSERT_EQUALS(false, AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); + ASSERT_EQUALS("'premium-internalError' encountered", AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); ASSERT_EQUALS(0, errorList.size()); } @@ -164,7 +164,7 @@ class TestAnalyzerInformation : public TestFixture { ); ASSERT_EQUALS(tinyxml2::XML_SUCCESS, xmlError); - ASSERT_EQUALS(false, AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); + ASSERT_EQUALS("'internalError' encountered", AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); ASSERT_EQUALS(0, errorList.size()); } @@ -185,7 +185,7 @@ class TestAnalyzerInformation : public TestFixture { ); ASSERT_EQUALS(tinyxml2::XML_SUCCESS, xmlError); - ASSERT_EQUALS(true, AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); + ASSERT_EQUALS("", AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); ASSERT_EQUALS(1, errorList.size()); } @@ -201,7 +201,7 @@ class TestAnalyzerInformation : public TestFixture { ); ASSERT_EQUALS(tinyxml2::XML_SUCCESS, xmlError); - ASSERT_EQUALS(true, AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); + ASSERT_EQUALS("", AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); ASSERT_EQUALS(0, errorList.size()); } @@ -222,7 +222,7 @@ class TestAnalyzerInformation : public TestFixture { ); ASSERT_EQUALS(tinyxml2::XML_SUCCESS, xmlError); - ASSERT_EQUALS(false, AnalyzerInformationTest::skipAnalysis(doc, 99, errorList)); + ASSERT_EQUALS("hash mismatch", AnalyzerInformationTest::skipAnalysis(doc, 99, errorList)); ASSERT_EQUALS(0, errorList.size()); } @@ -234,7 +234,37 @@ class TestAnalyzerInformation : public TestFixture { const tinyxml2::XMLError xmlError = doc.Parse(""); ASSERT_EQUALS(tinyxml2::XML_ERROR_EMPTY_DOCUMENT, xmlError); - ASSERT_EQUALS(false, AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); + ASSERT_EQUALS("no root node found", AnalyzerInformationTest::skipAnalysis(doc, 100, errorList)); + ASSERT_EQUALS(0, errorList.size()); + } + + // Unexpected root node + { + std::list errorList; + tinyxml2::XMLDocument doc; + + const tinyxml2::XMLError xmlError = doc.Parse( + "" + "" + ); + ASSERT_EQUALS(tinyxml2::XML_SUCCESS, xmlError); + + ASSERT_EQUALS("unexpected root node", AnalyzerInformationTest::skipAnalysis(doc, 99, errorList)); + ASSERT_EQUALS(0, errorList.size()); + } + + // No 'hash' attribute found + { + std::list errorList; + tinyxml2::XMLDocument doc; + + const tinyxml2::XMLError xmlError = doc.Parse( + "" + "" + ); + ASSERT_EQUALS(tinyxml2::XML_SUCCESS, xmlError); + + ASSERT_EQUALS("no 'hash' attribute found", AnalyzerInformationTest::skipAnalysis(doc, 99, errorList)); ASSERT_EQUALS(0, errorList.size()); } } From 64abf204eb362a32c15ce886d9a0a80b38e42135 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 25 Feb 2026 21:27:32 +0100 Subject: [PATCH 174/675] Fix #12724 FN: resourceLeak (allocation result in variable, regression) (#8215) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: chrchr-github Co-authored-by: Daniel Marjamäki --- lib/checkleakautovar.cpp | 103 ++++++++++++++++++++++----------------- test/testleakautovar.cpp | 8 +++ 2 files changed, 67 insertions(+), 44 deletions(-) diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 0ff4bcd8931..148bd43c689 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -295,6 +295,18 @@ static const Token* getReturnValueFromOutparamAlloc(const Token* alloc, const Se return nullptr; } +static std::vector getComparisonTokens(const Token* tok) +{ + std::vector result{ tok }; + if (tok->hasKnownValue(ValueFlow::Value::ValueType::SYMBOLIC)) + result.push_back(tok->getKnownValue(ValueFlow::Value::ValueType::SYMBOLIC)->tokvalue); + for (const Token* op : { tok->astOperand1(), tok->astOperand2() }) { + if (op && op->hasKnownValue(ValueFlow::Value::ValueType::SYMBOLIC)) + result.push_back(op->getKnownValue(ValueFlow::Value::ValueType::SYMBOLIC)->tokvalue); + } + return result; +} + bool CheckLeakAutoVar::checkScope(const Token * const startToken, VarInfo &varInfo, std::set notzero, @@ -444,7 +456,7 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken, if (tok2->str() == ";") { break; } - if (tok2->varId()) { + if (tok2->varId() && !Token::Match(tok2->astParent(), "%comp%|!")) { varInfo.erase(tok2->varId()); } } @@ -578,53 +590,56 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken, astOperand2AfterCommas = astOperand2AfterCommas->astOperand2(); // Recursively scan variable comparisons in condition - visitAstNodes(astOperand2AfterCommas, [&](const Token *tok3) { - if (!tok3) - return ChildrenToVisit::none; - if (tok3->str() == "&&" || tok3->str() == "||") { - // FIXME: handle && ! || better - return ChildrenToVisit::op1_and_op2; - } - if (tok3->str() == "(" && Token::Match(tok3->astOperand1(), "UNLIKELY|LIKELY")) { - return ChildrenToVisit::op2; - } - if (tok3->str() == "(" && tok3->previous()->isName()) { - const std::vector params = getArguments(tok3->previous()); - for (const Token *par : params) { - if (!par->isComparisonOp()) - continue; - const Token *vartok = nullptr; - if (isVarTokComparison(par, &vartok, alloc_success_conds) || - (isVarTokComparison(par, &vartok, alloc_failed_conds))) { - varInfo1.erase(vartok->varId()); - varInfo2.erase(vartok->varId()); + for (const Token* compTok : getComparisonTokens(astOperand2AfterCommas)) { + visitAstNodes(compTok, [&](const Token* tok3) { + if (!tok3) + return ChildrenToVisit::none; + if (tok3->str() == "&&" || tok3->str() == "||") { + // FIXME: handle && ! || better + return ChildrenToVisit::op1_and_op2; + } + if (tok3->str() == "(" && Token::Match(tok3->astOperand1(), "UNLIKELY|LIKELY")) { + return ChildrenToVisit::op2; + } + if (tok3->str() == "(" && tok3->previous()->isName()) { + const std::vector params = getArguments(tok3->previous()); + for (const Token* par : params) { + if (!par->isComparisonOp()) + continue; + const Token* vartok = nullptr; + if (isVarTokComparison(par, &vartok, alloc_success_conds) || + (isVarTokComparison(par, &vartok, alloc_failed_conds))) { + varInfo1.erase(vartok->varId()); + varInfo2.erase(vartok->varId()); + } } + return ChildrenToVisit::none; } - return ChildrenToVisit::none; - } - const Token *vartok = nullptr; - if (isVarTokComparison(tok3, &vartok, alloc_success_conds)) { - varInfo2.reallocToAlloc(vartok->varId()); - varInfo2.erase(vartok->varId()); - if (astIsVariableComparison(tok3, "!=", "0", &vartok) && - (notzero.find(vartok->varId()) != notzero.end())) - varInfo2.clear(); - - if (std::any_of(varInfo1.alloctype.begin(), varInfo1.alloctype.end(), [&](const std::pair& info) { - if (info.second.status != VarInfo::ALLOC) - return false; - const Token* ret = getReturnValueFromOutparamAlloc(info.second.allocTok, *mSettings); - return ret && vartok && ret->varId() && ret->varId() == vartok->varId(); - })) { - varInfo1.clear(); + const Token* vartok = nullptr; + if (isVarTokComparison(tok3, &vartok, alloc_success_conds)) { + varInfo2.reallocToAlloc(vartok->varId()); + varInfo2.erase(vartok->varId()); + if (astIsVariableComparison(tok3, "!=", "0", &vartok) && + (notzero.find(vartok->varId()) != notzero.end())) + varInfo2.clear(); + + if (std::any_of(varInfo1.alloctype.begin(), varInfo1.alloctype.end(), [&](const std::pair& info) { + if (info.second.status != VarInfo::ALLOC) + return false; + const Token* ret = getReturnValueFromOutparamAlloc(info.second.allocTok, *mSettings); + return ret && vartok && ret->varId() && ret->varId() == vartok->varId(); + })) { + varInfo1.clear(); + } } - } else if (isVarTokComparison(tok3, &vartok, alloc_failed_conds)) { - varInfo1.reallocToAlloc(vartok->varId()); - varInfo1.erase(vartok->varId()); - } - return ChildrenToVisit::none; - }); + else if (isVarTokComparison(tok3, &vartok, alloc_failed_conds)) { + varInfo1.reallocToAlloc(vartok->varId()); + varInfo1.erase(vartok->varId()); + } + return ChildrenToVisit::none; + }); + } if (!skipIfBlock && !checkScope(closingParenthesis->next(), varInfo1, notzero, recursiveCount)) { varInfo.clear(); diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 7aa64c1cd3c..d23a655b492 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -641,6 +641,14 @@ class TestLeakAutoVar : public TestFixture { " x = p != nullptr ? p : nullptr;\n" "}", dinit(CheckOptions, $.cpp = true)); ASSERT_EQUALS("", errout_str()); + + check("void f(const char* n) {\n" // #12724 + " FILE* fp = fopen(n, \"r\");\n" + " bool b = (fp == NULL);\n" + " if (b)\n" + " return;\n" + "}\n", dinit(CheckOptions, $.cpp = true)); + ASSERT_EQUALS("[test.cpp:6:1]: (error) Resource leak: fp [resourceLeak]\n", errout_str()); } void memcpy1() { // #11542 From c49dfb6e32f5ddad1b0f33a78665d289d7d55947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 26 Feb 2026 08:59:46 +0100 Subject: [PATCH 175/675] fixed #1059/#14519 - extract configurations for compound preprocessor checks with operators (#8066) --- lib/preprocessor.cpp | 63 ++++++--- test/cfg/std.c | 2 +- test/testpreprocessor.cpp | 280 ++++++++++++++++++++++++++++++++++---- 3 files changed, 300 insertions(+), 45 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 01e3d6f5c74..a028fc5b864 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -22,6 +22,7 @@ #include "errorlogger.h" #include "errortypes.h" #include "library.h" +#include "mathlib.h" #include "path.h" #include "platform.h" #include "settings.h" @@ -420,17 +421,21 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::setname && (next1->str() == "==" || next1->str() == "<=" || next1->str() == ">=") && next2->number) { if (defined.find(cond->str()) == defined.end()) - return cond->str() + '=' + cond->next->next->str(); + return cond->str() + '=' + next1->next->str(); } + const auto lessGreaterThanConfig = [](const simplecpp::Token* dtok, const simplecpp::Token* ctok) { + auto v = MathLib::toBigNumber(ctok->next->str()); + if (ctok->op == '<') + v -= 1; + else + v += 1; + return dtok->str() + '=' + std::to_string(v); + }; + if (len == 3 && cond->name && (next1->op == '<' || next1->op == '>') && next2->number) { if (defined.find(cond->str()) == defined.end()) { - int v = strToInt(cond->next->next->str()); - if (next1->op == '<') - v -= 1; - else - v += 1; - return cond->str() + '=' + std::to_string(v); + return lessGreaterThanConfig(cond, next1); } } @@ -447,22 +452,40 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::setnext->str() + "=0"); continue; } - if (cond->str() != "defined") + if (cond->str() == "==" || cond->str() == "<=" || cond->str() == ">=") { + if (cond->next->number) { + const simplecpp::Token *dtok = cond->previous; + if (sameline(iftok,dtok) && dtok->name && defined.find(dtok->str()) == defined.end() && undefined.find(dtok->str()) == undefined.end()) + configset.insert(dtok->str() + '=' + cond->next->str()); + } continue; - const simplecpp::Token *dtok = cond->next; - if (!dtok) - break; - if (dtok->op == '(') - dtok = dtok->next; - - if (sameline(iftok,dtok) && dtok->name && defined.find(dtok->str()) == defined.end() && undefined.find(dtok->str()) == undefined.end()) { - if (!isNotDefinedMacro) { - configset.insert(dtok->str() + "=" + dtok->str()); // if defined is set to itself. - } else { - configset.insert(dtok->str()); + } + if (cond->op == '<' || cond->op == '>') { + if (cond->next->number) { + const simplecpp::Token *dtok = cond->previous; + if (sameline(iftok,dtok) && dtok->name && defined.find(dtok->str()) == defined.end() && undefined.find(dtok->str()) == undefined.end()) { + configset.insert(lessGreaterThanConfig(dtok, cond)); + } } + continue; + } + if (cond->str() == "defined") { + const simplecpp::Token *dtok = cond->next; + if (!dtok) + break; + if (dtok->op == '(') + dtok = dtok->next; + + if (sameline(iftok,dtok) && dtok->name && defined.find(dtok->str()) == defined.end() && undefined.find(dtok->str()) == undefined.end()) { + if (!isNotDefinedMacro) { + configset.insert(dtok->str() + "=" + dtok->str()); // if defined is set to itself. + } else { + configset.insert(dtok->str()); + } + isNotDefinedMacro = false; + } + continue; } - isNotDefinedMacro = false; } std::string cfgStr; for (const std::string &s : configset) { diff --git a/test/cfg/std.c b/test/cfg/std.c index adc147c2333..af0b30e03b2 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -7,7 +7,7 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // -// cppcheck-suppress-file valueFlowBailout +// cppcheck-suppress-file [valueFlowBailout,purgedConfiguration] #include #include diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index c53fed82e01..0f22a1fbca7 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -319,10 +319,15 @@ class TestPreprocessor : public TestFixture { TEST_CASE(getConfigs11); // #9832 - include guards TEST_CASE(getConfigs12); // #14222 TEST_CASE(getConfigs13); // #14222 - TEST_CASE(getConfigs14); // #1059 - TEST_CASE(getConfigs15); // #1059 - TEST_CASE(getConfigs16); // #1059 - TEST_CASE(getConfigs17); // #1059 + TEST_CASE(getConfigs_gte); // #1059 + TEST_CASE(getConfigs_lte); // #1059 + TEST_CASE(getConfigs_gt); // #1059 + TEST_CASE(getConfigs_lt); // #1059 + TEST_CASE(getConfigs_eq_compound); // #1059 + TEST_CASE(getConfigs_gte_compound); // #1059 + TEST_CASE(getConfigs_lte_compound); // #1059 + TEST_CASE(getConfigs_gt_compound); // #1059 + TEST_CASE(getConfigs_lt_compound); // #1059 TEST_CASE(getConfigsError); TEST_CASE(getConfigsD1); @@ -2331,32 +2336,259 @@ class TestPreprocessor : public TestFixture { ASSERT_EQUALS("\n", getConfigsStr(filedata, nullptr, "gnu.cfg")); } - void getConfigs14() { // #1059 - const char filedata[] = "#if A >= 1\n" - "1\n" - "#endif\n"; - ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata)); + void getConfigs_gte() { // #1059 + { + const char filedata[] = "#if A >= 1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A >= 201112L\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=201112L\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A >= 12147483647\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=12147483647\n", getConfigsStr(filedata)); + } } - void getConfigs15() { // #1059 - const char filedata[] = "#if A <= 1\n" - "1\n" - "#endif\n"; - ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata)); + void getConfigs_lte() { // #1059 + { + const char filedata[] = "#if A <= 1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=1\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A <= 201112L\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=201112L\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A <= 12147483647\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=12147483647\n", getConfigsStr(filedata)); + } } - void getConfigs16() { // #1059 - const char filedata[] = "#if A > 1\n" - "1\n" - "#endif\n"; - ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + void getConfigs_gt() { // #1059 + { + const char filedata[] = "#if A > 1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 1L\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 1U\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 1UL\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 1Z\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 0x1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 01\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 0b1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 1t\n" + "1\n" + "#endif\n"; + ASSERT_THROW_INTERNAL_EQUALS(getConfigsStr(filedata), INTERNAL, "Internal Error. MathLib::toBigNumber: input was not completely consumed: 1t"); + } + { + const char filedata[] = "#if A > 1.0\n" + "1\n" + "#endif\n"; + TODO_ASSERT_THROW(getConfigsStr(filedata), InternalError); // floating point literals are not allowed + } + { + const char filedata[] = "#if A > 12147483647\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=12147483648\n", getConfigsStr(filedata)); + } } - void getConfigs17() { // #1059 - const char filedata[] = "#if A < 1\n" - "1\n" - "#endif\n"; - ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + void getConfigs_lt() { // #1059 + { + const char filedata[] = "#if A < 1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 1L\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 1U\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 1UL\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 1Z\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 0x1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 01\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 0b1\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 1t\n" + "1\n" + "#endif\n"; + ASSERT_THROW_INTERNAL_EQUALS(getConfigsStr(filedata), INTERNAL, "Internal Error. MathLib::toBigNumber: input was not completely consumed: 1t"); + } + { + const char filedata[] = "#if A < 1.0\n" + "1\n" + "#endif\n"; + TODO_ASSERT_THROW(getConfigsStr(filedata), InternalError); // floating point literals are not allowed + } + { + const char filedata[] = "#if A < 12147483647\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=12147483646\n", getConfigsStr(filedata)); + } + } + + void getConfigs_eq_compound() { // #1059 + { + const char filedata[] = "#if A == 1 && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=1;B=B\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A == 201112L && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=201112L;B=B\n", getConfigsStr(filedata)); + } + } + + void getConfigs_gte_compound() { // #1059 + { + const char filedata[] = "#if A >= 1 && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=1;B=B\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A >= 201112L && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=201112L;B=B\n", getConfigsStr(filedata)); + } + } + + void getConfigs_lte_compound() { // #1059 + { + const char filedata[] = "#if A <= 1 && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=1;B=B\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A <= 201112L && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=201112L;B=B\n", getConfigsStr(filedata)); + } + } + + void getConfigs_gt_compound() { // #1059 + { + const char filedata[] = "#if A > 1 && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=2;B=B\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A > 201112L && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=201113;B=B\n", getConfigsStr(filedata)); + } + } + + void getConfigs_lt_compound() { // #1059 + { + const char filedata[] = "#if A < 1 && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=0;B=B\n", getConfigsStr(filedata)); + } + { + const char filedata[] = "#if A < 201112L && defined(B)\n" + "1\n" + "#endif\n"; + ASSERT_EQUALS("\nA=201111;B=B\n", getConfigsStr(filedata)); + } } void getConfigsError() { From a54b894f1fed4f004b30e6fbda6da6f0d67d76ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 26 Feb 2026 09:02:18 +0100 Subject: [PATCH 176/675] fixed #13050 - deprecated CMake option `BUILD_TESTS` in favor of `BUILD_TESTING` (#8235) --- .github/workflows/CI-unixish-docker.yml | 2 +- .github/workflows/CI-unixish.yml | 38 ++++++++++++------------- .github/workflows/CI-windows.yml | 8 +++--- .github/workflows/asan.yml | 2 +- .github/workflows/clang-tidy.yml | 2 +- .github/workflows/iwyu.yml | 4 +-- .github/workflows/release-windows.yml | 2 +- .github/workflows/selfcheck.yml | 12 ++++---- .github/workflows/tsan.yml | 2 +- .github/workflows/ubsan.yml | 2 +- CMakeLists.txt | 7 ++--- cmake/findDependencies.cmake | 2 +- cmake/options.cmake | 13 ++++++++- cmake/printInfo.cmake | 3 +- gui/CMakeLists.txt | 2 +- readme.md | 2 +- releasenotes.txt | 1 + test/CMakeLists.txt | 2 +- 18 files changed, 58 insertions(+), 48 deletions(-) diff --git a/.github/workflows/CI-unixish-docker.yml b/.github/workflows/CI-unixish-docker.yml index a73218a05e3..a457799a92b 100644 --- a/.github/workflows/CI-unixish-docker.yml +++ b/.github/workflows/CI-unixish-docker.yml @@ -57,7 +57,7 @@ jobs: - name: Run CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: CMake build (with GUI) run: | diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 6a7dad5fc9a..65e5c423ebc 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -58,13 +58,13 @@ jobs: - name: CMake build on ubuntu (with GUI / system tinyxml2) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: CMake build on macos (with GUI / system tinyxml2) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: Run CMake test (system tinyxml2) @@ -127,12 +127,12 @@ jobs: - name: Run CMake on ubuntu (with GUI) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install + cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install - name: Run CMake on macos (with GUI) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 - name: Run CMake build run: | @@ -154,13 +154,13 @@ jobs: - name: Run CMake on ubuntu (no CLI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli -G "Unix Makefiles" -DBUILD_CLI=Off + cmake -S . -B cmake.output_nocli -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off - name: Run CMake on ubuntu (no CLI / with tests) if: matrix.os == 'ubuntu-22.04' run: | # the test and CLI code are too intertwined so for now we need to reject that - if cmake -S . -B cmake.output_nocli_tests -G "Unix Makefiles" -DBUILD_TESTS=On -DBUILD_CLI=Off; then + if cmake -S . -B cmake.output_nocli_tests -G "Unix Makefiles" -DBUILD_TESTING=On -DBUILD_CLI=Off; then exit 1 else exit 0 @@ -169,18 +169,18 @@ jobs: - name: Run CMake on ubuntu (no CLI / with GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli_gui -G "Unix Makefiles" -DBUILD_CLI=Off -DBUILD_GUI=On + cmake -S . -B cmake.output_nocli_gui -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=On - name: Run CMake on ubuntu (no GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nogui -G "Unix Makefiles" -DBUILD_GUI=Off + cmake -S . -B cmake.output_nogui -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off - name: Run CMake on ubuntu (no GUI / with triage) if: matrix.os == 'ubuntu-22.04' run: | # cannot build triage without GUI - if cmake -S . -B cmake.output_nogui_triage -G "Unix Makefiles" -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then + if cmake -S . -B cmake.output_nogui_triage -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then exit 1 else exit 0 @@ -189,7 +189,7 @@ jobs: - name: Run CMake on ubuntu (no CLI / no GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli_nogui -G "Unix Makefiles" -DBUILD_GUI=Off + cmake -S . -B cmake.output_nocli_nogui -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off build_cmake_cxxstd: @@ -243,12 +243,12 @@ jobs: - name: Run CMake on ubuntu (with GUI) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Run CMake on macos (with GUI) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 - name: Run CMake build run: | @@ -373,7 +373,7 @@ jobs: run: | # make sure we fail when Boost is requested and not available. # will fail because no package configuration is available. - if cmake -S . -B cmake.output.boost-force-noavail -G "Unix Makefiles" -DUSE_BOOST=On; then + if cmake -S . -B cmake.output.boost-force-noavail -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On; then exit 1 else exit 0 @@ -386,12 +386,12 @@ jobs: - name: Run CMake on macOS (force Boost) run: | - cmake -S . -B cmake.output.boost-force -G "Unix Makefiles" -DUSE_BOOST=On + cmake -S . -B cmake.output.boost-force -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On - name: Run CMake on macOS (no Boost) run: | # make sure Boost is not used when disabled even though it is available - cmake -S . -B cmake.output.boost-no -G "Unix Makefiles" -DUSE_BOOST=Off + cmake -S . -B cmake.output.boost-no -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=Off if grep -q '\-DHAVE_BOOST' ./cmake.output.boost-no/compile_commands.json; then exit 1 else @@ -400,7 +400,7 @@ jobs: - name: Run CMake on macOS (with Boost) run: | - cmake -S . -B cmake.output.boost -G "Unix Makefiles" -DBUILD_TESTS=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output.boost -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache grep -q '\-DHAVE_BOOST' ./cmake.output.boost/compile_commands.json - name: Build with CMake on macOS (with Boost) @@ -560,7 +560,7 @@ jobs: - name: Test Signalhandler run: | - cmake -S . -B build.cmake.signal -G "Unix Makefiles" -DBUILD_TESTS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On + cmake -S . -B build.cmake.signal -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On cmake --build build.cmake.signal --target test-signalhandler -- -j$(nproc) # TODO: how to run this without copying the file? cp build.cmake.signal/bin/test-s* . @@ -571,7 +571,7 @@ jobs: - name: Test Stacktrace if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B build.cmake.stack -G "Unix Makefiles" -DBUILD_TESTS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On + cmake -S . -B build.cmake.stack -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On cmake --build build.cmake.stack --target test-stacktrace -- -j$(nproc) # TODO: how to run this without copying the file? cp build.cmake.stack/bin/test-s* . @@ -685,7 +685,7 @@ jobs: - name: CMake run: | - cmake -S . -B cmake.output -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On + cmake -S . -B cmake.output -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On - name: Generate dependencies run: | diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index 2b08f18bbf5..d8f2bc7e4d9 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -53,7 +53,7 @@ jobs: run: | rem TODO: enable rules? rem specify Release build so matchcompiler is used - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DBUILD_ONLINE_HELP=On -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DBUILD_TESTING=Off -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DBUILD_ONLINE_HELP=On -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! - name: Build GUI release run: | @@ -92,7 +92,7 @@ jobs: - name: Run CMake run: | - cmake -S . -B build.cxxstd -G "Visual Studio 17 2022" -A x64 -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake -S . -B build.cxxstd -G "Visual Studio 17 2022" -A x64 -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! - name: Build run: | @@ -150,7 +150,7 @@ jobs: 7z x pcre-%PCRE_VERSION%.zip || exit /b !errorlevel! cd pcre-%PCRE_VERSION% || exit /b !errorlevel! git apply --ignore-space-change ..\externals\pcre.patch || exit /b !errorlevel! - cmake . -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DPCRE_BUILD_PCRECPP=Off -DPCRE_BUILD_TESTS=Off -DPCRE_BUILD_PCREGREP=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake . -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DPCRE_BUILD_PCRECPP=Off -DPCRE_BUILD_TESTING=Off -DPCRE_BUILD_PCREGREP=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! nmake || exit /b !errorlevel! copy pcre.h ..\externals || exit /b !errorlevel! copy pcre.lib ..\externals\pcre64.lib || exit /b !errorlevel! @@ -230,7 +230,7 @@ jobs: - name: Test SEH wrapper if: matrix.config == 'release' run: | - cmake -S . -B build.cmake.seh -DBUILD_TESTS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake -S . -B build.cmake.seh -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! cmake --build build.cmake.seh --target test-sehwrapper || exit /b !errorlevel! :: TODO: how to run this without copying the file? copy build.cmake.seh\bin\Debug\test-sehwrapper.exe . || exit /b !errorlevel! diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 1b7de3e7001..c52dc70420a 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -74,7 +74,7 @@ jobs: - name: CMake run: | - cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=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 + cmake -S . -B cmake.output -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-22 CXX: clang++-22 diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 5d7445f34b5..66528e96e52 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -61,7 +61,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=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 -DWARNINGS_ARE_ERRORS=On + cmake -S . -B cmake.output -G "Unix Makefiles" -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 -DWARNINGS_ARE_ERRORS=On env: CC: clang-22 CXX: clang++-22 diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 9b25be2cffa..6af371d035b 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -128,7 +128,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=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.stdlib == 'libc++' }} + cmake -S . -B cmake.output -G "Unix Makefiles" -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.stdlib == 'libc++' }} env: CC: clang CXX: clang++ @@ -236,7 +236,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=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 }} + cmake -S . -B cmake.output -G "Unix Makefiles" -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-22 CXX: clang++-22 diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 2836000acc5..07a52f27fdc 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -79,7 +79,7 @@ jobs: run: | :: TODO: enable rules? :: specify Release build so matchcompiler is used - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On -DUSE_BOOST=ON -DBOOST_INCLUDEDIR=%GITHUB_WORKSPACE%\boost -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=Off -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On -DUSE_BOOST=ON -DBOOST_INCLUDEDIR=%GITHUB_WORKSPACE%\boost -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! cmake --build build --target cppcheck-gui --config Release || exit /b !errorlevel! # TODO: package PDBs diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index 804de21a0b4..a7af97d89cc 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -64,7 +64,7 @@ jobs: # unusedFunction - start - name: CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=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 + cmake -S . -B cmake.output -G "Unix Makefiles" -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 - name: Generate dependencies run: | @@ -90,7 +90,7 @@ jobs: # unusedFunction notest - start - name: CMake (no test) run: | - cmake -S . -B cmake.output.notest -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_GUI=ON -DBUILD_TRIAGE=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_GUI=ON -DBUILD_TRIAGE=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test) run: | @@ -112,7 +112,7 @@ jobs: # unusedFunction notest nogui - start - name: CMake (no test / no gui) run: | - cmake -S . -B cmake.output.notest_nogui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest_nogui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test / no gui) run: | @@ -131,7 +131,7 @@ jobs: # unusedFunction notest nocli - start - name: CMake (no test / no cli) run: | - cmake -S . -B cmake.output.notest_nocli -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_CLI=Off -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 + cmake -S . -B cmake.output.notest_nocli -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -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 - name: Generate dependencies (no test / no cli) run: | @@ -154,7 +154,7 @@ jobs: # unusedFunction notest nocli nogui - start - name: CMake (no test / no cli / no gui) run: | - cmake -S . -B cmake.output.notest_nocli_nogui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_CLI=Off -DBUILD_GUI=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest_nocli_nogui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test / no cli / no gui) run: | @@ -177,7 +177,7 @@ jobs: - name: CMake (corpus / no test) run: | - cmake -S cppcheck-2.8 -B cmake.output.corpus -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_GUI=ON -DUSE_QT6=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + cmake -S cppcheck-2.8 -B cmake.output.corpus -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_GUI=ON -DUSE_QT6=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 - name: Generate dependencies (corpus) run: | diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml index 0c29d903034..cca77bc9a6c 100644 --- a/.github/workflows/tsan.yml +++ b/.github/workflows/tsan.yml @@ -73,7 +73,7 @@ jobs: - name: CMake run: | - cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=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 + cmake -S . -B cmake.output -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-22 CXX: clang++-22 diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index 7be2c511015..1502babdcdc 100644 --- a/.github/workflows/ubsan.yml +++ b/.github/workflows/ubsan.yml @@ -73,7 +73,7 @@ jobs: - name: CMake run: | - cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=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 + cmake -S . -B cmake.output -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-22 CXX: clang++-22 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3595154f7ae..5f603ae1332 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.14) project(Cppcheck VERSION 2.18.99 LANGUAGES CXX) include(cmake/options.cmake) @@ -11,6 +11,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include(GNUInstallDirs) +include(CTest) include(cmake/compilerCheck.cmake) include(cmake/versions.cmake) @@ -77,10 +78,6 @@ endif() # - Cygwin handling # - MinGW handling -if(BUILD_TESTS) - enable_testing() -endif() - add_custom_target(copy_cfg ALL ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/cfg" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/cfg" diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index 61458ced051..f3d7b0b2fec 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -3,7 +3,7 @@ if(BUILD_GUI) if(WITH_QCHART) list(APPEND qt_components Charts) endif() - if(BUILD_TESTS) + if(BUILD_TESTING) list(APPEND qt_components Test) endif() find_package(Qt6 COMPONENTS ${qt_components} REQUIRED) diff --git a/cmake/options.cmake b/cmake/options.cmake index 7de7cb360f6..0e8da0e3f0b 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -57,13 +57,24 @@ if(BUILD_CORE_DLL AND NOT MSVC) message(FATAL_ERROR "Building of lib as DLL is only supported with Visual Studio") endif() option(BUILD_TESTS "Build tests" OFF) +if(DEFINED BUILD_TESTS) + message(WARNING "BUILD_TESTS has been deprecated and will be removed in Cppcheck 2.22 - please use BUILD_TESTING instead") + if(DEFINED BUILD_TESTING) + message(WARNING "BUILD_TESTS and BUILD_TESTING have been defined at the same time - ignoring BUILD_TESTS") + else() + set(BUILD_TESTING "${BUILD_TESTS}") + endif() +elseif(NOT DEFINED BUILD_TESTING) + # disable tests by default - TODO: remove this + set(BUILD_TESTING OFF) +endif() option(REGISTER_TESTS "Register tests in CTest" ON) option(ENABLE_CHECK_INTERNAL "Enable internal checks" OFF) option(DISABLE_DMAKE "Disable run-dmake dependencies" OFF) option(BUILD_MANPAGE "Enable man target to build manpage" OFF) option(BUILD_CLI "Build the CLI application" ON) -if(NOT BUILD_CLI AND BUILD_TESTS) +if(NOT BUILD_CLI AND BUILD_TESTING) message(FATAL_ERROR "Building the tests requires the CLI to be build as well") endif() diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index 6ea93bed207..97f0f7d2536 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -52,7 +52,8 @@ endif() message(STATUS "LIBXML2_XMLLINT_EXECUTABLE = ${LIBXML2_XMLLINT_EXECUTABLE}") message(STATUS "BUILD_CORE_DLL = ${BUILD_CORE_DLL}") message(STATUS "BUILD_TESTS = ${BUILD_TESTS}") -if(BUILD_TESTS) +message(STATUS "BUILD_TESTING = ${BUILD_TESTING}") +if(BUILD_TESTING) message(STATUS "REGISTER_TESTS = ${REGISTER_TESTS}") endif() message(STATUS "ENABLE_CHECK_INTERNAL = ${ENABLE_CHECK_INTERNAL}") diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 493c6a482d0..d640c341458 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -87,7 +87,7 @@ CheckOptions: add_dependencies(cppcheck-gui run-dmake) endif() - if (BUILD_TESTS) + if (BUILD_TESTING) add_subdirectory(test) endif() endif() diff --git a/readme.md b/readme.md index 72f368b3293..246d2e07c72 100644 --- a/readme.md +++ b/readme.md @@ -71,7 +71,7 @@ For release builds it is recommended that you use: -DUSE_MATCHCOMPILER=ON For building the tests use the flag. --DBUILD_TESTS=ON +-DBUILD_TESTING=ON Using cmake you can generate project files for Visual Studio,XCode,etc. diff --git a/releasenotes.txt b/releasenotes.txt index e288b784a2e..4772418f1f0 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -15,6 +15,7 @@ GUI: Changed interface: - removed CMake option "DISABLE_CRTDBG_MAP_ALLOC" +- CMake option "BUILD_TESTS" has been deprecated and will be removed in Cppcheck 2.22 - use "BUILD_TESTING" instead - Infrastructure & dependencies: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dca02d19194..0462a65216e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -if (BUILD_TESTS) +if (BUILD_TESTING) add_subdirectory(signal) add_subdirectory(seh) From 9c0834be19e199d7b963162285287a861b63162a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 26 Feb 2026 09:07:40 +0100 Subject: [PATCH 177/675] Fix #14530 FP redundantCopyLocalConst with dissimilar types (#8259) Co-authored-by: chrchr-github --- lib/checkother.cpp | 14 +++++++++----- test/testother.cpp | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ac8284bddba..03b8721a345 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3294,9 +3294,11 @@ static bool constructorTakesReference(const Scope * const classScope) static bool isLargeObject(const Variable* var, const Settings& settings) { - return var && !var->isGlobal() && - (!var->type() || !var->type()->classScope || - (var->valueType() && var->valueType()->getSizeOf(settings, ValueType::Accuracy::LowerBound, ValueType::SizeOf::Pointer) > 2 * settings.platform.sizeof_pointer)); + if (!var || var->isGlobal() || !var->valueType()) + return false; + ValueType vt = *var->valueType(); + vt.reference = Reference::None; + return vt.getSizeOf(settings, ValueType::Accuracy::LowerBound, ValueType::SizeOf::Pointer) > 2 * settings.platform.sizeof_pointer; } //--------------------------------------------------------------------------- @@ -3332,13 +3334,15 @@ static bool checkFunctionReturnsRef(const Token* tok, const Settings& settings) return false; } -static bool checkVariableAssignment(const Token* tok, const Settings& settings) +static bool checkVariableAssignment(const Token* tok, const ValueType* vtLhs, const Settings& settings) { if (!Token::Match(tok, "%var% ;")) return false; const Variable* var = tok->variable(); if (!var || !isLargeObject(var, settings)) return false; + if (!vtLhs || !vtLhs->isTypeEqual(var->valueType())) + return false; if (findVariableChanged(tok->tokAt(2), tok->scope()->bodyEnd, /*indirect*/ 0, var->declarationId(), /*globalvar*/ false, settings)) return false; if (var->isLocal() || (var->isArgument() && !var->isReference())) @@ -3381,7 +3385,7 @@ void CheckOther::checkRedundantCopy() const Token* tok = startTok->next()->astOperand2(); if (!tok) continue; - if (!checkFunctionReturnsRef(tok, *mSettings) && !checkVariableAssignment(tok, *mSettings)) + if (!checkFunctionReturnsRef(tok, *mSettings) && !checkVariableAssignment(tok, var->valueType(), *mSettings)) continue; redundantCopyError(startTok, startTok->str()); } diff --git a/test/testother.cpp b/test/testother.cpp index d49d3e540d2..fc7b8df4361 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -9944,6 +9944,21 @@ class TestOther : public TestFixture { "}\n"); ASSERT_EQUALS("[test.cpp:7:17]: (performance, inconclusive) Use const reference for 'c' to avoid unnecessary data copying. [redundantCopyLocalConst]\n", errout_str()); + + check("int f(const char* c) {\n" // #14530 + " std::string s = c;\n" + " return s.rfind('.');\n" + "}\n" + "struct M {\n" + " M(const std::array& a);\n" + " double m[3][3];\n" + " double trace() const;\n" + "};\n" + "double g(const std::array& a) {\n" + " M m = a;\n" + " return m.trace();\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void checkNegativeShift() { From cfcd87470151fadb449819e84910089c3184a24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 26 Feb 2026 10:38:31 +0100 Subject: [PATCH 178/675] fixed some `Variable copied when it could be moved` Coverity warnings (#8265) --- lib/importproject.cpp | 2 +- lib/tokenize.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 9706cd5c6b2..ec0f3c4a97d 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -104,7 +104,7 @@ std::string ImportProject::collectArgs(const std::string &cmd, std::vectorstr() + " "; } - numberOfTypedefs[ts.name()].insert(existing_data_type); + numberOfTypedefs[ts.name()].emplace(std::move(existing_data_type)); continue; } } From 959bfb17ebca29b792db234cd664b75f4dbc4935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 26 Feb 2026 12:06:28 +0100 Subject: [PATCH 179/675] Fix #14543 (createrelease: run coverage.py to update mappings) [skip ci] (#8268) --- createrelease | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/createrelease b/createrelease index e89cd5cdf04..10c4dc92e35 100755 --- a/createrelease +++ b/createrelease @@ -12,6 +12,10 @@ # create jira issue "CI: update cppcheck binary" # cd ~/cppchecksolutions/addon/tools && python3 ci-update-cppcheck.py # +# update mappings.. +# cd ~/cppchecksolutions/addon/coverage +# CPPCHECK_REPO=~/cppchecksolutions/cppcheck python3 coverage.py --code +# # check every isPremiumEnabled call: TODO write helper script # - every id should be in --errorlist # git grep 'isPremiumEnabled[(]"' | sed 's/.*isPremiumEnabled[(]"//' | sed 's/".*//' | sort | uniq > ids1.txt From ff0929af1bfc8b945d38a75919b43b2dbeda9a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 26 Feb 2026 12:07:37 +0100 Subject: [PATCH 180/675] Fix #14482 (False negative: missingReturn not reported for function that returns a std::int32_t) (#8256) --- lib/symboldatabase.cpp | 6 +++++- test/testfunctions.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index c997a907501..d731c2a8884 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3342,8 +3342,12 @@ static bool checkReturns(const Function* function, bool unknown, bool emptyEnabl assert(defEnd != defStart); if (pred(defStart, defEnd)) return true; - if (isUnknownType(defStart, defEnd)) + if (isUnknownType(defStart, defEnd)) { + const Token* tok = function->token ? function->token->next() : function->tokenDef->next(); + if (tok->valueType() && tok->valueType()->type >= ValueType::Type::RECORD) + return false; return unknown; + } return false; } diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 6aa4e6534a2..d353c83aecc 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -86,6 +86,7 @@ class TestFunctions : public TestFixture { TEST_CASE(checkMissingReturn5); TEST_CASE(checkMissingReturn6); // #13180 TEST_CASE(checkMissingReturn7); // #14370 - FN try/catch + TEST_CASE(checkMissingReturnStdInt); // #14482 - FN std::int32_t // std::move for locar variable TEST_CASE(returnLocalStdMove1); @@ -1918,6 +1919,11 @@ class TestFunctions : public TestFixture { ASSERT_EQUALS("[test.cpp:3:19]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str()); } + void checkMissingReturnStdInt() {// #14482 - FN + check("std::int32_t f() {}\n"); + ASSERT_EQUALS("[test.cpp:1:19]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str()); + } + // NRVO check void returnLocalStdMove1() { check("struct A{}; A f() { A var; return std::move(var); }"); From 11c3958e9335152bee7b55ba057eaf29c571021c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 26 Feb 2026 13:59:16 +0100 Subject: [PATCH 181/675] Followup to #14510: constParameterPointer for immediately evaluated lambda (#8252) Co-authored-by: chrchr-github --- lib/checkother.cpp | 2 +- test/testother.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 03b8721a345..fb84001833c 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1869,7 +1869,7 @@ void CheckOther::checkConstPointer() continue; if (!var->isLocal() && !var->isArgument()) continue; - if (var->isArgument() && var->scope() && var->scope()->type == ScopeType::eLambda) + if (var->isArgument() && var->scope() && var->scope()->type == ScopeType::eLambda && !Token::simpleMatch(var->scope()->bodyEnd, "} (")) continue; const Token* const nameTok = var->nameToken(); if (tok == nameTok && var->isLocal() && !astIsRangeBasedForDecl(nameTok)) { diff --git a/test/testother.cpp b/test/testother.cpp index fc7b8df4361..1a0eb713832 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4699,6 +4699,12 @@ class TestOther : public TestFixture { " x();\n" "}\n"); ASSERT_EQUALS("[test.cpp:3:27]: (style) Variable 'p' can be declared as pointer to const [constVariablePointer]\n", errout_str()); + + check("int f() {\n" + " int i = 0;\n" + " return [](int* p) { return *p; }(&i);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:20]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str()); } void constArray() { From f04dccd3d31313fd4d5930dffd8febcb91d39e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 26 Feb 2026 14:27:04 +0100 Subject: [PATCH 182/675] fixed #13087 - store `unmatchedSuppression` in `AnalyzerInformation` (#8173) --- cli/cppcheckexecutor.cpp | 65 +++++++++++++++++++++++++++++++--------- lib/analyzerinfo.cpp | 20 +++++++++++++ lib/analyzerinfo.h | 2 ++ test/cli/other_test.py | 4 --- 4 files changed, 73 insertions(+), 18 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 4f74bccbd5e..9f8fbb4f405 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -295,13 +295,15 @@ int CppCheckExecutor::check_wrapper(const Settings& settings, Suppressions& supp } /** - * Report unmatched suppressions - * @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions) - * @return true is returned if errors are reported + * Get list of unmatchedSuppression errors + * @param unmatched list of unmatched suppressions + * @param filters a list of (globbed) IDs to filter out + * @return vector of unmatchedSuppression errors */ -static bool reportUnmatchedSuppressions(const std::list &unmatched, ErrorLogger &errorLogger, const std::vector& filters) +static std::vector getUnmatchedSuppressions(const std::list &unmatched, const std::vector& filters) { - bool err = false; + std::vector errors; + // Report unmatched suppressions for (const SuppressionList::Suppression &s : unmatched) { // check if this unmatched suppression is suppressed @@ -325,15 +327,15 @@ static bool reportUnmatchedSuppressions(const std::list callStack; + std::list callStack; if (!s.fileName.empty()) { callStack.emplace_back(s.fileName, s.lineNumber, 0); } const std::string unmatchedSuppressionId = s.isPolyspace ? "unmatchedPolyspaceSuppression" : "unmatchedSuppression"; - errorLogger.reportErr(::ErrorMessage(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, unmatchedSuppressionId, Certainty::normal)); - err = true; + errors.emplace_back(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, unmatchedSuppressionId, Certainty::normal); } - return err; + + return errors; } bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, const SuppressionList& suppressions, const std::list &files, const std::list& fileSettings, ErrorLogger& errorLogger) { @@ -359,21 +361,55 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con supprlist.addSuppression(std::move(s)); } + const auto reportErrorsFn = [&](const std::string& sourcefile, std::size_t fsFileId, const std::vector& errors) -> bool { + if (errors.empty()) + return false; + + // TODO: what if sourcefile is empty? + + AnalyzerInformation analyzerInfo; + // FIXME: this is a horrible hack + // we need to "re-open" the file so we can add the unmatchedSuppression findings. + // we cannot keep it open conditionally because the whole program analysis reads the XML. + // re-ordering the code is also not an option because the unmatched suppression reporting needs to be run after all other checks. + analyzerInfo.reopen(settings.buildDir, sourcefile, /*cfgname*/ "", fsFileId); + + for (const auto& errmsg : errors) { + analyzerInfo.reportErr(errmsg); + errorLogger.reportErr(errmsg); + } + return true; + }; + bool err = false; for (auto i = files.cbegin(); i != files.cend(); ++i) { - err |= ::reportUnmatchedSuppressions(supprlist.getUnmatchedLocalSuppressions(*i), errorLogger, settings.unmatchedSuppressionFilters); + const std::vector errors = getUnmatchedSuppressions(supprlist.getUnmatchedLocalSuppressions(*i), settings.unmatchedSuppressionFilters); + err |= reportErrorsFn(i->spath(), i->fsFileId(), errors); } for (auto i = fileSettings.cbegin(); i != fileSettings.cend(); ++i) { - err |= ::reportUnmatchedSuppressions(supprlist.getUnmatchedLocalSuppressions(i->file), errorLogger, settings.unmatchedSuppressionFilters); + const std::vector errors = getUnmatchedSuppressions(supprlist.getUnmatchedLocalSuppressions(i->file), settings.unmatchedSuppressionFilters); + err |= reportErrorsFn(i->file.spath(), i->file.fsFileId(), errors); } if (settings.inlineSuppressions) { - err |= ::reportUnmatchedSuppressions(supprlist.getUnmatchedInlineSuppressions(), errorLogger, settings.unmatchedSuppressionFilters); + const std::vector errors = getUnmatchedSuppressions(supprlist.getUnmatchedInlineSuppressions(), settings.unmatchedSuppressionFilters); + for (const auto& errmsg : errors) { + std::string sourcefile; + if (!errmsg.callStack.empty()) + sourcefile = errmsg.callStack.cbegin()->getfile(false); // TODO: simplify path? + err |= reportErrorsFn(sourcefile, 0, {errmsg}); + } } - err |= ::reportUnmatchedSuppressions(supprlist.getUnmatchedGlobalSuppressions(), errorLogger, settings.unmatchedSuppressionFilters); + const std::vector errors = getUnmatchedSuppressions(supprlist.getUnmatchedGlobalSuppressions(), settings.unmatchedSuppressionFilters); + for (const auto& errmsg : errors) { + std::string sourcefile; + if (!errmsg.callStack.empty()) + sourcefile = errmsg.callStack.cbegin()->getfile(false); // TODO: simplify path? + err |= reportErrorsFn(sourcefile, 0, {errmsg}); + } return err; } @@ -426,9 +462,10 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup #endif } + // TODO: is this run again instead of using previously cached results? returnValue |= cppcheck.analyseWholeProgram(settings.buildDir, mFiles, mFileSettings, stdLogger.getCtuInfo()); - if (settings.severity.isEnabled(Severity::information) || settings.checkConfiguration) { + if ((settings.severity.isEnabled(Severity::information) || settings.checkConfiguration) && !supprs.nomsg.getSuppressions().empty()) { const bool err = reportUnmatchedSuppressions(settings, supprs.nomsg, mFiles, mFileSettings, stdLogger); if (err && returnValue == 0) returnValue = settings.exitCode; diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index 30a6910eef4..e76cae3bad6 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -292,3 +292,23 @@ std::string AnalyzerInformation::processFilesTxt(const std::string& buildDir, co return ""; } +void AnalyzerInformation::reopen(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId) +{ + if (buildDir.empty() || sourcefile.empty()) + return; + + const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(buildDir,sourcefile,cfg,fsFileId); + std::ifstream ifs(analyzerInfoFile); + if (!ifs.is_open()) + return; + + std::ostringstream iss; + iss << ifs.rdbuf(); + ifs.close(); + + std::string content = iss.str(); + content.resize(content.find("")); + + mOutputStream.open(analyzerInfoFile, std::ios::trunc); + mOutputStream << content; +} diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index e2830bfbcb1..d324e7fc223 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -69,6 +69,8 @@ class CPPCHECKLIB AnalyzerInformation { void setFileInfo(const std::string &check, const std::string &fileInfo); static std::string getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId); + void reopen(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId); + static const char sep = ':'; class CPPCHECKLIB Info { diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 1a80b06d929..7ab4cc6e12d 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -2373,8 +2373,6 @@ def test_inline_suppr_builddir(tmp_path): __test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j1']) -# TODO: the suppressions are generated outside of the scope which captures the analysis information -@pytest.mark.xfail(strict=True) def test_inline_suppr_builddir_cached(tmp_path): build_dir = tmp_path / 'b1' os.mkdir(build_dir) @@ -2388,8 +2386,6 @@ def test_inline_suppr_builddir_j(tmp_path): __test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j2']) -# TODO: the suppressions are generated outside of the scope which captures the analysis information -@pytest.mark.xfail(strict=True) def test_inline_suppr_builddir_j_cached(tmp_path): build_dir = tmp_path / 'b1' os.mkdir(build_dir) From ee42c2cd6964553117203d9875fdad892c3d4125 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 26 Feb 2026 14:58:45 +0100 Subject: [PATCH 183/675] Fix #14526 FN throwInNoexceptFunction with throw in member function (regression), add test for #9380 (#8253) --- lib/checkexceptionsafety.cpp | 3 ++- test/testexceptionsafety.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/checkexceptionsafety.cpp b/lib/checkexceptionsafety.cpp index 61f1ad8c784..9311ed6b10e 100644 --- a/lib/checkexceptionsafety.cpp +++ b/lib/checkexceptionsafety.cpp @@ -257,7 +257,8 @@ static const Token * functionThrowsRecursive(const Function * function, std::set tok = tok->linkAt(1); // skip till start of catch clauses if (tok->str() == "throw") return tok; - if (tok->function() && Token::simpleMatch(tok->astParent(), "(")) { + if (tok->function() && (Token::simpleMatch(tok->astParent(), "(") || + (Token::simpleMatch(tok->astParent(), ".") && Token::simpleMatch(tok->astParent()->astParent(), "(")))) { const Function * called = tok->function(); // check if called function has an exception specification if (called->isThrow() && called->throwArg) diff --git a/test/testexceptionsafety.cpp b/test/testexceptionsafety.cpp index 753a1ddd454..4744fd0f9c9 100644 --- a/test/testexceptionsafety.cpp +++ b/test/testexceptionsafety.cpp @@ -356,6 +356,21 @@ class TestExceptionSafety : public TestFixture { check("const char *func() noexcept { return 0; }\n" "const char *func1() noexcept { try { throw 1; } catch(...) {} return 0; }"); ASSERT_EQUALS("", errout_str()); + + check("struct A {\n" // #14526 + " void f(int = 0, int = 1) { throw 0; }\n" + "};\n" + "void g() noexcept {\n" + " A a;\n" + " a.f();\n" + "}\n" + "void h() noexcept {\n" + " A a;\n" + " a.f(1, 3);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:6:7]: (error) Unhandled exception thrown in function declared not to throw exceptions. [throwInNoexceptFunction]\n" + "[test.cpp:10:7]: (error) Unhandled exception thrown in function declared not to throw exceptions. [throwInNoexceptFunction]\n", + errout_str()); } void nothrowThrow() { @@ -518,6 +533,15 @@ class TestExceptionSafety : public TestFixture { " }\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void f(int i) {\n" // #9380 + " throw i;\n" + "}\n" + "int main() {\n" + " f(123);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:5:5]: (error) Unhandled exception thrown in function that is an entry point. [throwInEntryPoint]\n", + errout_str()); } }; From fdc01707a471daa66b9a33043cf4b65a4cea1fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 26 Feb 2026 15:58:24 +0100 Subject: [PATCH 184/675] fixed #13659 - set proper line for file-level `unmatchedSuppression` (#8266) --- cli/cppcheckexecutor.cpp | 2 +- test/cli/other_test.py | 28 +++++++++++++--------------- test/testsuppressions.cpp | 4 ++-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 9f8fbb4f405..d9705307584 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -329,7 +329,7 @@ static std::vector getUnmatchedSuppressions(const std::list callStack; if (!s.fileName.empty()) { - callStack.emplace_back(s.fileName, s.lineNumber, 0); + callStack.emplace_back(s.fileName, s.lineNumber == -1 ? 0 : s.lineNumber, 0); // TODO: get rid of s.lineNumber == -1 hack } const std::string unmatchedSuppressionId = s.isPolyspace ? "unmatchedPolyspaceSuppression" : "unmatchedSuppression"; errors.emplace_back(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, unmatchedSuppressionId, Certainty::normal); diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 7ab4cc6e12d..ce4089c9ac4 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -3367,11 +3367,10 @@ def test_suppress_unmatched_wildcard(tmp_path): # #13660 exitcode, stdout, stderr = cppcheck(args, cwd=tmp_path) assert exitcode == 0, stdout assert stdout.splitlines() == [] - # TODO: invalid locations - see #13659 assert stderr.splitlines() == [ - 'test*.c:-1:0: information: Unmatched suppression: id [unmatchedSuppression]', - 'test*.c:-1:0: information: Unmatched suppression: id2 [unmatchedSuppression]', - 'tes?.c:-1:0: information: Unmatched suppression: id2 [unmatchedSuppression]' + 'test*.c:0:0: information: Unmatched suppression: id [unmatchedSuppression]', + 'test*.c:0:0: information: Unmatched suppression: id2 [unmatchedSuppression]', + 'tes?.c:0:0: information: Unmatched suppression: id2 [unmatchedSuppression]' ] @@ -3396,12 +3395,11 @@ def test_suppress_unmatched_wildcard_unchecked(tmp_path): exitcode, stdout, stderr = cppcheck(args, cwd=tmp_path) assert exitcode == 0, stdout assert stdout.splitlines() == [] - # TODO: invalid locations - see #13659 assert stderr.splitlines() == [ - 'test*.c:-1:0: information: Unmatched suppression: id [unmatchedSuppression]', - 'tes?.c:-1:0: information: Unmatched suppression: id [unmatchedSuppression]', - '*:-1:0: information: Unmatched suppression: id2 [unmatchedSuppression]', - 'test*.c:-1:0: information: Unmatched suppression: * [unmatchedSuppression]' + 'test*.c:0:0: information: Unmatched suppression: id [unmatchedSuppression]', + 'tes?.c:0:0: information: Unmatched suppression: id [unmatchedSuppression]', + '*:0:0: information: Unmatched suppression: id2 [unmatchedSuppression]', + 'test*.c:0:0: information: Unmatched suppression: * [unmatchedSuppression]' ] @@ -3855,12 +3853,12 @@ def test_unmatched_file(tmp_path): # #14248 / #14249 ret, stdout, stderr = cppcheck(args) assert stdout == '' assert stderr.splitlines() == [ - f'{lib_file}:-1:0: information: Unmatched suppression: error [unmatchedSuppression]', - f'{lib_file}:-1:0: information: Unmatched suppression: error2 [unmatchedSuppression]', - f'{lib_file}:-1:0: information: Unmatched suppression: error3 [unmatchedSuppression]', - f'{lib_file}:-1:0: information: Unmatched suppression: error4 [unmatchedSuppression]', - f'{lib_file}:-1:0: information: Unmatched suppression: error5 [unmatchedSuppression]', - f'{lib_file}:-1:0: information: Unmatched suppression: error6 [unmatchedSuppression]' + f'{lib_file}:0:0: information: Unmatched suppression: error [unmatchedSuppression]', + f'{lib_file}:0:0: information: Unmatched suppression: error2 [unmatchedSuppression]', + f'{lib_file}:0:0: information: Unmatched suppression: error3 [unmatchedSuppression]', + f'{lib_file}:0:0: information: Unmatched suppression: error4 [unmatchedSuppression]', + f'{lib_file}:0:0: information: Unmatched suppression: error5 [unmatchedSuppression]', + f'{lib_file}:0:0: information: Unmatched suppression: error6 [unmatchedSuppression]' ] assert ret == 0, stdout diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index e8ebc4c4702..2b87cdad42b 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -542,7 +542,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "uninitvar:test.cpp")); - ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str()); + ASSERT_EQUALS("[test.cpp:0:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str()); // suppress all for this file only ASSERT_EQUALS(0, (this->*check)("void f() {\n" @@ -558,7 +558,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "*:test.cpp")); - ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: * [unmatchedSuppression]\n", errout_str()); + ASSERT_EQUALS("[test.cpp:0:0]: (information) Unmatched suppression: * [unmatchedSuppression]\n", errout_str()); // suppress uninitvar for this file and line ASSERT_EQUALS(0, (this->*check)("void f() {\n" From 09150eddda8c5e6e08b48f6fa2edb618506c9ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 26 Feb 2026 16:46:08 +0100 Subject: [PATCH 185/675] fixed #14259/#14491 - CI-unixish.yml: added step using minimum required CMake version / bumped minimum CMake version to 3.22 (#8210) --- .github/workflows/CI-unixish.yml | 36 +++++++++++++++++++++++++++ .github/workflows/CI-windows.yml | 42 ++++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- cmake/options.cmake | 12 +++------ readme.md | 2 +- releasenotes.txt | 1 + 6 files changed, 85 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 65e5c423ebc..b90e964eebb 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -407,6 +407,42 @@ jobs: run: | cmake --build cmake.output.boost -- -j$(nproc) + build_cmake_minimum: # TODO: move to docker workflow? + + runs-on: ubuntu-22.04 # use the oldest available runner + + env: + CMAKE_VERSION: 3.22 + CMAKE_VERSION_FULL: 3.22.6 + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Install missing software + run: | + sudo apt-get update + sudo apt-get install libxml2-utils + # qt6-tools-dev-tools for lprodump + # qt6-l10n-tools for lupdate + sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev + + - name: Install CMake + run: | + wget https://cmake.org/files/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64.tar.gz + tar xf cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64.tar.gz + + - name: Run CMake (without GUI) + run: | + export PATH=cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64/bin:$PATH + cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On + + - name: Run CMake (with GUI) + run: | + export PATH=cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64/bin:$PATH + cmake -S . -B cmake.output.gui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On + build: strategy: diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index d8f2bc7e4d9..da5fe2df99e 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -98,6 +98,48 @@ jobs: run: | cmake --build build.cxxstd --config Debug || exit /b !errorlevel! + build_cmake_minimum: + + runs-on: windows-2022 # use the oldest available runner + + env: + CMAKE_VERSION: 3.22 + CMAKE_VERSION_FULL: 3.22.6 + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Install CMake + run: | + curl -fsSL https://cmake.org/files/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION_FULL }}-windows-x86_64.zip -o cmake.zip || exit /b !errorlevel! + 7z x cmake.zip || exit /b !errorlevel! + + - name: Set up Visual Studio environment + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + version: 6.10.0 + modules: 'qtcharts' + setup-python: 'false' + cache: true + aqtversion: '==3.1.*' # TODO: remove when aqtinstall 3.2.2 is available + + - name: Run CMake (without GUI) + run: | + :: TODO: enable DHAVE_RULES? + cmake-${{ env.CMAKE_VERSION_FULL }}-windows-x86_64\bin\cmake.exe -S . -B cmake.output -G "Visual Studio 17 2022" -A x64 -DHAVE_RULES=Off -DBUILD_TESTING=On + + - name: Run CMake (with GUI) + run: | + :: TODO: enable DHAVE_RULES? + cmake-${{ env.CMAKE_VERSION_FULL }}-windows-x86_64\bin\cmake.exe -S . -B cmake.output.gui -G "Visual Studio 17 2022" -A x64 -DHAVE_RULES=Off -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On + build: strategy: matrix: diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f603ae1332..e41d81029ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.22) project(Cppcheck VERSION 2.18.99 LANGUAGES CXX) include(cmake/options.cmake) diff --git a/cmake/options.cmake b/cmake/options.cmake index 0e8da0e3f0b..4a315667093 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -124,14 +124,10 @@ option(ENABLE_CSA_ALPHA "Enable Clang Static Analyzer alpha checkers for run # TODO: disable by default like make build? option(FILESDIR "Hard-coded directory for files to load from" OFF) -if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16") - set(CMAKE_DISABLE_PRECOMPILE_HEADERS Off CACHE BOOL "Disable precompiled headers") - # need to disable the prologue or it will be treated like a system header and not emit any warnings - # see https://gitlab.kitware.com/cmake/cmake/-/issues/21219 - set(CMAKE_PCH_PROLOGUE "") -else() - set(CMAKE_DISABLE_PRECOMPILE_HEADERS On CACHE BOOL "Disable precompiled headers") -endif() +set(CMAKE_DISABLE_PRECOMPILE_HEADERS Off CACHE BOOL "Disable precompiled headers") +# need to disable the prologue or it will be treated like a system header and not emit any warnings +# see https://gitlab.kitware.com/cmake/cmake/-/issues/21219 +set(CMAKE_PCH_PROLOGUE "") set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE ${CMAKE_INSTALL_PREFIX}/include CACHE PATH "Output directory for headers") set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_INSTALL_PREFIX}/lib CACHE PATH "Output directory for libraries") diff --git a/readme.md b/readme.md index 246d2e07c72..9244243770a 100644 --- a/readme.md +++ b/readme.md @@ -52,7 +52,7 @@ The minimum required Python version is 3.7. ### CMake -The minimum required version is CMake 3.13. +The minimum required version is CMake 3.22. Example, compiling Cppcheck with cmake: diff --git a/releasenotes.txt b/releasenotes.txt index 4772418f1f0..fe530b2121e 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -23,4 +23,5 @@ Infrastructure & dependencies: Other: - The built-in "win*" and "unix*" platforms will now default to signed char type instead of unknown signedness. If you require unsigned chars please specify "--funsigned-char" +- bumped minimum required CMake version to 3.22 - From 1820c05899a182bfb8dfd3be72250997ce37aec5 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:46:34 +0100 Subject: [PATCH 186/675] Fix #14540 FP shiftNegative after sign check (#8269) --- lib/valueflow.cpp | 2 +- test/testvalueflow.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index e824ba75a5a..fdf7394aa3a 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3682,7 +3682,7 @@ static void valueFlowSymbolicOperators(const SymbolDatabase& symboldatabase, con continue; if (vartok->exprId() == 0) continue; - if (Token::Match(tok, "<<|>>|/") && !astIsLHS(vartok)) + if (Token::Match(tok, "<<|>>|/|-") && !astIsLHS(vartok)) continue; if (Token::Match(tok, "<<|>>|^|+|-|%or%") && constant->intvalue != 0) continue; diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 6eb807bdd11..36410a60508 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -8910,6 +8910,18 @@ class TestValueFlow : public TestFixture { " return x;\n" "}\n"; ASSERT_EQUALS(false, testValueOfXKnown(code, 3U, "a", 0)); + + code = "void f(int n) {\n" + " int x = 0 - n;\n" + " return x;\n" + "}\n"; + ASSERT_EQUALS(false, testValueOfX(code, 3U, "n", ValueFlow::Value::ValueType::SYMBOLIC)); + + code = "void f(int n) {\n" + " int x = n - 0;\n" + " return x;\n" + "}\n"; + ASSERT_EQUALS(true, testValueOfX(code, 3U, "n", ValueFlow::Value::ValueType::SYMBOLIC)); } void valueFlowSymbolicStrlen() From 31cb62d1d9a4dbb9f8008acb5565965e93a49ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 27 Feb 2026 15:11:46 +0100 Subject: [PATCH 187/675] fixed #14545 - updated simplecpp to 1.6.5 (#8196) https://github.com/danmar/simplecpp/releases/tag/1.6.5 --- externals/simplecpp/simplecpp.cpp | 427 ++++++++++++++++-------------- externals/simplecpp/simplecpp.h | 12 +- 2 files changed, 242 insertions(+), 197 deletions(-) diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp index 581c9b10990..7afc17ab735 100644 --- a/externals/simplecpp/simplecpp.cpp +++ b/externals/simplecpp/simplecpp.cpp @@ -67,14 +67,12 @@ static bool isOct(const std::string &s) return s.size()>1 && (s[0]=='0') && (s[1] >= '0') && (s[1] < '8'); } -// TODO: added an undercore since this conflicts with a function of the same name in utils.h from Cppcheck source when building Cppcheck with MSBuild -static bool isStringLiteral_(const std::string &s) +static bool isStringLiteral(const std::string &s) { return s.size() > 1 && (s[0]=='\"') && (*s.rbegin()=='\"'); } -// TODO: added an undercore since this conflicts with a function of the same name in utils.h from Cppcheck source when building Cppcheck with MSBuild -static bool isCharLiteral_(const std::string &s) +static bool isCharLiteral(const std::string &s) { // char literal patterns can include 'a', '\t', '\000', '\xff', 'abcd', and maybe '' // This only checks for the surrounding '' but doesn't parse the content. @@ -351,121 +349,124 @@ class simplecpp::TokenList::Stream { bool isUtf16; }; -class StdIStream : public simplecpp::TokenList::Stream { -public: - // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members - explicit StdIStream(std::istream &istr) - : istr(istr) { - assert(istr.good()); - init(); - } +namespace { + class StdIStream : public simplecpp::TokenList::Stream { + public: + // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members + explicit StdIStream(std::istream &istr) + : istr(istr) { + assert(istr.good()); + init(); + } - int get() override { - return istr.get(); - } - int peek() override { - return istr.peek(); - } - void unget() override { - istr.unget(); - } - bool good() override { - return istr.good(); - } + int get() override { + return istr.get(); + } + int peek() override { + return istr.peek(); + } + void unget() override { + istr.unget(); + } + bool good() override { + return istr.good(); + } -private: - std::istream &istr; -}; + private: + std::istream &istr; + }; -class StdCharBufStream : public simplecpp::TokenList::Stream { -public: - // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members - StdCharBufStream(const unsigned char* str, std::size_t size) - : str(str) - , size(size) - { - init(); - } + class StdCharBufStream : public simplecpp::TokenList::Stream { + public: + // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members + StdCharBufStream(const unsigned char* str, std::size_t size) + : str(str) + , size(size) + { + init(); + } - int get() override { - if (pos >= size) - return lastStatus = EOF; - return str[pos++]; - } - int peek() override { - if (pos >= size) - return lastStatus = EOF; - return str[pos]; - } - void unget() override { - --pos; - } - bool good() override { - return lastStatus != EOF; - } + int get() override { + if (pos >= size) + return lastStatus = EOF; + return str[pos++]; + } + int peek() override { + if (pos >= size) + return lastStatus = EOF; + return str[pos]; + } + void unget() override { + --pos; + } + bool good() override { + return lastStatus != EOF; + } -private: - const unsigned char *str; - const std::size_t size; - std::size_t pos{}; - int lastStatus{}; -}; + private: + const unsigned char *str; + const std::size_t size; + std::size_t pos{}; + int lastStatus{}; + }; -class FileStream : public simplecpp::TokenList::Stream { -public: - /** - * @throws simplecpp::Output thrown if file is not found - */ - // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members - explicit FileStream(const std::string &filename, std::vector &files) - : file(fopen(filename.c_str(), "rb")) - { - if (!file) { - files.push_back(filename); - throw simplecpp::Output(simplecpp::Output::FILE_NOT_FOUND, {}, "File is missing: " + filename); + class FileStream : public simplecpp::TokenList::Stream { + public: + /** + * @throws simplecpp::Output thrown if file is not found + */ + // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members + explicit FileStream(const std::string &filename, std::vector &files) + : file(fopen(filename.c_str(), "rb")) + { + if (!file) { + files.emplace_back(filename); + throw simplecpp::Output(simplecpp::Output::FILE_NOT_FOUND, {}, "File is missing: " + filename); + } + init(); } - init(); - } - FileStream(const FileStream&) = delete; - FileStream &operator=(const FileStream&) = delete; + FileStream(const FileStream&) = delete; + FileStream &operator=(const FileStream&) = delete; - ~FileStream() override { - fclose(file); - file = nullptr; - } + ~FileStream() override { + fclose(file); + file = nullptr; + } - int get() override { - lastStatus = lastCh = fgetc(file); - return lastCh; - } - int peek() override { - // keep lastCh intact - const int ch = fgetc(file); - unget_internal(ch); - return ch; - } - void unget() override { - unget_internal(lastCh); - } - bool good() override { - return lastStatus != EOF; - } + int get() override { + lastStatus = lastCh = fgetc(file); + return lastCh; + } + int peek() override { + // keep lastCh intact + const int ch = fgetc(file); + unget_internal(ch); + return ch; + } + void unget() override { + unget_internal(lastCh); + } + bool good() override { + return lastStatus != EOF; + } -private: - void unget_internal(int ch) { - if (isUtf16) { - // TODO: use ungetc() as well - // UTF-16 has subsequent unget() calls - fseek(file, -1, SEEK_CUR); - } else - ungetc(ch, file); - } + private: + void unget_internal(int ch) { + if (isUtf16) { + // TODO: use ungetc() as well + // UTF-16 has subsequent unget() calls + fseek(file, -1, SEEK_CUR); + } else { + ungetc(ch, file); + } + } - FILE *file; - int lastCh{}; - int lastStatus{}; -}; + FILE *file; + int lastCh{}; + int lastStatus{}; + }; +} simplecpp::TokenList::TokenList(std::vector &filenames) : frontToken(nullptr), backToken(nullptr), files(filenames) {} @@ -490,7 +491,7 @@ simplecpp::TokenList::TokenList(const std::string &filename, std::vectorpush_back(e); + outputList->emplace_back(e); } } @@ -565,6 +566,7 @@ std::string simplecpp::TokenList::stringify(bool linenrs) const { std::ostringstream ret; Location loc; + loc.line = 1; bool filechg = true; for (const Token *tok = cfront(); tok; tok = tok->next) { if (tok->location.line < loc.line || tok->location.fileIndex != loc.fileIndex) { @@ -619,12 +621,12 @@ static void portabilityBackslash(simplecpp::OutputList *outputList, const simple { if (!outputList) return; - simplecpp::Output err = { + simplecpp::Output err{ simplecpp::Output::PORTABILITY_BACKSLASH, location, "Combination 'backslash space newline' is not portable." }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } static bool isStringLiteralPrefix(const std::string &str) @@ -668,12 +670,12 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename, if (ch >= 0x80) { if (outputList) { - simplecpp::Output err = { + simplecpp::Output err{ simplecpp::Output::UNHANDLED_CHAR_ERROR, location, "The code contains unhandled character(s) (character code=" + std::to_string(static_cast(ch)) + "). Neither unicode nor extended ascii is supported." }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } clear(); return; @@ -870,12 +872,12 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename, } if (!stream.good() || ch == '\n') { if (outputList) { - Output err = { + Output err{ Output::SYNTAX_ERROR, location, "Invalid newline in raw string delimiter." }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } return; } @@ -884,12 +886,12 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename, currentToken += stream.readChar(); if (!endsWith(currentToken, endOfRawString)) { if (outputList) { - Output err = { + Output err{ Output::SYNTAX_ERROR, location, "Raw string missing terminating delimiter." }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } return; } @@ -1004,6 +1006,14 @@ static bool isFloatSuffix(const simplecpp::Token *tok) return c == 'f' || c == 'l'; } +static const std::string AND("and"); +static const std::string BITAND("bitand"); +static const std::string BITOR("bitor"); +static bool isAlternativeAndBitandBitor(const simplecpp::Token* tok) +{ + return isAlternativeBinaryOp(tok, AND) || isAlternativeBinaryOp(tok, BITAND) || isAlternativeBinaryOp(tok, BITOR); +} + void simplecpp::TokenList::combineOperators() { std::stack executableScope; @@ -1039,7 +1049,7 @@ void simplecpp::TokenList::combineOperators() if (tok->previous && tok->previous->number && sameline(tok->previous, tok) && tok->previous->str().find_first_of("._") == std::string::npos) { tok->setstr(tok->previous->str() + '.'); deleteToken(tok->previous); - if (sameline(tok, tok->next) && (isFloatSuffix(tok->next) || (tok->next && tok->next->startsWithOneOf("AaBbCcDdEeFfPp")))) { + if (sameline(tok, tok->next) && (isFloatSuffix(tok->next) || (tok->next && tok->next->startsWithOneOf("AaBbCcDdEeFfPp") && !isAlternativeAndBitandBitor(tok->next)))) { tok->setstr(tok->str() + tok->next->str()); deleteToken(tok->next); } @@ -1178,8 +1188,9 @@ void simplecpp::TokenList::constFoldMulDivRem(Token *tok) continue; long long result; - if (tok->op == '*') + if (tok->op == '*') { result = (stringToLL(tok->previous->str()) * stringToLL(tok->next->str())); + } else if (tok->op == '/' || tok->op == '%') { const long long rhs = stringToLL(tok->next->str()); if (rhs == 0) @@ -1191,8 +1202,9 @@ void simplecpp::TokenList::constFoldMulDivRem(Token *tok) result = (lhs / rhs); else result = (lhs % rhs); - } else + } else { continue; + } tok = tok->previous; tok->setstr(toString(result)); @@ -1284,8 +1296,6 @@ void simplecpp::TokenList::constFoldComparison(Token *tok) } } -static const std::string BITAND("bitand"); -static const std::string BITOR("bitor"); static const std::string XOR("xor"); void simplecpp::TokenList::constFoldBitwise(Token *tok) { @@ -1320,7 +1330,6 @@ void simplecpp::TokenList::constFoldBitwise(Token *tok) } } -static const std::string AND("and"); static const std::string OR("or"); void simplecpp::TokenList::constFoldLogicalOp(Token *tok) { @@ -1416,8 +1425,9 @@ std::string simplecpp::TokenList::readUntil(Stream &stream, const Location &loca ret.erase(ret.size()-1U); backslash = (next == '\r'); update_ch = false; - } else if (next == '\\') + } else if (next == '\\') { update_ch = !update_ch; + } ret += next; } while (next == '\\'); if (update_ch) @@ -1428,12 +1438,12 @@ std::string simplecpp::TokenList::readUntil(Stream &stream, const Location &loca if (!stream.good() || ch != end) { clear(); if (outputList) { - Output err = { + Output err{ Output::SYNTAX_ERROR, location, std::string("No pair for character (") + start + "). Can't process file. File is either invalid or unicode, which is currently not supported." }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } return ""; } @@ -1471,7 +1481,7 @@ unsigned int simplecpp::TokenList::fileIndex(const std::string &filename) if (files[i] == filename) return i; } - files.push_back(filename); + files.emplace_back(filename); return files.size() - 1U; } @@ -1538,8 +1548,9 @@ namespace simplecpp { if (this != &other) { files = other.files; valueDefinedInCode_ = other.valueDefinedInCode_; - if (other.tokenListDefine.empty()) + if (other.tokenListDefine.empty()) { parseDefine(other.nameTokDef); + } else { tokenListDefine = other.tokenListDefine; parseDefine(tokenListDefine.cfront()); @@ -1608,15 +1619,17 @@ namespace simplecpp { if (par==0) break; --par; - } else if (macro2tok->op == ')') + } else if (macro2tok->op == ')') { ++par; + } macro2tok = macro2tok->previous; } if (macro2tok) { // macro2tok->op == '(' macro2tok = macro2tok->previous; expandedmacros.insert(name()); - } else if (rawtok->op == '(') + } else if (rawtok->op == '(') { macro2tok = output2.back(); + } if (!macro2tok || !macro2tok->name) break; if (output2.cfront() != output2.cback() && macro2tok->str() == this->name()) @@ -1636,8 +1649,9 @@ namespace simplecpp { const Token *rawtok2 = rawtok; for (; rawtok2; rawtok2 = rawtok2->next) { rawtokens2.push_back(new Token(rawtok2->str(), loc)); - if (rawtok2->op == '(') + if (rawtok2->op == '(') { ++par; + } else if (rawtok2->op == ')') { if (par <= 1U) break; @@ -1699,19 +1713,19 @@ namespace simplecpp { : Error(loc, format(macroName, message)) {} static inline invalidHashHash unexpectedToken(const Location &loc, const std::string ¯oName, const Token *tokenA) { - return invalidHashHash(loc, macroName, "Unexpected token '"+ tokenA->str()+"'"); + return {loc, macroName, "Unexpected token '"+ tokenA->str()+"'"}; } static inline invalidHashHash cannotCombine(const Location &loc, const std::string ¯oName, const Token *tokenA, const Token *tokenB) { - return invalidHashHash(loc, macroName, "Combining '"+ tokenA->str()+ "' and '"+ tokenB->str() + "' yields an invalid token."); + return {loc, macroName, "Combining '"+ tokenA->str()+ "' and '"+ tokenB->str() + "' yields an invalid token."}; } static inline invalidHashHash unexpectedNewline(const Location &loc, const std::string ¯oName) { - return invalidHashHash(loc, macroName, "Unexpected newline"); + return {loc, macroName, "Unexpected newline"}; } static inline invalidHashHash universalCharacterUB(const Location &loc, const std::string ¯oName, const Token* tokenA, const std::string& strAB) { - return invalidHashHash(loc, macroName, "Combining '\\"+ tokenA->str()+ "' and '"+ strAB.substr(tokenA->str().size()) + "' yields universal character '\\" + strAB + "'. This is undefined behavior according to C standard chapter 5.1.1.2, paragraph 4."); + return {loc, macroName, "Combining '\\"+ tokenA->str()+ "' and '"+ strAB.substr(tokenA->str().size()) + "' yields universal character '\\" + strAB + "'. This is undefined behavior according to C standard chapter 5.1.1.2, paragraph 4."}; } }; private: @@ -1753,7 +1767,7 @@ namespace simplecpp { break; } if (argtok->op != ',') - args.push_back(argtok->str()); + args.emplace_back(argtok->str()); argtok = argtok->next; } if (!sameline(nametoken, argtok)) { @@ -1828,22 +1842,24 @@ namespace simplecpp { std::vector getMacroParameters(const Token *nameTokInst, bool calledInDefine) const { if (!nameTokInst->next || nameTokInst->next->op != '(' || !functionLike()) - return std::vector(); + return {}; std::vector parametertokens; - parametertokens.push_back(nameTokInst->next); + parametertokens.emplace_back(nameTokInst->next); unsigned int par = 0U; for (const Token *tok = nameTokInst->next->next; calledInDefine ? sameline(tok, nameTokInst) : (tok != nullptr); tok = tok->next) { - if (tok->op == '(') + if (tok->op == '(') { ++par; + } else if (tok->op == ')') { if (par == 0U) { - parametertokens.push_back(tok); + parametertokens.emplace_back(tok); break; } --par; - } else if (par == 0U && tok->op == ',' && (!variadic || parametertokens.size() < args.size())) - parametertokens.push_back(tok); + } else if (par == 0U && tok->op == ',' && (!variadic || parametertokens.size() < args.size())) { + parametertokens.emplace_back(tok); + } } return parametertokens; } @@ -1871,8 +1887,9 @@ namespace simplecpp { tokens.back()->macro = name(); } - if (tok->op == '(') + if (tok->op == '(') { ++par; + } else if (tok->op == ')') { --par; if (par == 0U) @@ -1893,7 +1910,7 @@ namespace simplecpp { std::cout << " expand " << name() << " " << locstring(defineLocation()) << std::endl; #endif - usageList.push_back(loc); + usageList.emplace_back(loc); if (nameTokInst->str() == "__FILE__") { output.push_back(new Token('\"'+output.file(loc)+'\"', loc)); @@ -1945,19 +1962,20 @@ namespace simplecpp { const MacroMap::const_iterator m = macros.find("__COUNTER__"); - if (!counter || m == macros.end()) + if (!counter || m == macros.end()) { parametertokens2.swap(parametertokens1); + } else { const Macro &counterMacro = m->second; unsigned int par = 0; for (const Token *tok = parametertokens1[0]; tok && par < parametertokens1.size(); tok = tok->next) { if (tok->str() == "__COUNTER__") { tokensparams.push_back(new Token(toString(counterMacro.usageList.size()), tok->location)); - counterMacro.usageList.push_back(tok->location); + counterMacro.usageList.emplace_back(tok->location); } else { tokensparams.push_back(new Token(*tok)); if (tok == parametertokens1[par]) { - parametertokens2.push_back(tokensparams.cback()); + parametertokens2.emplace_back(tokensparams.cback()); par++; } } @@ -2135,8 +2153,9 @@ namespace simplecpp { TokenList tokens(files); tokens.push_back(new Token(*tok)); const Token * tok2 = nullptr; - if (tok->next->op == '(') + if (tok->next->op == '(') { tok2 = appendTokens(tokens, loc, tok->next, macros, expandedmacros, parametertokens); + } else if (expandArg(tokens, tok->next, loc, macros, expandedmacros, parametertokens)) { tokens.front()->location = loc; if (tokens.cfront()->next && tokens.cfront()->next->op == '(') @@ -2274,7 +2293,7 @@ namespace simplecpp { throw invalidHashHash::unexpectedNewline(tok->location, name()); const bool canBeConcatenatedWithEqual = A->isOneOf("+-*/%&|^") || A->str() == "<<" || A->str() == ">>"; - const bool canBeConcatenatedStringOrChar = isStringLiteral_(A->str()) || isCharLiteral_(A->str()); + const bool canBeConcatenatedStringOrChar = isStringLiteral(A->str()) || isCharLiteral(A->str()); const bool unexpectedA = (!A->name && !A->number && !A->str().empty() && !canBeConcatenatedWithEqual && !canBeConcatenatedStringOrChar); const Token * const B = tok->next->next; @@ -2312,12 +2331,15 @@ namespace simplecpp { const bool varargs = variadic && !args.empty() && B->str() == args[args.size()-1U]; if (expandArg(tokensB, B, parametertokens)) { - if (tokensB.empty()) + if (tokensB.empty()) { strAB = A->str(); - else if (varargs && A->op == ',') + } + else if (varargs && A->op == ',') { strAB = ","; - else if (varargs && unexpectedA) + } + else if (varargs && unexpectedA) { throw invalidHashHash::unexpectedToken(tok->location, name(), A); + } else { strAB = A->str() + tokensB.cfront()->str(); tokensB.deleteToken(tokensB.front()); @@ -2336,8 +2358,9 @@ namespace simplecpp { throw invalidHashHash::universalCharacterUB(tok->location, name(), A, strAB); } - if (varargs && tokensB.empty() && tok->previous->str() == ",") + if (varargs && tokensB.empty() && tok->previous->str() == ",") { output.deleteToken(A); + } else if (strAB != "," && macros.find(strAB) == macros.end()) { A->setstr(strAB); for (Token *b = tokensB.front(); b; b = b->next) @@ -2691,7 +2714,7 @@ static void simplifyName(simplecpp::TokenList &expr) { for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) { if (tok->name) { - static const std::set altop = {"and","or","bitand","bitor","compl","not","not_eq","xor"}; + static const std::set altop{"and","or","bitand","bitor","compl","not","not_eq","xor"}; if (altop.find(tok->str()) != altop.end()) { bool alt; if (tok->str() == "not" || tok->str() == "compl") { @@ -2755,8 +2778,9 @@ long long simplecpp::characterLiteralToLL(const std::string& str) pos = 3; } else if (str.size() >= 2 && (str[0] == 'L' || str[0] == 'U') && str[1] == '\'') { pos = 2; - } else + } else { throw std::runtime_error("expected a character literal"); + } unsigned long long multivalue = 0; @@ -2956,6 +2980,7 @@ static void simplifyComments(simplecpp::TokenList &expr) /** * @throws std::runtime_error thrown on invalid literals, missing sizeof arguments or invalid expressions, * missing __has_include() arguments or expressions, undefined function-like macros, invalid number literals + * @throws std::overflow_error thrown on overflow or division by zero */ static long long evaluate(simplecpp::TokenList &expr, const simplecpp::DUI &dui, const std::map &sizeOfType) { @@ -3120,7 +3145,7 @@ std::pair simplecpp::FileDataCache::get(const std:: bool simplecpp::FileDataCache::getFileId(const std::string &path, FileID &id) { #ifdef _WIN32 - HANDLE hFile = CreateFileA(path.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileA(path.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) return false; @@ -3176,12 +3201,12 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, if (filedata == nullptr) { if (outputList) { - simplecpp::Output err = { + simplecpp::Output err{ simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND, {}, "Can not open include file '" + filename + "' that is explicitly included." }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } continue; } @@ -3195,7 +3220,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, if (dui.removeComments) filedata->tokens.removeComments(); - filelist.push_back(filedata->tokens.front()); + filelist.emplace_back(filedata->tokens.front()); } for (const Token *rawtok = rawtokens.cfront(); rawtok || !filelist.empty(); rawtok = rawtok ? rawtok->next : nullptr) { @@ -3234,7 +3259,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, if (dui.removeComments) filedata->tokens.removeComments(); - filelist.push_back(filedata->tokens.front()); + filelist.emplace_back(filedata->tokens.front()); } return cache; @@ -3250,12 +3275,12 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token tok1 = it->second.expand(value, tok, macros, files); } catch (const simplecpp::Macro::Error &err) { if (outputList) { - simplecpp::Output out = { + simplecpp::Output out{ simplecpp::Output::SYNTAX_ERROR, err.location, "failed to expand \'" + tok->str() + "\', " + err.what }; - outputList->push_back(std::move(out)); + outputList->emplace_back(std::move(out)); } return false; } @@ -3340,8 +3365,21 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL continue; const std::string lhs(macrostr.substr(0,eq)); const std::string rhs(eq==std::string::npos ? std::string("1") : macrostr.substr(eq+1)); - const Macro macro(lhs, rhs, dummy); - macros.insert(std::pair(macro.name(), macro)); + try { + const Macro macro(lhs, rhs, dummy); + macros.insert(std::pair(macro.name(), macro)); + } catch (const std::runtime_error& e) { + if (outputList) { + simplecpp::Output err{ + Output::DUI_ERROR, + {}, + e.what() + }; + outputList->emplace_back(std::move(err)); + } + output.clear(); + return; + } } const bool strictAnsiUndefined = dui.undefined.find("__STRICT_ANSI__") != dui.undefined.cend(); @@ -3351,7 +3389,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL macros.insert(std::make_pair("__FILE__", Macro("__FILE__", "__FILE__", dummy))); macros.insert(std::make_pair("__LINE__", Macro("__LINE__", "__LINE__", dummy))); macros.insert(std::make_pair("__COUNTER__", Macro("__COUNTER__", "__COUNTER__", dummy))); - struct tm ltime = {}; + struct tm ltime {}; getLocaltime(ltime); macros.insert(std::make_pair("__DATE__", Macro("__DATE__", getDateDefine(<ime), dummy))); macros.insert(std::make_pair("__TIME__", Macro("__TIME__", getTimeDefine(<ime), dummy))); @@ -3366,12 +3404,12 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL const cppstd_t cpp_std = simplecpp::getCppStd(dui.std); if (cpp_std == CPPUnknown) { if (outputList) { - simplecpp::Output err = { + simplecpp::Output err{ Output::DUI_ERROR, {}, "unknown standard specified: '" + dui.std + "'" }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } output.clear(); return; @@ -3423,12 +3461,12 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL if (ifstates.size() <= 1U && (rawtok->str() == ELIF || rawtok->str() == ELSE || rawtok->str() == ENDIF)) { if (outputList) { - simplecpp::Output err = { + simplecpp::Output err{ Output::SYNTAX_ERROR, rawtok->location, "#" + rawtok->str() + " without #if" }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } output.clear(); return; @@ -3443,13 +3481,13 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL msg += tok->str(); } msg = '#' + rawtok->str() + ' ' + msg; - simplecpp::Output err = { + simplecpp::Output err{ rawtok->str() == ERROR ? Output::ERROR : Output::WARNING, rawtok->location, std::move(msg) }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } if (rawtok->str() == ERROR) { output.clear(); @@ -3471,23 +3509,23 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL } } catch (const std::runtime_error &) { if (outputList) { - simplecpp::Output err = { + simplecpp::Output err{ Output::SYNTAX_ERROR, rawtok->location, "Failed to parse #define" }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } output.clear(); return; } catch (const simplecpp::Macro::Error &err) { if (outputList) { - simplecpp::Output out = { + simplecpp::Output out{ simplecpp::Output::SYNTAX_ERROR, err.location, "Failed to parse #define, " + err.what }; - outputList->push_back(std::move(out)); + outputList->emplace_back(std::move(out)); } output.clear(); return; @@ -3523,12 +3561,12 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL if (inc2.empty() || inc2.cfront()->str().size() <= 2U) { if (outputList) { - simplecpp::Output err = { + simplecpp::Output err{ Output::SYNTAX_ERROR, rawtok->location, "No header in #include" }; - outputList->push_back(std::move(err)); + outputList->emplace_back(std::move(err)); } output.clear(); return; @@ -3541,21 +3579,21 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL const FileData *const filedata = cache.get(rawtokens.file(rawtok->location), header, dui, systemheader, files, outputList).first; if (filedata == nullptr) { if (outputList) { - simplecpp::Output out = { + simplecpp::Output out{ simplecpp::Output::MISSING_HEADER, rawtok->location, "Header not found: " + inctok->str() }; - outputList->push_back(std::move(out)); + outputList->emplace_back(std::move(out)); } } else if (includetokenstack.size() >= 400) { if (outputList) { - simplecpp::Output out = { + simplecpp::Output out{ simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY, rawtok->location, "#include nested too deeply" }; - outputList->push_back(std::move(out)); + outputList->emplace_back(std::move(out)); } } else if (pragmaOnce.find(filedata->filename) == pragmaOnce.end()) { includetokenstack.push(gotoNextLine(rawtok)); @@ -3565,26 +3603,27 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL } else if (rawtok->str() == IF || rawtok->str() == IFDEF || rawtok->str() == IFNDEF || rawtok->str() == ELIF) { if (!sameline(rawtok,rawtok->next)) { if (outputList) { - simplecpp::Output out = { + simplecpp::Output out{ simplecpp::Output::SYNTAX_ERROR, rawtok->location, "Syntax error in #" + rawtok->str() }; - outputList->push_back(std::move(out)); + outputList->emplace_back(std::move(out)); } output.clear(); return; } bool conditionIsTrue; - if (ifstates.top() == AlwaysFalse || (ifstates.top() == ElseIsTrue && rawtok->str() != ELIF)) + if (ifstates.top() == AlwaysFalse || (ifstates.top() == ElseIsTrue && rawtok->str() != ELIF)) { conditionIsTrue = false; + } else if (rawtok->str() == IFDEF) { conditionIsTrue = (macros.find(rawtok->next->str()) != macros.end() || (hasInclude && rawtok->next->str() == HAS_INCLUDE)); - maybeUsedMacros[rawtok->next->str()].push_back(rawtok->next->location); + maybeUsedMacros[rawtok->next->str()].emplace_back(rawtok->next->location); } else if (rawtok->str() == IFNDEF) { conditionIsTrue = (macros.find(rawtok->next->str()) == macros.end() && !(hasInclude && rawtok->next->str() == HAS_INCLUDE)); - maybeUsedMacros[rawtok->next->str()].push_back(rawtok->next->location); + maybeUsedMacros[rawtok->next->str()].emplace_back(rawtok->next->location); } else { /*if (rawtok->str() == IF || rawtok->str() == ELIF)*/ TokenList expr(files); for (const Token *tok = rawtok->next; tok && tok->location.sameline(rawtok->location); tok = tok->next) { @@ -3598,7 +3637,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL const bool par = (tok && tok->op == '('); if (par) tok = tok->next; - maybeUsedMacros[rawtok->next->str()].push_back(rawtok->next->location); + maybeUsedMacros[rawtok->next->str()].emplace_back(rawtok->next->location); if (tok) { if (macros.find(tok->str()) != macros.end()) expr.push_back(new Token("1", tok->location)); @@ -3611,12 +3650,12 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL tok = tok ? tok->next : nullptr; if (!tok || !sameline(rawtok,tok) || (par && tok->op != ')')) { if (outputList) { - Output out = { + Output out{ Output::SYNTAX_ERROR, rawtok->location, "failed to evaluate " + std::string(rawtok->str() == IF ? "#if" : "#elif") + " condition" }; - outputList->push_back(std::move(out)); + outputList->emplace_back(std::move(out)); } output.clear(); return; @@ -3654,12 +3693,12 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL tok = tok ? tok->next : nullptr; if (!tok || !sameline(rawtok,tok) || (par && tok->op != ')') || (!closingAngularBracket)) { if (outputList) { - Output out = { + Output out{ Output::SYNTAX_ERROR, rawtok->location, "failed to evaluate " + std::string(rawtok->str() == IF ? "#if" : "#elif") + " condition" }; - outputList->push_back(std::move(out)); + outputList->emplace_back(std::move(out)); } output.clear(); return; @@ -3667,7 +3706,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL continue; } - maybeUsedMacros[rawtok->next->str()].push_back(rawtok->next->location); + maybeUsedMacros[rawtok->next->str()].emplace_back(rawtok->next->location); const Token *tmp = tok; if (!preprocessToken(expr, tmp, macros, files, outputList)) { @@ -3695,12 +3734,12 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL std::string msg = "failed to evaluate " + std::string(rawtok->str() == IF ? "#if" : "#elif") + " condition"; if (e.what() && *e.what()) msg += std::string(", ") + e.what(); - Output out = { + Output out{ Output::SYNTAX_ERROR, rawtok->location, std::move(msg) }; - outputList->push_back(std::move(out)); + outputList->emplace_back(std::move(out)); } output.clear(); return; @@ -3799,7 +3838,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL mu.macroName = macro.name(); mu.macroLocation = macro.defineLocation(); mu.useLocation = *usageIt; - macroUsage->push_back(std::move(mu)); + macroUsage->emplace_back(std::move(mu)); } } } diff --git a/externals/simplecpp/simplecpp.h b/externals/simplecpp/simplecpp.h index 9a847d14969..54f6a90c053 100644 --- a/externals/simplecpp/simplecpp.h +++ b/externals/simplecpp/simplecpp.h @@ -57,7 +57,9 @@ #ifndef SIMPLECPP_TOKENLIST_ALLOW_PTR // still provide the legacy API in case we lack the performant wrappers # if !defined(__cpp_lib_string_view) && !defined(__cpp_lib_span) -# define SIMPLECPP_TOKENLIST_ALLOW_PTR +# define SIMPLECPP_TOKENLIST_ALLOW_PTR 1 +# else +# define SIMPLECPP_TOKENLIST_ALLOW_PTR 0 # endif #endif @@ -141,7 +143,7 @@ namespace simplecpp { } unsigned int fileIndex{}; - unsigned int line{1}; + unsigned int line{}; unsigned int col{}; }; @@ -267,7 +269,7 @@ namespace simplecpp { TokenList(const unsigned char (&data)[size], std::vector &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr) : TokenList(data, size-1, filenames, filename, outputList, 0) {} -#ifdef SIMPLECPP_TOKENLIST_ALLOW_PTR +#if SIMPLECPP_TOKENLIST_ALLOW_PTR /** generates a token list from the given buffer */ TokenList(const unsigned char* data, std::size_t size, std::vector &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr) : TokenList(data, size, filenames, filename, outputList, 0) @@ -311,6 +313,10 @@ namespace simplecpp { std::string stringify(bool linenrs = false) const; void readfile(Stream &stream, const std::string &filename=std::string(), OutputList *outputList = nullptr); + /** + * @throws std::overflow_error thrown on overflow or division by zero + * @throws std::runtime_error thrown on invalid expressions + */ void constFold(); void removeComments(); From 2c53a923dce4fa46e32ffd3babd582570210e241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 27 Feb 2026 17:47:19 +0100 Subject: [PATCH 188/675] createrelease: added note about creating performance tracking ticket [skip ci] (#8263) the ticket is to track (potential) "regression" in performance across more versions than the actual daca analysis which only compares the latest against the previous version. --- createrelease | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/createrelease b/createrelease index 10c4dc92e35..95eb0db7638 100755 --- a/createrelease +++ b/createrelease @@ -109,6 +109,12 @@ # ssh -t danielmarjamaki,cppcheck@shell.sourceforge.net create # ./build-cppcheck.sh # +# create a ticket with data from http://cppcheck1.osuosl.org:8000/time_gt.html for performance tracking +# (example: https://trac.cppcheck.net/ticket/13715) +# - type: defect +# - component: Performance +# - summary: [meta] performance regressions in 2.x +# # run daca with new release # 1. edit tools/donate-cpu-server.py. Update OLD_VERSION and SERVER_VERSION # 2. scp -i ~/.ssh/osuosl_id_rsa tools/donate-cpu-server.py danielmarjamaki@cppcheck1.osuosl.org:/var/daca@home/ From 0580f2b127948e441826487bcef9f9a9aaef1727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 27 Feb 2026 18:39:40 +0100 Subject: [PATCH 189/675] refs #13810 - fixed missing column for `invalidSuppression` (#8121) --- cli/cppcheckexecutor.cpp | 2 +- lib/cppcheck.cpp | 2 +- lib/preprocessor.cpp | 105 ++++++++++++++++++++++---------------- lib/preprocessor.h | 8 +-- lib/suppressions.h | 3 ++ test/cli/project_test.py | 2 +- test/testsuppressions.cpp | 44 ++++++++-------- 7 files changed, 94 insertions(+), 72 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index d9705307584..6744a2e50d8 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -329,7 +329,7 @@ static std::vector getUnmatchedSuppressions(const std::list callStack; if (!s.fileName.empty()) { - callStack.emplace_back(s.fileName, s.lineNumber == -1 ? 0 : s.lineNumber, 0); // TODO: get rid of s.lineNumber == -1 hack + callStack.emplace_back(s.fileName, s.lineNumber == -1 ? 0 : s.lineNumber, 0); // TODO: set column - see #13810 / get rid of s.lineNumber == -1 hack } const std::string unmatchedSuppressionId = s.isPolyspace ? "unmatchedPolyspaceSuppression" : "unmatchedSuppression"; errors.emplace_back(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, unmatchedSuppressionId, Certainty::normal); diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index d74c19f4ea7..200895e3050 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1161,7 +1161,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str if (!hasValidConfig && currCfg == *configurations.rbegin()) { // If there is no valid configuration then report error.. - preprocessor.error(tokensP.file(o->location), o->location.line, o->location.col, o->msg, o->type); + preprocessor.error(o->location, o->msg, o->type); } skipCfg = true; } diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index a028fc5b864..50db3dd34a6 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -72,15 +72,13 @@ Preprocessor::Preprocessor(simplecpp::TokenList& tokens, const Settings& setting namespace { struct BadInlineSuppression { - BadInlineSuppression(std::string file, const int line, unsigned int col, std::string msg) : file(std::move(file)), line(line), col(col), errmsg(std::move(msg)) {} - std::string file; - int line; // TODO: needs to be unsigned - unsigned int col; + BadInlineSuppression(const simplecpp::Location& loc, std::string msg) : location(loc), errmsg(std::move(msg)) {} + simplecpp::Location location; std::string errmsg; }; } -static bool parseInlineSuppressionCommentToken(const simplecpp::TokenList &tokens, const simplecpp::Token *tok, std::list &inlineSuppressions, std::list &bad) +static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std::list &inlineSuppressions, std::list &bad) { const std::string cppchecksuppress("cppcheck-suppress"); @@ -93,7 +91,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::TokenList &token if (comment.substr(pos1, cppchecksuppress.size()) != cppchecksuppress) return false; if (pos1 + cppchecksuppress.size() >= comment.size()) { - bad.emplace_back(tokens.file(tok->location), tok->location.line, 0, "suppression without error ID"); + bad.emplace_back(tok->location, "suppression without error ID"); return false; } @@ -103,7 +101,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::TokenList &token // skip spaces after "cppcheck-suppress" and its possible prefix const std::string::size_type pos2 = comment.find_first_not_of(' ', posEndComment); if (pos2 == std::string::npos) { - bad.emplace_back(tokens.file(tok->location), tok->location.line, 0, "suppression without error ID"); + bad.emplace_back(tok->location, "suppression without error ID"); return false; } @@ -113,7 +111,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::TokenList &token if (posEndComment >= (pos1 + cppchecksuppress.size() + 1)) { const std::string suppressCmdString = comment.substr(pos1, pos2-pos1-1); if (comment.at(pos1 + cppchecksuppress.size()) != '-') { - bad.emplace_back(tokens.file(tok->location), tok->location.line, 0, "unknown suppression type '" + suppressCmdString + "'"); // TODO: set column + bad.emplace_back(tok->location, "unknown suppression type '" + suppressCmdString + "'"); return false; } @@ -132,7 +130,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::TokenList &token else if ("macro" == suppressTypeString) errorType = SuppressionList::Type::macro; else { - bad.emplace_back(tokens.file(tok->location), tok->location.line, 0, "unknown suppression type '" + suppressCmdString + "'"); // TODO: set column + bad.emplace_back(tok->location, "unknown suppression type '" + suppressCmdString + "'"); return false; } } @@ -146,11 +144,12 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::TokenList &token s.isInline = true; s.type = errorType; s.lineNumber = tok->location.line; + s.column = tok->location.col; } // TODO: return false? if (!errmsg.empty()) - bad.emplace_back(tokens.file(tok->location), tok->location.line, tok->location.col, std::move(errmsg)); + bad.emplace_back(tok->location, std::move(errmsg)); // TODO: report ones without ID - return false? std::copy_if(suppressions.cbegin(), suppressions.cend(), std::back_inserter(inlineSuppressions), [](const SuppressionList::Suppression& s) { @@ -166,6 +165,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::TokenList &token s.isInline = true; s.type = errorType; s.lineNumber = tok->location.line; + s.column = tok->location.col; // TODO: report when no ID - unreachable? if (!s.errorId.empty()) @@ -174,7 +174,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::TokenList &token // TODO: unreachable? // TODO: return false? if (!errmsg.empty()) - bad.emplace_back(tokens.file(tok->location), tok->location.line, tok->location.col, std::move(errmsg)); + bad.emplace_back(tok->location, std::move(errmsg)); } return true; @@ -213,7 +213,7 @@ static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Sett if (polyspace::isPolyspaceComment(tok->str())) { inlineSuppressions = polyspaceParser.parse(tok->str(), tok->location.line, getRelativeFilename(tokens, tok, settings)); } else { - if (!parseInlineSuppressionCommentToken(tokens, tok, inlineSuppressions, bad)) + if (!parseInlineSuppressionCommentToken(tok, inlineSuppressions, bad)) continue; if (!sameline(tok->previous, tok)) { @@ -222,7 +222,7 @@ static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Sett tok = tok->next; while (tok->comment) { - parseInlineSuppressionCommentToken(tokens, tok, inlineSuppressions, bad); + parseInlineSuppressionCommentToken(tok, inlineSuppressions, bad); if (tok->next) { tok = tok->next; } else { @@ -255,6 +255,7 @@ static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Sett // Add the suppressions. for (SuppressionList::Suppression &suppr : inlineSuppressions) { suppr.fileName = relativeFilename; + suppr.fileIndex = tok->location.fileIndex; if (SuppressionList::Type::block == suppr.type) { suppressions.addSuppression(std::move(suppr)); @@ -278,6 +279,7 @@ static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Sett suppr.lineBegin = supprBegin->lineNumber; suppr.lineEnd = suppr.lineNumber; suppr.lineNumber = supprBegin->lineNumber; + suppr.column = supprBegin->column; suppr.type = SuppressionList::Type::block; inlineSuppressionsBlockBegin.erase(supprBegin); suppressions.addSuppression(std::move(suppr)); // TODO: check result @@ -289,8 +291,12 @@ static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Sett } if (throwError) { + simplecpp::Location loc; // NOLINTNEXTLINE(bugprone-use-after-move) - moved only when thrownError is false - bad.emplace_back(suppr.fileName, suppr.lineNumber, 0, "Suppress End: No matching begin"); // TODO: set column + loc.fileIndex = suppr.fileIndex; + loc.line = suppr.lineNumber; + loc.col = suppr.column; + bad.emplace_back(loc, "Suppress End: No matching begin"); } } else if (SuppressionList::Type::unique == suppr.type || suppr.type == SuppressionList::Type::macro) { // special handling when suppressing { warnings for backwards compatibility @@ -304,20 +310,30 @@ static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Sett suppr.thisAndNextLine = thisAndNextLine; suppr.lineNumber = tok->location.line; + suppr.column = tok->location.col; suppr.macroName = macroName; suppressions.addSuppression(std::move(suppr)); // TODO: check result } else if (SuppressionList::Type::file == suppr.type) { if (onlyComments) suppressions.addSuppression(std::move(suppr)); // TODO: check result - else - bad.emplace_back(suppr.fileName, suppr.lineNumber, 0, "File suppression should be at the top of the file"); // TODO: set column + else { + simplecpp::Location loc; + loc.fileIndex = suppr.fileIndex; + loc.line = suppr.lineNumber; + loc.col = suppr.column; + bad.emplace_back(loc, "File suppression should be at the top of the file"); + } } } } - for (const SuppressionList::Suppression & suppr: inlineSuppressionsBlockBegin) - // cppcheck-suppress useStlAlgorithm - bad.emplace_back(suppr.fileName, suppr.lineNumber, 0, "Suppress Begin: No matching end"); // TODO: set column + for (const SuppressionList::Suppression & suppr: inlineSuppressionsBlockBegin) { + simplecpp::Location loc; + loc.fileIndex = suppr.fileIndex; + loc.line = suppr.lineNumber; + loc.col = suppr.column; + bad.emplace_back(loc, "Suppress Begin: No matching end"); + } } void Preprocessor::inlineSuppressions(SuppressionList &suppressions) @@ -330,7 +346,7 @@ void Preprocessor::inlineSuppressions(SuppressionList &suppressions) ::addInlineSuppressions(filedata->tokens, mSettings, suppressions, err); } for (const BadInlineSuppression &bad : err) { - invalidSuppression(bad.file, bad.line, bad.col, bad.errmsg); // TODO: column is always 0 + invalidSuppression(bad.location, bad.errmsg); } } @@ -937,7 +953,7 @@ const simplecpp::Output* Preprocessor::reportOutput(const simplecpp::OutputList case simplecpp::Output::ERROR: out_ret = &out; if (!startsWith(out.msg,"#error") || showerror) - error(mTokens.file(out.location), out.location.line, out.location.col, out.msg, out.type); + error(out.location, out.msg, out.type); break; case simplecpp::Output::WARNING: case simplecpp::Output::PORTABILITY_BACKSLASH: @@ -947,20 +963,20 @@ const simplecpp::Output* Preprocessor::reportOutput(const simplecpp::OutputList const std::string::size_type pos1 = out.msg.find_first_of("<\""); const std::string::size_type pos2 = out.msg.find_first_of(">\"", pos1 + 1U); if (pos1 < pos2 && pos2 != std::string::npos) - missingInclude(mTokens.file(out.location), out.location.line, out.location.col, out.msg.substr(pos1+1, pos2-pos1-1), out.msg[pos1] == '\"' ? UserHeader : SystemHeader); + missingInclude(out.location, out.msg.substr(pos1+1, pos2-pos1-1), out.msg[pos1] == '\"' ? UserHeader : SystemHeader); } break; case simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY: case simplecpp::Output::SYNTAX_ERROR: case simplecpp::Output::UNHANDLED_CHAR_ERROR: out_ret = &out; - error(mTokens.file(out.location), out.location.line, out.location.col, out.msg, out.type); + error(out.location, out.msg, out.type); break; case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND: case simplecpp::Output::FILE_NOT_FOUND: case simplecpp::Output::DUI_ERROR: out_ret = &out; - error("", 0, 0, out.msg, out.type); + error({}, out.msg, out.type); break; } } @@ -995,20 +1011,20 @@ static std::string simplecppErrToId(simplecpp::Output::Type type) cppcheck::unreachable(); } -void Preprocessor::error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, simplecpp::Output::Type type) +void Preprocessor::error(const simplecpp::Location& loc, const std::string &msg, simplecpp::Output::Type type) { - error(filename, linenr, col, msg, simplecppErrToId(type)); + error(loc, msg, simplecppErrToId(type)); } -void Preprocessor::error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, const std::string& id) +void Preprocessor::error(const simplecpp::Location& loc, const std::string &msg, const std::string& id) { std::list locationList; - if (!filename.empty()) { - std::string file = Path::fromNativeSeparators(filename); + if (!mTokens.file(loc).empty()) { + std::string file = Path::fromNativeSeparators(mTokens.file(loc)); if (mSettings.relativePaths) file = Path::getRelativePath(file, mSettings.basePaths); - locationList.emplace_back(file, linenr, col); + locationList.emplace_back(file, loc.line, loc.col); } mErrorLogger.reportErr(ErrorMessage(std::move(locationList), mFile0, @@ -1019,15 +1035,15 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, unsig } // Report that include is missing -void Preprocessor::missingInclude(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &header, HeaderTypes headerType) +void Preprocessor::missingInclude(const simplecpp::Location& loc, const std::string &header, HeaderTypes headerType) { if (!mSettings.checks.isEnabled(Checks::missingInclude)) return; std::list locationList; - if (!filename.empty()) { + if (!mTokens.file(loc).empty()) { // TODO: add relative path handling? - locationList.emplace_back(filename, linenr, col); + locationList.emplace_back(mTokens.file(loc), loc.line, loc.col); } ErrorMessage errmsg(std::move(locationList), mFile0, Severity::information, (headerType==SystemHeader) ? @@ -1038,9 +1054,9 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line mErrorLogger.reportErr(errmsg); } -void Preprocessor::invalidSuppression(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg) +void Preprocessor::invalidSuppression(const simplecpp::Location& loc, const std::string &msg) { - error(filename, linenr, col, msg, "invalidSuppression"); + error(loc, msg, "invalidSuppression"); } void Preprocessor::getErrorMessages(ErrorLogger &errorLogger, const Settings &settings) @@ -1048,14 +1064,17 @@ void Preprocessor::getErrorMessages(ErrorLogger &errorLogger, const Settings &se std::vector files; simplecpp::TokenList tokens(files); Preprocessor preprocessor(tokens, settings, errorLogger, Standards::Language::CPP); - preprocessor.missingInclude("", 1, 2, "", UserHeader); - preprocessor.missingInclude("", 1, 2, "", SystemHeader); - preprocessor.error("", 1, 2, "message", simplecpp::Output::ERROR); - preprocessor.error("", 1, 2, "message", simplecpp::Output::SYNTAX_ERROR); - preprocessor.error("", 1, 2, "message", simplecpp::Output::UNHANDLED_CHAR_ERROR); - preprocessor.error("", 1, 2, "message", simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY); - preprocessor.error("", 1, 2, "message", simplecpp::Output::FILE_NOT_FOUND); - preprocessor.invalidSuppression("", 1, 2, "message"); + simplecpp::Location loc; + loc.line = 1; + loc.col = 2; + preprocessor.missingInclude(loc, "", UserHeader); + preprocessor.missingInclude(loc, "", SystemHeader); + preprocessor.error(loc, "message", simplecpp::Output::ERROR); + preprocessor.error(loc, "message", simplecpp::Output::SYNTAX_ERROR); + preprocessor.error(loc, "message", simplecpp::Output::UNHANDLED_CHAR_ERROR); + preprocessor.error(loc, "message", simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY); + preprocessor.error(loc, "message", simplecpp::Output::FILE_NOT_FOUND); + preprocessor.invalidSuppression(loc, "message"); } void Preprocessor::dump(std::ostream &out) const diff --git a/lib/preprocessor.h b/lib/preprocessor.h index f8f213b13df..a211341691f 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -141,7 +141,7 @@ class CPPCHECKLIB WARN_UNUSED Preprocessor { const simplecpp::Output* reportOutput(const simplecpp::OutputList &outputList, bool showerror); - void error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, simplecpp::Output::Type type); + void error(const simplecpp::Location& loc, const std::string &msg, simplecpp::Output::Type type); const simplecpp::Output* handleErrors(const simplecpp::OutputList &outputList); @@ -156,9 +156,9 @@ class CPPCHECKLIB WARN_UNUSED Preprocessor { SystemHeader }; - void missingInclude(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &header, HeaderTypes headerType); - void invalidSuppression(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg); - void error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, const std::string& id); + void missingInclude(const simplecpp::Location& loc, const std::string &header, HeaderTypes headerType); + void invalidSuppression(const simplecpp::Location& loc, const std::string &msg); + void error(const simplecpp::Location& loc, const std::string &msg, const std::string& id); void addRemarkComments(const simplecpp::TokenList &tokens, std::vector &remarkComments) const; diff --git a/lib/suppressions.h b/lib/suppressions.h index eb6bf0bbace..d164aa0caa4 100644 --- a/lib/suppressions.h +++ b/lib/suppressions.h @@ -151,9 +151,12 @@ class CPPCHECKLIB SuppressionList { std::string errorId; std::string fileName; std::string extraComment; + // TODO: use simplecpp::Location? + int fileIndex{}; int lineNumber = NO_LINE; // TODO: needs to be unsigned int lineBegin = NO_LINE; int lineEnd = NO_LINE; + int column{}; Type type = Type::unique; std::string symbolName; std::string macroName; diff --git a/test/cli/project_test.py b/test/cli/project_test.py index ec1ef56d7d1..e8c120f2c08 100644 --- a/test/cli/project_test.py +++ b/test/cli/project_test.py @@ -64,7 +64,7 @@ def test_json_entry_file_not_found(tmpdir): "--project=" + str(project_file) ]) assert 0 == ret - assert stderr == f"nofile:0:0: error: File is missing: {missing_file_posix} [missingFile]\n" + assert stderr == f"{missing_file}:0:0: error: File is missing: {missing_file_posix} [missingFile]\n" def test_json_no_arguments(tmpdir): diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 2b87cdad42b..0e6bbffadc4 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -465,7 +465,7 @@ class TestSuppressions : public TestFixture { " a++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:2:0]: (error) File suppression should be at the top of the file [invalidSuppression]\n" + ASSERT_EQUALS("[test.cpp:2:5]: (error) File suppression should be at the top of the file [invalidSuppression]\n" "[test.cpp:4:5]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("void f() {\n" @@ -474,7 +474,7 @@ class TestSuppressions : public TestFixture { "}\n" "// cppcheck-suppress-file uninitvar\n", "")); - ASSERT_EQUALS("[test.cpp:5:0]: (error) File suppression should be at the top of the file [invalidSuppression]\n" + ASSERT_EQUALS("[test.cpp:5:1]: (error) File suppression should be at the top of the file [invalidSuppression]\n" "[test.cpp:3:5]: (error) Uninitialized variable: a [uninitvar]\n", errout_str()); ASSERT_EQUALS(0, (this->*check)("// cppcheck-suppress-file uninitvar\n" @@ -726,7 +726,7 @@ class TestSuppressions : public TestFixture { " b++;\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:2:0]: (error) Suppress Begin: No matching end [invalidSuppression]\n" + ASSERT_EQUALS("[test.cpp:2:5]: (error) Suppress Begin: No matching end [invalidSuppression]\n" "[test.cpp:4:5]: (error) Uninitialized variable: a [uninitvar]\n" "[test.cpp:6:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); @@ -738,7 +738,7 @@ class TestSuppressions : public TestFixture { " // cppcheck-suppress-end uninitvar\n" "}\n", "")); - ASSERT_EQUALS("[test.cpp:6:0]: (error) Suppress End: No matching begin [invalidSuppression]\n" + ASSERT_EQUALS("[test.cpp:6:5]: (error) Suppress End: No matching begin [invalidSuppression]\n" "[test.cpp:3:5]: (error) Uninitialized variable: a [uninitvar]\n" "[test.cpp:5:5]: (error) Uninitialized variable: b [uninitvar]\n", errout_str()); @@ -749,11 +749,11 @@ class TestSuppressions : public TestFixture { "void f() {}\n" "// cppcheck-suppress-end-unknown id4\n", "")); - ASSERT_EQUALS("[test.cpp:1:0]: (error) unknown suppression type 'cppcheck-suppress:' [invalidSuppression]\n" - "[test.cpp:2:0]: (error) unknown suppression type 'cppcheck-suppress-unknown' [invalidSuppression]\n" - "[test.cpp:3:0]: (error) unknown suppression type 'cppcheck-suppress-begin-unknown' [invalidSuppression]\n" - "[test.cpp:6:0]: (error) unknown suppression type 'cppcheck-suppress-end-unknown' [invalidSuppression]\n" - "[test.cpp:4:0]: (error) Suppress Begin: No matching end [invalidSuppression]\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:1]: (error) unknown suppression type 'cppcheck-suppress:' [invalidSuppression]\n" + "[test.cpp:2:1]: (error) unknown suppression type 'cppcheck-suppress-unknown' [invalidSuppression]\n" + "[test.cpp:3:1]: (error) unknown suppression type 'cppcheck-suppress-begin-unknown' [invalidSuppression]\n" + "[test.cpp:6:1]: (error) unknown suppression type 'cppcheck-suppress-end-unknown' [invalidSuppression]\n" + "[test.cpp:4:1]: (error) Suppress Begin: No matching end [invalidSuppression]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("// cppcheck-suppress-file\n" "// cppcheck-suppress\n" @@ -766,14 +766,14 @@ class TestSuppressions : public TestFixture { "void f() {}\n" "// cppcheck-suppress-end\n", "")); - ASSERT_EQUALS("[test.cpp:1:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:2:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:3:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:4:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:6:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:7:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:10:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:8:0]: (error) Suppress Begin: No matching end [invalidSuppression]\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:2:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:3:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:4:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:6:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:7:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:10:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:8:1]: (error) Suppress Begin: No matching end [invalidSuppression]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("// cppcheck-suppress:\n" "// cppcheck-suppress-unknown\n" @@ -783,11 +783,11 @@ class TestSuppressions : public TestFixture { "// cppcheck-suppress-end-unknown\n", "")); // TODO: actually these are all invalid types - ASSERT_EQUALS("[test.cpp:1:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:2:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:3:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:4:0]: (error) suppression without error ID [invalidSuppression]\n" - "[test.cpp:6:0]: (error) suppression without error ID [invalidSuppression]\n", errout_str()); + ASSERT_EQUALS("[test.cpp:1:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:2:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:3:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:4:1]: (error) suppression without error ID [invalidSuppression]\n" + "[test.cpp:6:1]: (error) suppression without error ID [invalidSuppression]\n", errout_str()); ASSERT_EQUALS(1, (this->*check)("void f() {\n" " int a;\n" From 1c1970956052d82a96e37450f08c3dad151ac0dd Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:06:25 +0100 Subject: [PATCH 190/675] Fix #7091 FN variableScope for variables used in inner loop (#8245) Co-authored-by: chrchr-github --- lib/checkother.cpp | 12 +++++++++++- test/testother.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index fb84001833c..4285154d841 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1331,6 +1331,15 @@ static bool mayDependOn(const ValueType *other, const ValueType *original) return otherPtr > originalPtr; } +static bool isOnlyUsedInCurrentScope(const Variable* var, const Token *tok, const Scope* scope) +{ + if (tok->scope() == scope) + return true; + if (tok->scope()->type == ScopeType::eSwitch) + return false; + return !Token::findmatch(tok->scope()->bodyEnd, "%varid%", scope->bodyEnd, var->declarationId()); +} + bool CheckOther::checkInnerScope(const Token *tok, const Variable* var, bool& used) const { const Scope* scope = tok->next()->scope(); @@ -1370,7 +1379,8 @@ bool CheckOther::checkInnerScope(const Token *tok, const Variable* var, bool& us if (tok == forHeadEnd) forHeadEnd = nullptr; - if (loopVariable && noContinue && tok->scope() == scope && !forHeadEnd && scope->type != ScopeType::eSwitch && Token::Match(tok, "%varid% =", var->declarationId())) { // Assigned in outer scope. + if (loopVariable && noContinue && !forHeadEnd && scope->type != ScopeType::eSwitch && Token::Match(tok, "%varid% =", var->declarationId()) && + isOnlyUsedInCurrentScope(var, tok, scope)) { // Assigned in outer scope. loopVariable = false; std::pair range = tok->next()->findExpressionStartEndTokens(); if (range.first) diff --git a/test/testother.cpp b/test/testother.cpp index 1a0eb713832..4727c15ef27 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -123,6 +123,7 @@ class TestOther : public TestFixture { TEST_CASE(varScope43); TEST_CASE(varScope44); TEST_CASE(varScope45); + TEST_CASE(varScope46); TEST_CASE(oldStylePointerCast); TEST_CASE(intToPointerCast); @@ -1984,6 +1985,49 @@ class TestOther : public TestFixture { ASSERT_EQUALS("[test.cpp:2:16]: (style) The scope of the variable 'b' can be reduced. [variableScope]\n", errout_str()); } + void varScope46() { + check("void f() {\n" // #7091 + " int y1;\n" + " for (int i = 0; i < 3; ++i) {\n" + " for(int j = 0; j < 3; ++j) {\n" + " y1 = 2 * 1;\n" + " y1 += 1;\n" + " }\n" + " }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:9]: (style) The scope of the variable 'y1' can be reduced. [variableScope]\n", + errout_str()); + + check("bool f() {\n" + "bool b = false;\n" + "do {\n" + " switch (g()) {\n" + " case 0:\n" + " b = true;\n" + " break;\n" + " case 1:\n" + " return b;\n" + " break;\n" + " default:\n" + " break;\n" + " }\n" + "}\n" + "while (true);\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + + check("void f() {\n" + " int y1 = 0;\n" + " for (int i = 0; i < 3; ++i) {\n" + " for(int j = 0; j < 3; ++j) {\n" + " y1 = y1 + 1;\n" + " dostuff(y1);\n" + " }\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + } + #define checkOldStylePointerCast(...) checkOldStylePointerCast_(__FILE__, __LINE__, __VA_ARGS__) template void checkOldStylePointerCast_(const char* file, int line, const char (&code)[size], Standards::cppstd_t std = Standards::CPPLatest) { From 9d674c2a5f42749a89ef5a7288e39379ed0a3242 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 28 Feb 2026 09:57:10 +0100 Subject: [PATCH 191/675] Fix #14544 FP nullPointerRedundantCheck (array argument) (#8271) --- lib/astutils.cpp | 2 +- test/testnullpointer.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index e140d965114..2330a9d2b94 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2499,7 +2499,7 @@ bool isMutableExpression(const Token* tok) if (const Variable* var = tok->variable()) { if (var->nameToken() == tok) return false; - if (!var->isPointer() && var->isConst()) + if (var->isConst() && !var->isPointer() && (!var->isArray() || !var->isArgument())) return false; } return true; diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index f2664b05285..37107397a44 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -995,6 +995,14 @@ class TestNullPointer : public TestFixture { "char f(S* s) { return s->p ? 'a' : s->p->c; }\n"); ASSERT_EQUALS("[test.cpp:2:24] -> [test.cpp:2:37]: (warning) Either the condition 's->p' is redundant or there is possible null pointer dereference: s->p. [nullPointerRedundantCheck]\n", errout_str()); + + check("int f(const int a[]) {\n" // #14544 + " int i = 0;\n" + " if (!a)\n" + " a = &i;\n" + " return *a;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void nullpointer5() { From 33bd6fb3e2d6ccbfb15ec5907637528506cc44f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 1 Mar 2026 18:58:18 +0100 Subject: [PATCH 192/675] CI-windows.yml: reverted accidental change of PCRE CMake flag (#8281) --- .github/workflows/CI-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index da5fe2df99e..764a6ae7f81 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -192,7 +192,7 @@ jobs: 7z x pcre-%PCRE_VERSION%.zip || exit /b !errorlevel! cd pcre-%PCRE_VERSION% || exit /b !errorlevel! git apply --ignore-space-change ..\externals\pcre.patch || exit /b !errorlevel! - cmake . -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DPCRE_BUILD_PCRECPP=Off -DPCRE_BUILD_TESTING=Off -DPCRE_BUILD_PCREGREP=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake . -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DPCRE_BUILD_PCRECPP=Off -DPCRE_BUILD_TESTS=Off -DPCRE_BUILD_PCREGREP=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! nmake || exit /b !errorlevel! copy pcre.h ..\externals || exit /b !errorlevel! copy pcre.lib ..\externals\pcre64.lib || exit /b !errorlevel! From f578aac581a333e422a376efd9a2ed62c6e47ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 1 Mar 2026 18:58:38 +0100 Subject: [PATCH 193/675] follow-up for #13050 - fixed CMake warning when `BUILD_TESTS` is not actually provided (#8277) --- cmake/options.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/options.cmake b/cmake/options.cmake index 4a315667093..67b34f7526b 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -56,7 +56,7 @@ option(BUILD_CORE_DLL "Build lib as cppcheck-core.dll with Visual Studio" if(BUILD_CORE_DLL AND NOT MSVC) message(FATAL_ERROR "Building of lib as DLL is only supported with Visual Studio") endif() -option(BUILD_TESTS "Build tests" OFF) +# need to check before the option() specifying it or it will be defined if(DEFINED BUILD_TESTS) message(WARNING "BUILD_TESTS has been deprecated and will be removed in Cppcheck 2.22 - please use BUILD_TESTING instead") if(DEFINED BUILD_TESTING) @@ -68,6 +68,7 @@ elseif(NOT DEFINED BUILD_TESTING) # disable tests by default - TODO: remove this set(BUILD_TESTING OFF) endif() +option(BUILD_TESTS "Build tests" OFF) option(REGISTER_TESTS "Register tests in CTest" ON) option(ENABLE_CHECK_INTERNAL "Enable internal checks" OFF) option(DISABLE_DMAKE "Disable run-dmake dependencies" OFF) From 02119e501814a248ad1a54433c6340827f100663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 1 Mar 2026 18:58:52 +0100 Subject: [PATCH 194/675] clang-tidy.yml: replaced obsolete `WARNINGS_ARE_ERRORS` with `CMAKE_COMPILE_WARNING_AS_ERROR` (#8279) --- .github/workflows/clang-tidy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 66528e96e52..a922d481674 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -61,7 +61,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -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 -DWARNINGS_ARE_ERRORS=On + cmake -S . -B cmake.output -G "Unix Makefiles" -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-22 CXX: clang++-22 From 09b909445cf61ba2dd447b0f93ec4ba175bca0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 1 Mar 2026 18:59:08 +0100 Subject: [PATCH 195/675] adjusted mode of some CMake messages (#8278) this allows CMake to fail with `-Werror=` is specified --- cmake/options.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/options.cmake b/cmake/options.cmake index 67b34f7526b..07c6f8d771d 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -25,7 +25,7 @@ option(ANALYZE_TYPE "Build with TypeSanitizer to detect aliasing issues" option(WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF) if(WARNINGS_ARE_ERRORS) if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") - message(WARNING "WARNINGS_ARE_ERRORS is deprecated - please use CMAKE_COMPILE_WARNING_AS_ERROR instead") + message(DEPRECATION "WARNINGS_ARE_ERRORS is deprecated - please use CMAKE_COMPILE_WARNING_AS_ERROR instead") endif() set(CMAKE_COMPILE_WARNING_AS_ERROR On) endif() @@ -58,9 +58,9 @@ if(BUILD_CORE_DLL AND NOT MSVC) endif() # need to check before the option() specifying it or it will be defined if(DEFINED BUILD_TESTS) - message(WARNING "BUILD_TESTS has been deprecated and will be removed in Cppcheck 2.22 - please use BUILD_TESTING instead") + message(DEPRECATION "BUILD_TESTS has been deprecated and will be removed in Cppcheck 2.22 - please use BUILD_TESTING instead") if(DEFINED BUILD_TESTING) - message(WARNING "BUILD_TESTS and BUILD_TESTING have been defined at the same time - ignoring BUILD_TESTS") + message(AUTHOR_WARNING "BUILD_TESTS and BUILD_TESTING have been defined at the same time - ignoring BUILD_TESTS") else() set(BUILD_TESTING "${BUILD_TESTS}") endif() From f27f35beb258d6440613de55314f32b165b89937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Mon, 2 Mar 2026 08:24:38 +0100 Subject: [PATCH 196/675] Fix #14494: FP syntaxError (parenthesis after if) (#8218) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 91481fa6172..301906e30fc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3788,7 +3788,7 @@ void Tokenizer::simplifyParenthesizedLibraryFunctions() if (!Token::simpleMatch(tok, ") (")) continue; Token *rpar = tok, *lpar = tok->link(); - if (!lpar || (Token::Match(lpar->previous(), "%name%") && !lpar->previous()->isKeyword())) + if (!lpar || (Token::Match(lpar->previous(), "%name%") && !Token::Match(lpar->previous(), "return|delete|throw"))) continue; const Token *ftok = rpar->previous(); if (mSettings.library.isNotLibraryFunction(ftok)) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index eff4a8d44f2..ee38b2a1dce 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -185,6 +185,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(removeParentheses27); TEST_CASE(removeParentheses28); // #12164 - don't remove parentheses in '(expr1) ? (expr2) : (expr3);' TEST_CASE(removeParantheses29); // #13735 + TEST_CASE(removeParentheses30); TEST_CASE(tokenize_double); TEST_CASE(tokenize_strings); @@ -2192,6 +2193,19 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(exp, tokenizeAndStringify(code)); } + void removeParentheses30() { + static char code[] = "void f (Node *node) {\n" + " if (node->data && (node->provider)->free)\n" + " (node->provider)->free (node);\n" + "}\n"; + static const char exp[] = "void f ( Node * node ) {\n" + "if ( node . data && ( node . provider ) . free ) {\n" + "node . provider . free ( node ) ; }\n" + "}"; + ASSERT_EQUALS(exp, tokenizeAndStringify(code)); + (void) errout_str(); + } + void tokenize_double() { const char code[] = "void f() {\n" " double a = 4.2;\n" From 25fe1de87fdf48b90d12c141ea39c4c4edb74e5a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 2 Mar 2026 10:42:03 +0100 Subject: [PATCH 197/675] Fix #14548 internalAstError for compound literal in ternary operator (#8283) --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 1138b410ddd..03095a40992 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -873,7 +873,7 @@ static void compileTerm(Token *&tok, AST_state& state) state.inArrayAssignment--; tok = tok1->link()->next(); } - } else if (!state.inArrayAssignment && !Token::simpleMatch(prev, "=")) { + } else if ((!state.inArrayAssignment && !Token::simpleMatch(prev, "=")) || Token::simpleMatch(prev, "?")) { state.op.push(tok); tok = tok->link()->next(); } else { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ee38b2a1dce..7aca456a445 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -426,6 +426,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(astrvaluedecl); TEST_CASE(astorkeyword); TEST_CASE(astenumdecl); + TEST_CASE(astcompound); TEST_CASE(startOfExecutableScope); @@ -7422,6 +7423,11 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("A0U=", testAst("enum myclass : unsigned char { A = 0U, };")); } + void astcompound() { + ASSERT_EQUALS("sn0=={(tmp:?=", testAst("Str s = n == 0 ? (Str) { 0 } : tmp;")); // #14548 + ASSERT_EQUALS("s(sstrlens(0:?,{(return", testAst("return (struct Str) { (unsigned char*)s, s ? strlen(s) : 0 };")); + } + #define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__) template bool isStartOfExecutableScope_(int offset, const char (&code)[size], const char* file, int line) { From 41770838fbbd81f0a39d64d45e8ec46b15d709a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 2 Mar 2026 12:33:40 +0100 Subject: [PATCH 198/675] fixed #14547 - store absolute path in `FileWithDetails` (fixes slow lead up to analysis with a lot of input files) (#8282) --- cli/cmdlineparser.cpp | 30 +++++++++++++++--------------- lib/filesettings.h | 10 ++++++++++ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index c017e238409..e5c990ab494 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -206,8 +206,6 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) assert(!(!pathnamesRef.empty() && !fileSettingsRef.empty())); if (!fileSettingsRef.empty()) { - // TODO: de-duplicate - std::list fileSettings; if (!mSettings.fileFilters.empty()) { // filter only for the selected filenames from all project files @@ -225,6 +223,8 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) fileSettings = fileSettingsRef; } + // TODO: de-duplicate + mFileSettings.clear(); frontend::applyLang(fileSettings, mSettings, mEnforcedLang); @@ -265,19 +265,6 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) return false; } - // de-duplicate files - { - auto it = filesResolved.begin(); - while (it != filesResolved.end()) { - const std::string& absname = Path::getAbsoluteFilePath(it->spath()); - // TODO: log if duplicated files were dropped - filesResolved.erase(std::remove_if(std::next(it), filesResolved.end(), [&](const FileWithDetails& entry) { - return Path::getAbsoluteFilePath(entry.spath()) == absname; - }), filesResolved.end()); - ++it; - } - } - std::list files; if (!mSettings.fileFilters.empty()) { files = filterFiles(mSettings.fileFilters, filesResolved); @@ -291,6 +278,19 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) files = std::move(filesResolved); } + // de-duplicate files + { + auto it = files.begin(); + while (it != files.end()) { + const std::string& absname = it->abspath(); + // TODO: log if duplicated files were dropped + files.erase(std::remove_if(std::next(it), files.end(), [&](const FileWithDetails& entry) { + return entry.abspath() == absname; + }), files.end()); + ++it; + } + } + frontend::applyLang(files, mSettings, mEnforcedLang); // sort the markup last diff --git a/lib/filesettings.h b/lib/filesettings.h index b51f092d6b4..aaa2f28779a 100644 --- a/lib/filesettings.h +++ b/lib/filesettings.h @@ -50,6 +50,7 @@ class FileWithDetails { mPath = std::move(path); mPathSimplified = Path::simplifyPath(mPath); + mPathAbsolute.clear(); } const std::string& path() const @@ -62,6 +63,14 @@ class FileWithDetails return mPathSimplified; } + const std::string& abspath() const + { + // use delayed resolution as it will fail for files which do not exist + if (mPathAbsolute.empty()) + mPathAbsolute = Path::getAbsoluteFilePath(mPath); + return mPathAbsolute; + } + std::size_t size() const { return mSize; @@ -89,6 +98,7 @@ class FileWithDetails private: std::string mPath; std::string mPathSimplified; + mutable std::string mPathAbsolute; Standards::Language mLang = Standards::Language::None; std::size_t mSize; std::size_t mFsFileId{0}; From f309bf23c0a9a28b6ca7c2a55a04b0e43449df76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 2 Mar 2026 12:34:47 +0100 Subject: [PATCH 199/675] fixed #14081 - fail builds in CI on CMake warnings (#8273) --- .github/workflows/CI-unixish-docker.yml | 2 +- .github/workflows/CI-unixish.yml | 42 ++++++++++++------------- .github/workflows/CI-windows.yml | 6 ++-- .github/workflows/asan.yml | 2 +- .github/workflows/clang-tidy.yml | 2 +- .github/workflows/iwyu.yml | 4 +-- .github/workflows/release-windows.yml | 2 +- .github/workflows/selfcheck.yml | 10 +++--- .github/workflows/tsan.yml | 2 +- .github/workflows/ubsan.yml | 2 +- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/CI-unixish-docker.yml b/.github/workflows/CI-unixish-docker.yml index a457799a92b..e254c1e986f 100644 --- a/.github/workflows/CI-unixish-docker.yml +++ b/.github/workflows/CI-unixish-docker.yml @@ -57,7 +57,7 @@ jobs: - name: Run CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: CMake build (with GUI) run: | diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index b90e964eebb..fabe0832f4b 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -58,13 +58,13 @@ jobs: - name: CMake build on ubuntu (with GUI / system tinyxml2) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output.tinyxml2 -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: CMake build on macos (with GUI / system tinyxml2) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output.tinyxml2 -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: Run CMake test (system tinyxml2) @@ -127,12 +127,12 @@ jobs: - name: Run CMake on ubuntu (with GUI) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install - name: Run CMake on macos (with GUI) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 - name: Run CMake build run: | @@ -154,13 +154,13 @@ jobs: - name: Run CMake on ubuntu (no CLI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off + cmake -S . -B cmake.output_nocli -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off - name: Run CMake on ubuntu (no CLI / with tests) if: matrix.os == 'ubuntu-22.04' run: | # the test and CLI code are too intertwined so for now we need to reject that - if cmake -S . -B cmake.output_nocli_tests -G "Unix Makefiles" -DBUILD_TESTING=On -DBUILD_CLI=Off; then + if cmake -S . -B cmake.output_nocli_tests -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DBUILD_CLI=Off; then exit 1 else exit 0 @@ -169,18 +169,18 @@ jobs: - name: Run CMake on ubuntu (no CLI / with GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli_gui -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=On + cmake -S . -B cmake.output_nocli_gui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=On - name: Run CMake on ubuntu (no GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nogui -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off + cmake -S . -B cmake.output_nogui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off - name: Run CMake on ubuntu (no GUI / with triage) if: matrix.os == 'ubuntu-22.04' run: | # cannot build triage without GUI - if cmake -S . -B cmake.output_nogui_triage -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then + if cmake -S . -B cmake.output_nogui_triage -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then exit 1 else exit 0 @@ -189,7 +189,7 @@ jobs: - name: Run CMake on ubuntu (no CLI / no GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli_nogui -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off + cmake -S . -B cmake.output_nocli_nogui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off build_cmake_cxxstd: @@ -243,12 +243,12 @@ jobs: - name: Run CMake on ubuntu (with GUI) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Run CMake on macos (with GUI) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 - name: Run CMake build run: | @@ -373,7 +373,7 @@ jobs: run: | # make sure we fail when Boost is requested and not available. # will fail because no package configuration is available. - if cmake -S . -B cmake.output.boost-force-noavail -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On; then + if cmake -S . -B cmake.output.boost-force-noavail -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On; then exit 1 else exit 0 @@ -386,12 +386,12 @@ jobs: - name: Run CMake on macOS (force Boost) run: | - cmake -S . -B cmake.output.boost-force -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On + cmake -S . -B cmake.output.boost-force -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On - name: Run CMake on macOS (no Boost) run: | # make sure Boost is not used when disabled even though it is available - cmake -S . -B cmake.output.boost-no -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=Off + cmake -S . -B cmake.output.boost-no -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=Off if grep -q '\-DHAVE_BOOST' ./cmake.output.boost-no/compile_commands.json; then exit 1 else @@ -400,7 +400,7 @@ jobs: - name: Run CMake on macOS (with Boost) run: | - cmake -S . -B cmake.output.boost -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output.boost -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache grep -q '\-DHAVE_BOOST' ./cmake.output.boost/compile_commands.json - name: Build with CMake on macOS (with Boost) @@ -436,12 +436,12 @@ jobs: - name: Run CMake (without GUI) run: | export PATH=cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64/bin:$PATH - cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On - name: Run CMake (with GUI) run: | export PATH=cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64/bin:$PATH - cmake -S . -B cmake.output.gui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On + cmake -S . -B cmake.output.gui -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On build: @@ -596,7 +596,7 @@ jobs: - name: Test Signalhandler run: | - cmake -S . -B build.cmake.signal -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On + cmake -S . -B build.cmake.signal -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On cmake --build build.cmake.signal --target test-signalhandler -- -j$(nproc) # TODO: how to run this without copying the file? cp build.cmake.signal/bin/test-s* . @@ -607,7 +607,7 @@ jobs: - name: Test Stacktrace if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B build.cmake.stack -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On + cmake -S . -B build.cmake.stack -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On cmake --build build.cmake.stack --target test-stacktrace -- -j$(nproc) # TODO: how to run this without copying the file? cp build.cmake.stack/bin/test-s* . @@ -721,7 +721,7 @@ jobs: - name: CMake run: | - cmake -S . -B cmake.output -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On + cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On - name: Generate dependencies run: | diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index 764a6ae7f81..c993c57753a 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -53,7 +53,7 @@ jobs: run: | rem TODO: enable rules? rem specify Release build so matchcompiler is used - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DBUILD_TESTING=Off -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DBUILD_ONLINE_HELP=On -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake -S . -B build -Werror=dev -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DBUILD_TESTING=Off -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DBUILD_ONLINE_HELP=On -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! - name: Build GUI release run: | @@ -92,7 +92,7 @@ jobs: - name: Run CMake run: | - cmake -S . -B build.cxxstd -G "Visual Studio 17 2022" -A x64 -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake -S . -B build.cxxstd -Werror=dev -G "Visual Studio 17 2022" -A x64 -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! - name: Build run: | @@ -272,7 +272,7 @@ jobs: - name: Test SEH wrapper if: matrix.config == 'release' run: | - cmake -S . -B build.cmake.seh -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake -S . -B build.cmake.seh -Werror=dev -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! cmake --build build.cmake.seh --target test-sehwrapper || exit /b !errorlevel! :: TODO: how to run this without copying the file? copy build.cmake.seh\bin\Debug\test-sehwrapper.exe . || exit /b !errorlevel! diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index c52dc70420a..38e90cb760a 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -74,7 +74,7 @@ jobs: - name: CMake run: | - cmake -S . -B cmake.output -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 + 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-22 CXX: clang++-22 diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index a922d481674..540e5770382 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -61,7 +61,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -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 + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -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-22 CXX: clang++-22 diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 6af371d035b..9ac43313671 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -128,7 +128,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -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.stdlib == 'libc++' }} + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -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.stdlib == 'libc++' }} env: CC: clang CXX: clang++ @@ -236,7 +236,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -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 }} + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -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-22 CXX: clang++-22 diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 07a52f27fdc..20868c1c607 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -79,7 +79,7 @@ jobs: run: | :: TODO: enable rules? :: specify Release build so matchcompiler is used - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=Off -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On -DUSE_BOOST=ON -DBOOST_INCLUDEDIR=%GITHUB_WORKSPACE%\boost -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! + cmake -S . -B build -Werror=dev -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=Off -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On -DUSE_BOOST=ON -DBOOST_INCLUDEDIR=%GITHUB_WORKSPACE%\boost -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel! cmake --build build --target cppcheck-gui --config Release || exit /b !errorlevel! # TODO: package PDBs diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index a7af97d89cc..aa5b61d859b 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -64,7 +64,7 @@ jobs: # unusedFunction - start - name: CMake run: | - cmake -S . -B cmake.output -G "Unix Makefiles" -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 + cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -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 - name: Generate dependencies run: | @@ -90,7 +90,7 @@ jobs: # unusedFunction notest - start - name: CMake (no test) run: | - cmake -S . -B cmake.output.notest -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_GUI=ON -DBUILD_TRIAGE=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_GUI=ON -DBUILD_TRIAGE=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test) run: | @@ -112,7 +112,7 @@ jobs: # unusedFunction notest nogui - start - name: CMake (no test / no gui) run: | - cmake -S . -B cmake.output.notest_nogui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest_nogui -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test / no gui) run: | @@ -131,7 +131,7 @@ jobs: # unusedFunction notest nocli - start - name: CMake (no test / no cli) run: | - cmake -S . -B cmake.output.notest_nocli -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -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 + cmake -S . -B cmake.output.notest_nocli -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -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 - name: Generate dependencies (no test / no cli) run: | @@ -154,7 +154,7 @@ jobs: # unusedFunction notest nocli nogui - start - name: CMake (no test / no cli / no gui) run: | - cmake -S . -B cmake.output.notest_nocli_nogui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest_nocli_nogui -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test / no cli / no gui) run: | diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml index cca77bc9a6c..72b1764d11d 100644 --- a/.github/workflows/tsan.yml +++ b/.github/workflows/tsan.yml @@ -73,7 +73,7 @@ jobs: - name: CMake run: | - cmake -S . -B cmake.output -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 + 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-22 CXX: clang++-22 diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index 1502babdcdc..5afc5feb1f9 100644 --- a/.github/workflows/ubsan.yml +++ b/.github/workflows/ubsan.yml @@ -73,7 +73,7 @@ jobs: - name: CMake run: | - cmake -S . -B cmake.output -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 + 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-22 CXX: clang++-22 From 4cf551f7a7ebac0035b80498974c9de39802871b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 2 Mar 2026 12:51:13 +0100 Subject: [PATCH 200/675] AUTHORS: Add Florian Mueller [skip ci] (#8287) --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 2642df52431..0d9ea7d27d6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -131,6 +131,7 @@ Felix Faber Felix Geyer Felix Passenberg Felix Wolff +Florian Mueller Florin Iucha flovent Francesc Elies From be92fb5adfcf1d16b170500f43d9dba71dcc1c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 2 Mar 2026 12:51:56 +0100 Subject: [PATCH 201/675] Run tools/get_checkers.py to update checkers report (#8284) --- lib/checkers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checkers.cpp b/lib/checkers.cpp index e374058f332..f7d7f913da6 100644 --- a/lib/checkers.cpp +++ b/lib/checkers.cpp @@ -41,7 +41,7 @@ namespace checkers { {"CheckBufferOverrun::analyseWholeProgram",""}, {"CheckBufferOverrun::argumentSize","warning"}, {"CheckBufferOverrun::arrayIndex",""}, - {"CheckBufferOverrun::arrayIndexThenCheck",""}, + {"CheckBufferOverrun::arrayIndexThenCheck","style"}, {"CheckBufferOverrun::bufferOverflow",""}, {"CheckBufferOverrun::negativeArraySize",""}, {"CheckBufferOverrun::objectIndex",""}, From e190b2e13c8ca30db25c18a55fced8cd28abdc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 2 Mar 2026 13:09:52 +0100 Subject: [PATCH 202/675] Release: Update ts files [skip ci] (#8288) --- gui/cppcheck_de.ts | 624 +++++++++++++++++++++-------------------- gui/cppcheck_es.ts | 622 +++++++++++++++++++++-------------------- gui/cppcheck_fi.ts | 622 +++++++++++++++++++++-------------------- gui/cppcheck_fr.ts | 622 +++++++++++++++++++++-------------------- gui/cppcheck_it.ts | 622 +++++++++++++++++++++-------------------- gui/cppcheck_ja.ts | 626 ++++++++++++++++++++++-------------------- gui/cppcheck_ka.ts | 624 +++++++++++++++++++++-------------------- gui/cppcheck_ko.ts | 622 +++++++++++++++++++++-------------------- gui/cppcheck_nl.ts | 622 +++++++++++++++++++++-------------------- gui/cppcheck_ru.ts | 624 +++++++++++++++++++++-------------------- gui/cppcheck_sr.ts | 622 +++++++++++++++++++++-------------------- gui/cppcheck_sv.ts | 624 +++++++++++++++++++++-------------------- gui/cppcheck_zh_CN.ts | 624 +++++++++++++++++++++-------------------- gui/cppcheck_zh_TW.ts | 624 +++++++++++++++++++++-------------------- 14 files changed, 4530 insertions(+), 4194 deletions(-) diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index 0197f93c728..c0d68ed6d8a 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -334,40 +334,40 @@ Parameter: -l(line) (file) Bearbeiten
- - + + Library files (*.cfg) Bibliotheksdateien (*.cfg) - + Open library file Bibliothek öffnen - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Datei %1 kann nicht geöffnet werden. - + Failed to load %1. %2. %1 kann nicht geladen werden. %2. - + Cannot save file %1. Datei %1 kann nicht gespeichert werden. - + Save the library as Speichere Bibliothek unter @@ -496,25 +496,25 @@ Parameter: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck - + Standard Standard @@ -534,236 +534,236 @@ Parameter: -l(line) (file) &Symbolleisten
- + A&nalyze A&nalysieren - + C++ standard C++-Standard - + &C standard &C-Standard - + &Edit &Bearbeiten - + &License... &Lizenz... - + A&uthors... &Autoren... - + &About... Ü&ber... - + &Files... &Dateien... - - + + Analyze files Analysiere Dateien - + Ctrl+F Strg+F - + &Directory... &Verzeichnis... - - + + Analyze directory Analysiere Verzeichnis - + Ctrl+D Strg+D - + Ctrl+R Strg+R - + &Stop &Stoppen - - + + Stop analysis Analyse abbrechen - + Esc Esc - + &Save results to file... &Ergebnisse in Datei speichern... - + Ctrl+S Strg+S - + &Quit &Beenden - + &Clear results Ergebnisse &löschen - + &Preferences &Einstellungen - - - + + + Show errors Zeige Fehler - - - + + + Show warnings Zeige Warnungen - - + + Show performance warnings Zeige Performance-Warnungen - + Show &hidden Zeige &versteckte - + Information Information - + Show information messages Zeige Informationsmeldungen - + Show portability warnings Zeige Portabilitätswarnungen - + Show Cppcheck results Zeige Cppcheck-Ergebnisse - + Clang Clang - + Show Clang results Zeige Clang-Ergebnisse - + &Filter &Filter - + Filter results Gefilterte Ergebnisse - + Windows 32-bit ANSI Windows 32-bit, ANSI - + Windows 32-bit Unicode Windows 32-bit, Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - + &Print... Drucken... - + Print the Current Report Aktuellen Bericht ausdrucken - + Print Pre&view... Druckvorschau - + Open a Print Preview Dialog for the Current Results Druckvorschaudialog für aktuelle Ergebnisse öffnen - + Open library editor Bibliothekseditor öffnen - + &Check all Alle &auswählen @@ -779,324 +779,334 @@ Parameter: -l(line) (file)
- + Report - + Filter Filter - + &Reanalyze modified files Veränderte Dateien neu analysieren - + Reanal&yze all files Alle Dateien erneut anal&ysieren - + Ctrl+Q - + Style war&nings Stilwar&nungen - + E&rrors F&ehler - + &Uncheck all Alle a&bwählen - + Collapse &all Alle &reduzieren - + &Expand all Alle &erweitern - + &Standard &Standard - + Standard items Standardeinträge - + Toolbar Symbolleiste - + &Categories &Kategorien - + Error categories Fehler-Kategorien - + &Open XML... Öffne &XML... - + Open P&roject File... Pr&ojektdatei öffnen... - + Ctrl+Shift+O - + Sh&ow Scratchpad... &Zeige Schmierzettel... - + &New Project File... &Neue Projektdatei... - + Ctrl+Shift+N - + &Log View &Loganzeige - + Log View Loganzeige - + C&lose Project File Projektdatei &schließen - + &Edit Project File... Projektdatei &bearbeiten... - + &Statistics &Statistik - + &Warnings &Warnungen - + Per&formance warnings Per&formance-Warnungen - + &Information &Information - + &Portability &Portabilität - + P&latforms P&lattformen - + C++&11 C++&11 - + C&99 C&99 - + &Posix Posix - + C&11 C&11 - + &C89 &C89 - + &C++03 &C++03 - + &Library Editor... &Bibliothekseditor - + &Auto-detect language Sprache &automatisch erkennen - + &Enforce C++ C++ &erzwingen - + E&nforce C C e&rzwingen - + C++14 C++14 - + Reanalyze and check library Neu analysieren und Bibliothek prüfen - + Check configuration (defines, includes) Prüfe Konfiguration (Definitionen, Includes) - + C++17 C++17 - + C++20 C++20 - + Compliance report... - + Normal - + Misra C Misra C - + Misra C++ 2008 - + Cert C Cert C - + Cert C++ Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + &Contents &Inhalte - + Categories Kategorien - - + + Show style warnings Zeige Stilwarnungen - + Open the help contents Öffnet die Hilfe-Inhalte - + F1 F1 - + &Help &Hilfe - - + + Quick Filter: Schnellfilter: - + Select configuration Konfiguration wählen - + Found project file: %1 Do you want to load this project file instead? @@ -1105,37 +1115,37 @@ Do you want to load this project file instead? Möchten Sie stattdessen diese öffnen? - + File not found Datei nicht gefunden - + Bad XML Fehlerhaftes XML - + Missing attribute Fehlendes Attribut - + Bad attribute value Falscher Attributwert - + Duplicate platform type Plattformtyp doppelt - + Platform type redefined Plattformtyp neu definiert - + Duplicate define @@ -1157,50 +1167,50 @@ Möchten Sie stattdessen diese öffnen?
- + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + License Lizenz - + Authors Autoren - + Save the report file Speichert die Berichtdatei - - + + XML files (*.xml) XML-Dateien (*.xml) - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. @@ -1209,37 +1219,38 @@ This is probably because the settings were changed between the Cppcheck versions Dies wurde vermutlich durch einen Wechsel der Cppcheck-Version hervorgerufen. Bitte prüfen (und korrigieren) Sie die Einstellungen, andernfalls könnte die Editor-Anwendung nicht korrekt starten. - + You must close the project file before selecting new files or directories! Sie müssen die Projektdatei schließen, bevor Sie neue Dateien oder Verzeichnisse auswählen! - + The library '%1' contains unknown elements: %2 Die Bibliothek '%1' enthält unbekannte Elemente: %2 - + Unsupported format Nicht unterstütztes Format - + Unknown element Unbekanntes Element - Unknown issue - Unbekannter Fehler + Unknown element + Unknown issue + Unbekannter Fehler - - - - + + + + Error Fehler @@ -1248,80 +1259,80 @@ Dies wurde vermutlich durch einen Wechsel der Cppcheck-Version hervorgerufen. Bi Laden von %1 fehlgeschlagen. Ihre Cppcheck-Installation ist defekt. Sie können --data-dir=<Verzeichnis> als Kommandozeilenparameter verwenden, um anzugeben, wo die Datei sich befindet. Bitte beachten Sie, dass --data-dir in Installationsroutinen genutzt werden soll, und die GUI bei dessen Nutzung nicht startet, sondern die Einstellungen konfiguriert.
- + Open the report file Berichtdatei öffnen - + Text files (*.txt) Textdateien (*.txt) - + CSV files (*.csv) CSV-Dateien (*.csv) - + Project files (*.cppcheck);;All files(*.*) Projektdateien (*.cppcheck);;Alle Dateien(*.*) - + Select Project File Projektdatei auswählen - - - - + + + + Project: Projekt: - + No suitable files found to analyze! Keine passenden Dateien für Analyse gefunden! - + C/C++ Source C/C++-Quellcode - + Compile database Compilerdatenbank - + Visual Studio Visual Studio - + Borland C++ Builder 6 Borland C++-Builder 6 - + Select files to analyze Dateien für Analyse auswählen - + Select directory to analyze Verzeichnis für Analyse auswählen - + Select the configuration that will be analyzed Zu analysierende Konfiguration auswählen - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? @@ -1330,7 +1341,7 @@ Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1341,7 +1352,7 @@ Eine neue XML-Datei zu öffnen wird die aktuellen Ergebnisse löschen Möchten sie fortfahren? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? @@ -1350,109 +1361,109 @@ Do you want to stop the analysis and exit Cppcheck? Wollen sie die Analyse abbrechen und Cppcheck beenden? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML-Dateien (*.xml);;Textdateien (*.txt);;CSV-Dateien (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Build dir '%1' does not exist, create it? Erstellungsverzeichnis '%1' existiert nicht. Erstellen? - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1461,22 +1472,22 @@ Analysis is stopped. Import von '%1' fehlgeschlagen; Analyse wurde abgebrochen.
- + Project files (*.cppcheck) Projektdateien (*.cppcheck) - + Select Project Filename Projektnamen auswählen - + No project file loaded Keine Projektdatei geladen - + The project file %1 @@ -1493,12 +1504,12 @@ Do you want to remove the file from the recently used projects -list? Möchten Sie die Datei von der Liste der zuletzt benutzten Projekte entfernen? - + Install - + New version available: %1. %2 @@ -1847,12 +1858,17 @@ Options:
- + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting - + External tools Externe Werkzeuge @@ -1974,17 +1990,17 @@ Options: Cert C++
- + Bug hunting (Premium) - + Clang analyzer Clang-Analyzer - + Clang-tidy Clang-Tidy @@ -1997,82 +2013,82 @@ Options: ProjectFileDialog - + Project file: %1 Projektdatei: %1 - + Select Cppcheck build dir Wähle Cppcheck-Erstellungsverzeichnis - + Select include directory Wähle Include-Verzeichnisse - + Select a directory to check Wähle zu prüfendes Verzeichnis - + Note: Open source Cppcheck does not fully implement Misra C 2012 Hinweis: Open-Source Cppcheck implementiert Misra C 2012 nicht vollständig - + Clang-tidy (not found) Clang-tidy (nicht gefunden) - + Visual Studio Visual Studio - + Compile database Compilerdatenbank - + Borland C++ Builder 6 Borland C++-Builder 6 - + Import Project Projekt importieren - + Select directory to ignore Wähle zu ignorierendes Verzeichnis - + Source files Quelltext-Dateien - + All files Alle Dateien - + Exclude file Datei ausschließen - + Select MISRA rule texts file Wähle MISRA-Regeltext-Datei - + MISRA rule texts file (%1) MISRA-Regeltext-Datei (%1) @@ -2105,7 +2121,7 @@ Options: - + (Not found) (nicht gefunden) @@ -2155,157 +2171,157 @@ Options: - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Foreground Color Klassen-Vordergrundfarbe - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + File Datei - + Line Zeile - + Severity Schweregrad - + Classification - + Level - + Inconclusive Unklar - + Summary Zusammenfassung - + Id Id - + Guideline - + Rule - + Since date Seit Datum - + Tags - + CWE @@ -2356,88 +2372,88 @@ Options: Undefinierte Datei - + Copy Kopieren - + Could not find file: Kann Datei nicht finden: - + Please select the folder '%1' Bitte wählen Sie den Ordner '%1' - + Select Directory '%1' Wähle Verzeichnis '%1' - + Please select the directory where file is located. Bitte wählen Sie das Verzeichnis, in dem sich die Datei befindet. - + debug Debug - + note Anmerkung - + Hide all with id Verstecke alle mit gleicher ID - + Suppress selected id(s) Ausgewählte ID(s) unterdrücken - + Open containing folder Übergeordneten Ordner öffnen - + internal Intern - + Recheck %1 file(s) Erneut %1 Datei(en) prüfen - + Hide %1 result(s) Verstecke %1 Ergebnis(se) - + Tag Tag - + No tag Kein Tag - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2446,7 +2462,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2455,12 +2471,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! Datei konnte nicht gefunden werden! - + Could not start %1 Please check the application path and parameters are correct. @@ -2469,37 +2485,37 @@ Please check the application path and parameters are correct. Bitte überprüfen Sie ob der Pfad und die Parameter der Anwendung richtig eingestellt sind. - + Select Directory Wähle Verzeichnis - + style Stil - + error Fehler - + warning Warnung - + performance Performance - + portability Portabilität - + information Information @@ -3166,10 +3182,18 @@ Legen Sie unter dem Menü Ansicht fest, welche Arten von Fehlern angezeigt werde Informationsmeldungen + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked %1 von %2 Dateien geprüft diff --git a/gui/cppcheck_es.ts b/gui/cppcheck_es.ts index 2283e346285..927a56e05e5 100644 --- a/gui/cppcheck_es.ts +++ b/gui/cppcheck_es.ts @@ -322,42 +322,42 @@ Parameters: -l(line) (file) Editar - - + + Library files (*.cfg) Archivos de biblioteca (*.cfg) - + Open library file Abrir archivo de biblioteca - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. - + Failed to load %1. %2. - + Cannot save file %1. Can not save file %1. - + Save the library as @@ -476,20 +476,20 @@ Parameters: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck @@ -509,238 +509,238 @@ Parameters: -l(line) (file) &Herramientas - + &Help &Ayuda - + C++ standard C++ estándar - + &C standard C standard C estándar - + &Edit &Editar - + Standard Estándar - + Categories Categorías - + &License... &Licencia... - + A&uthors... A&utores... - + &About... &Acerca de... - + &Files... &Ficheros... - - + + Analyze files Check files Comprobar archivos - + Ctrl+F Ctrl+F - + &Directory... &Carpeta... - - + + Analyze directory Check directory Comprobar carpeta - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop &Detener - - + + Stop analysis Stop checking Detener comprobación - + Esc Esc - + &Save results to file... &Guardar los resultados en el fichero... - + Ctrl+S Ctrl+S - + &Quit &Salir - + &Clear results &Limpiar resultados - + &Preferences &Preferencias - - + + Show style warnings Mostrar advertencias de estilo - - - + + + Show errors Mostrar errores - + Information Información - + Show information messages Mostrar mensajes de información - + Show portability warnings Mostrar advertencias de portabilidad - + Show Cppcheck results - + Clang - + Show Clang results - + &Filter &Filtro - + Filter results Resultados del filtro - + Windows 32-bit ANSI Windows 32-bit ANSI - + Windows 32-bit Unicode Windows 32-bit Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - + &Print... Im&primir... - + Print the Current Report Imprimir el informe actual - + Print Pre&view... Pre&visualización de impresión... - + Open a Print Preview Dialog for the Current Results Abre el diálogo de previsualización de impresión para el informe actual - + Open library editor Abrir el editor de bibliotecas - + &Check all &Seleccionar todo @@ -756,363 +756,373 @@ Parameters: -l(line) (file) - + Report - + A&nalyze - + Filter Filtro - + &Reanalyze modified files &Recheck modified files - + Reanal&yze all files - + Ctrl+Q - + Style war&nings - + E&rrors - + &Uncheck all &Deseleccionar todo - + Collapse &all Contraer &todo - + &Expand all &Expandir todo - + &Standard &Estándar - + Standard items Elementos estándar - + &Contents &Contenidos - + Open the help contents Abrir la ayuda de contenidos - + F1 F1 - + Toolbar Barra de herramientas - + &Categories &Categorías - + Error categories Categorías de error - + &Open XML... &Abrir XML... - + Open P&roject File... Abrir P&royecto... - + Ctrl+Shift+O - + Sh&ow Scratchpad... - + &New Project File... &Nuevo Proyecto... - + Ctrl+Shift+N - + &Log View &Visor del log - + Log View Visor del log - + C&lose Project File C&errar Proyecto - + &Edit Project File... &Editar Proyecto... - + &Statistics &Estadísticas - + &Warnings - + Per&formance warnings - + &Information - + &Portability - + P&latforms - + C++&11 - + C&99 - + &Posix - + C&11 - + &C89 - + &C++03 - + &Library Editor... - + &Auto-detect language - + &Enforce C++ - + E&nforce C - + C++14 C++14 - + Reanalyze and check library - + Check configuration (defines, includes) - + C++17 C++17 - + C++20 C++20 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - - - + + Thread Details + + + + + Show thread details + + + + + + Show warnings Mostrar advertencias - - + + Show performance warnings Mostrar advertencias de rendimiento - + Show &hidden Mostrar &ocultos - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. - + You must close the project file before selecting new files or directories! ¡Tienes que cerrar el proyecto antes de seleccionar nuevos ficheros o carpetas! - + Select configuration - + File not found Archivo no encontrado - + Bad XML XML malformado - + Missing attribute Falta el atributo - + Bad attribute value - + Unsupported format Formato no soportado - + Duplicate define @@ -1133,61 +1143,61 @@ This is probably because the settings were changed between the Cppcheck versions - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - - + + XML files (*.xml) Archivos XML (*.xml) - + Open the report file Abrir informe - + License Licencia - + Authors Autores - + Save the report file Guardar informe - - + + Quick Filter: Filtro rápido: - + Found project file: %1 Do you want to load this project file instead? @@ -1196,117 +1206,118 @@ Do you want to load this project file instead? ¿Quiere cargar este fichero de proyecto en su lugar? - + The library '%1' contains unknown elements: %2 La biblioteca '%1' contiene elementos deconocidos: %2 - + Duplicate platform type - + Platform type redefined - + Unknown element - Unknown issue + Unknown element + Unknown issue - - - - + + + + Error Error - + Text files (*.txt) Ficheros de texto (*.txt) - + CSV files (*.csv) Ficheros CVS (*.cvs) - + Project files (*.cppcheck);;All files(*.*) Ficheros de proyecto (*.cppcheck;;Todos los ficheros (*.*) - + Select Project File Selecciona el archivo de proyecto - - - - + + + + Project: Proyecto: - + No suitable files found to analyze! - + C/C++ Source - + Compile database - + Visual Studio - + Borland C++ Builder 6 - + Select files to analyze - + Select directory to analyze - + Select the configuration that will be analyzed - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1314,81 +1325,81 @@ Do you want to proceed? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Build dir '%1' does not exist, create it? - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Project files (*.cppcheck) - + Select Project Filename Selecciona el nombre del proyecto - + No project file loaded No hay ningún proyecto cargado - + The project file %1 @@ -1405,67 +1416,67 @@ Do you want to remove the file from the recently used projects -list? ¿Quiere eliminar el fichero de la lista de proyectos recientes? - + Install - + New version available: %1. %2 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1822,12 +1833,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting - + External tools @@ -1938,17 +1954,17 @@ Options: - + Bug hunting (Premium) - + Clang analyzer - + Clang-tidy @@ -1961,82 +1977,82 @@ Options: ProjectFileDialog - + Project file: %1 Archivo de proyecto: %1 - + Select Cppcheck build dir - + Select include directory Selecciona una carpeta para incluir - + Select a directory to check Selecciona la carpeta a comprobar - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore Selecciona la carpeta a ignorar - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -2069,7 +2085,7 @@ Options: - + (Not found) @@ -2119,158 +2135,158 @@ Options: - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Foreground Color Class ForegroundColor - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + File Archivo - + Line Línea - + Severity Severidad - + Classification - + Level - + Inconclusive - + Summary Resumen - + Id Id - + Guideline - + Rule - + Since date - + Tags - + CWE @@ -2321,47 +2337,47 @@ Options: Fichero no definido - + Copy - + Could not find file: - + Please select the folder '%1' - + Select Directory '%1' - + Please select the directory where file is located. - + portability portabilidad - + note - + information información - + debug depuración @@ -2370,53 +2386,53 @@ Options: Ocultar - + Hide all with id Ocultar todos con el mismo id - + Suppress selected id(s) - + Open containing folder Abrir carpeta contenedora - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag - + No tag - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2426,7 +2442,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2435,12 +2451,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! ¡No se ha encontrado el fichero! - + Could not start %1 Please check the application path and parameters are correct. @@ -2449,7 +2465,7 @@ Please check the application path and parameters are correct. Por favor comprueba que la ruta a la aplicación y los parámetros son correctos. - + Select Directory Selecciona carpeta @@ -2458,22 +2474,22 @@ Por favor comprueba que la ruta a la aplicación y los parámetros son correctos Id - + style estilo - + error error - + warning advertencia - + performance ajuste @@ -3140,10 +3156,18 @@ Para cambiar el tipo de comportamiento, abra el menú Ver. Mensajes de información + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked %1 de %2 archivos comprobados diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index d6ad561fd33..f6c959aa099 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -325,42 +325,42 @@ Parameters: -l(line) (file) - - + + Library files (*.cfg) - + Open library file - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. - + Failed to load %1. %2. - + Cannot save file %1. Can not save file %1. - + Save the library as @@ -479,30 +479,30 @@ Parameters: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck - + A&nalyze - + Standard Vakio @@ -522,235 +522,235 @@ Parameters: -l(line) (file) - + C++ standard - + &C standard C standard - + &Edit &Muokkaa - + &License... &Lisenssi... - + A&uthors... &Tekijät... - + &About... &Tietoa ohjelmasta Cppcheck... - + &Files... &Tiedostot... - - + + Analyze files Check files - + Ctrl+F Ctrl+F - + &Directory... &Hakemisto... - - + + Analyze directory Check directory - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop &Pysäytä - - + + Stop analysis Stop checking - + Esc Esc - + &Save results to file... &Tallenna tulokset tiedostoon... - + Ctrl+S Ctrl+S - + &Quit &Lopeta - + &Clear results &Tyhjennä tulokset - + &Preferences &Asetukset - - - + + + Show errors - - - + + + Show warnings - - + + Show performance warnings - + Show &hidden - + Information - + Show information messages - + Show portability warnings - + Show Cppcheck results - + Clang - + Show Clang results - + &Filter - + Filter results - + Windows 32-bit ANSI - + Windows 32-bit Unicode - + Unix 32-bit - + Unix 64-bit - + Windows 64-bit - + &Print... - + Print the Current Report - + Print Pre&view... - + Open a Print Preview Dialog for the Current Results - + Open library editor - + &Check all &Valitse kaikki @@ -766,352 +766,362 @@ Parameters: -l(line) (file) - + Report - + Filter - + &Reanalyze modified files &Recheck modified files - + Reanal&yze all files - + Ctrl+Q - + Style war&nings - + E&rrors - + &Uncheck all &Poista kaikista valinta - + Collapse &all &Pienennä kaikki - + &Expand all &Laajenna kaikki - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + &Open XML... - + Open P&roject File... - + Ctrl+Shift+O - + Sh&ow Scratchpad... - + &New Project File... - + Ctrl+Shift+N - + &Log View - + Log View - + C&lose Project File - + &Edit Project File... - + &Statistics - + &Warnings - + Per&formance warnings - + &Information - + &Portability - + P&latforms - + C++&11 - + C&99 - + &Posix - + C&11 - + &C89 - + &C++03 - + &Library Editor... - + &Auto-detect language - + &Enforce C++ - + E&nforce C - + C++14 - + Reanalyze and check library - + Check configuration (defines, includes) - + C++17 - + C++20 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + &Contents - + Categories - - + + Show style warnings - + Open the help contents - + F1 - + &Help &Ohje - - + + Quick Filter: - + Select configuration - + Found project file: %1 Do you want to load this project file instead? - + File not found - + Bad XML - + Missing attribute - + Bad attribute value - + Duplicate define @@ -1132,181 +1142,182 @@ Do you want to load this project file instead? - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + License Lisenssi - + Authors Tekijät - + Save the report file Tallenna raportti - - + + XML files (*.xml) XML-tiedostot (*xml) - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. - + You must close the project file before selecting new files or directories! - + The library '%1' contains unknown elements: %2 - + Unsupported format - + Duplicate platform type - + Platform type redefined - + Unknown element - Unknown issue + Unknown element + Unknown issue - - - - + + + + Error - + Open the report file - + Text files (*.txt) Tekstitiedostot (*.txt) - + CSV files (*.csv) - + Project files (*.cppcheck);;All files(*.*) - + Select Project File - - - - + + + + Project: - + No suitable files found to analyze! - + C/C++ Source - + Compile database - + Visual Studio - + Borland C++ Builder 6 - + Select files to analyze - + Select directory to analyze - + Select the configuration that will be analyzed - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1314,81 +1325,81 @@ Do you want to proceed? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Build dir '%1' does not exist, create it? - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Project files (*.cppcheck) - + Select Project Filename - + No project file loaded - + The project file %1 @@ -1399,67 +1410,67 @@ Do you want to remove the file from the recently used projects -list? - + Install - + New version available: %1. %2 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1805,12 +1816,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting - + External tools @@ -1932,17 +1948,17 @@ Options: - + Bug hunting (Premium) - + Clang analyzer - + Clang-tidy @@ -1955,82 +1971,82 @@ Options: ProjectFileDialog - + Project file: %1 - + Select Cppcheck build dir - + Select include directory - + Select a directory to check - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -2065,7 +2081,7 @@ Options: - + (Not found) @@ -2115,158 +2131,158 @@ Options: - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Foreground Color Class ForegroundColor - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + File Tiedosto - + Line Rivi - + Severity Tyyppi - + Classification - + Level - + Inconclusive - + Summary - + Id - + Guideline - + Rule - + Since date - + Tags - + CWE @@ -2313,88 +2329,88 @@ Options: Määrittelemätön tiedosto - + Copy - + Could not find file: - + Please select the folder '%1' - + Select Directory '%1' - + Please select the directory where file is located. - + debug - + note - + Hide all with id - + Suppress selected id(s) - + Open containing folder - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag - + No tag - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2402,19 +2418,19 @@ Configure the editor application for Cppcheck in preferences/Applications.Voit asetuksista määritellä muita ohjelmia joilla avata tämän virheen sisältävän tiedoston. - + No default editor application selected. Please select the default editor application in preferences/Applications. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -2423,37 +2439,37 @@ Please check the application path and parameters are correct. Tarkista että ohjelman polku ja parametrit ovat oikeat. - + Select Directory - + style Tyyli - + error Yleinen - + warning - + performance - + portability - + information @@ -3113,10 +3129,18 @@ Määrittääksesi minkä tyyppisiä virheitä näytetään, avaa näkymä valik + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked diff --git a/gui/cppcheck_fr.ts b/gui/cppcheck_fr.ts index 45ee1549a62..82e0ea2bf74 100644 --- a/gui/cppcheck_fr.ts +++ b/gui/cppcheck_fr.ts @@ -313,13 +313,13 @@ Paramètres : -l(ligne) (fichier) Editer - - + + Library files (*.cfg) - + Open library file @@ -344,29 +344,29 @@ Paramètres : -l(ligne) (fichier) - - - + + + Cppcheck - + Save the library as - + Failed to load %1. %2. - + Cannot open file %1. - + Cannot save file %1. @@ -485,20 +485,20 @@ Paramètres : -l(ligne) (fichier) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck @@ -524,213 +524,223 @@ Paramètres : -l(ligne) (fichier) - + Report - + &Help &Aide - + &Edit &Édition - + Standard Standard - + &License... &Licence... - + A&uthors... A&uteurs... - + &About... À &Propos... - + &Files... &Fichiers... - + Ctrl+F - + &Directory... &Répertoires... - + Ctrl+D - + Ctrl+R - + &Stop &Arrêter - + Esc - + &Save results to file... &Sauvegarder les résultats dans un fichier... - + Ctrl+S - + &Quit &Quitter - + &Clear results &Effacer les résultats - + &Preferences &Préférences - + &Check all &Tout cocher - + &Uncheck all &Tout décocher - + Collapse &all &Tout réduire - + &Expand all &Tout dérouler - + &Contents &Contenus - + Open the help contents Ouvir l'aide - + F1 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + License Licence - + Authors Auteurs - + Save the report file Sauvegarder le rapport - - + + XML files (*.xml) Fichiers XML (*.xml) - + About - + Text files (*.txt) Fichiers Texte (*.txt) - + CSV files (*.csv) Fichiers CSV (*.csv) @@ -740,294 +750,294 @@ Paramètres : -l(ligne) (fichier) &Boite à outils - + Categories Catégories - - + + Show style warnings Afficher les avertissements de style - - - + + + Show errors Afficher les erreurs - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + &Open XML... &Ouvrir un fichier XML... - + Open P&roject File... Ouvrir un P&rojet... - + &New Project File... &Nouveau Projet... - + &Log View &Journal - + Log View Journal - + C&lose Project File F&ermer le projet - + &Edit Project File... &Editer le projet - + &Statistics Statistiques - - - + + + Show warnings Afficher les avertissements - - + + Show performance warnings Afficher les avertissements de performance - + Show &hidden - + Information Information - + Show information messages Afficher les messages d'information - + Show portability warnings Afficher les problèmes de portabilité - + You must close the project file before selecting new files or directories! Vous devez d'abord fermer le projet avant de choisir des fichiers/répertoires - + Open the report file Ouvrir le rapport - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Project files (*.cppcheck);;All files(*.*) - + Select Project File - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Select Project Filename - + No project file loaded - + Install - + New version available: %1. %2 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. - + &Filter &Filtre - + Filter results - - + + Quick Filter: Filtre rapide : - + Found project file: %1 Do you want to load this project file instead? - - - - + + + + Project: Projet : - + The project file %1 @@ -1038,32 +1048,32 @@ Do you want to remove the file from the recently used projects -list? - + Filter Filtre - + Windows 32-bit ANSI - + Windows 32-bit Unicode - + Unix 32-bit - + Unix 64-bit - + Windows 64-bit @@ -1073,35 +1083,35 @@ Do you want to remove the file from the recently used projects -list? - + C++ standard - - - - + + + + Error Erreur - + File not found Fichier introuvable - + Bad XML Mauvais fichier XML - + Missing attribute Attribut manquant - + Bad attribute value Mauvaise valeur d'attribut @@ -1113,64 +1123,65 @@ Do you want to remove the file from the recently used projects -list? %2 - + Unsupported format Format non supporté - + The library '%1' contains unknown elements: %2 La bibliothèque '%1' contient des éléments inconnus: %2 - + Duplicate platform type - + Platform type redefined - + &Print... &Imprimer... - + Print the Current Report Imprimer le rapport - + Print Pre&view... Apercu d'impression... - + Open a Print Preview Dialog for the Current Results - + Open library editor - + Unknown element - Unknown issue + Unknown element + Unknown issue - + Select configuration @@ -1193,67 +1204,67 @@ Options: - + Build dir '%1' does not exist, create it? - - + + Analyze files - - + + Analyze directory - + &Reanalyze modified files - - + + Stop analysis - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + No suitable files found to analyze! - + Select files to analyze - + Select directory to analyze - + Select the configuration that will be analyzed - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? - + Duplicate define @@ -1268,221 +1279,221 @@ Do you want to proceed analysis without using any of these project files? - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? - + A&nalyze - + &C standard - + Reanal&yze all files - + Ctrl+Q - + Style war&nings - + E&rrors - + Ctrl+Shift+O - + Sh&ow Scratchpad... - + Ctrl+Shift+N - + &Warnings - + Per&formance warnings - + &Information - + &Portability - + Show Cppcheck results - + Clang - + Show Clang results - + P&latforms - + C++&11 - + C&99 - + &Posix - + C&11 - + &C89 - + &C++03 - + &Library Editor... - + &Auto-detect language - + &Enforce C++ - + E&nforce C - + C++14 - + Project files (*.cppcheck) - + Reanalyze and check library - + Check configuration (defines, includes) - + C++17 - + C++20 - + C/C++ Source - + Compile database - + Visual Studio - + Borland C++ Builder 6 - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1736,17 +1747,17 @@ Do you want to proceed? - + Bug hunting - + Clang analyzer - + Clang-tidy @@ -1899,12 +1910,17 @@ Do you want to proceed? - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting (Premium) - + External tools @@ -1944,82 +1960,82 @@ Do you want to proceed? ProjectFileDialog - + Project file: %1 Fichier projet : %1 - + Select include directory Selectionner un répertoire à inclure - + Select directory to ignore Selectionner un répertoire à ignorer - + Select a directory to check Selectionner un répertoire à vérifier - + Select Cppcheck build dir - + Import Project - + Clang-tidy (not found) - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) - + Visual Studio - + Compile database - + Borland C++ Builder 6 @@ -2052,7 +2068,7 @@ Do you want to proceed? - + (Not found) @@ -2102,157 +2118,157 @@ Do you want to proceed? - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + Class Foreground Color - + File Fichier - + Line Ligne - + Severity Sévérité - + Classification - + Level - + Inconclusive - + Summary Résumé - + Id Id - + Guideline - + Rule - + Since date - + Tags - + CWE @@ -2299,13 +2315,13 @@ Do you want to proceed? Fichier indéterminé - - + + Cppcheck - + Could not start %1 Please check the application path and parameters are correct. @@ -2314,12 +2330,12 @@ Please check the application path and parameters are correct. Merci de vérifier que le chemin de l'application et que les paramètres sont corrects. - + style erreur de style - + error erreur @@ -2332,64 +2348,64 @@ Merci de vérifier que le chemin de l'application et que les paramètres so Cacher - + Could not find the file! Fichier introuvable ! - + Select Directory Selectionner dossier - + warning avertissement - + performance performance - + portability portabilité - + information information - + debug débogage - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2400,12 +2416,12 @@ Please select the default editor application in preferences/Applications.Id - + Hide all with id - + Open containing folder Ouvrir l'emplacement du fichier @@ -2414,47 +2430,47 @@ Please select the default editor application in preferences/Applications.Revérifier - + note - + Suppress selected id(s) - + Tag - + No tag - + Could not find file: - + Please select the folder '%1' - + Select Directory '%1' - + Please select the directory where file is located. - + Copy @@ -3113,10 +3129,18 @@ Pour configurer les erreurs affichées, ouvrez le menu d'affichage. + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked diff --git a/gui/cppcheck_it.ts b/gui/cppcheck_it.ts index 811150c9257..1c8829bb198 100644 --- a/gui/cppcheck_it.ts +++ b/gui/cppcheck_it.ts @@ -334,42 +334,42 @@ Parametri: -l(line) (file) Modifica - - + + Library files (*.cfg) - + Open library file - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. - + Failed to load %1. %2. - + Cannot save file %1. Can not save file %1. - + Save the library as @@ -488,30 +488,30 @@ Parametri: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck - + A&nalyze - + Standard Standard @@ -531,235 +531,235 @@ Parametri: -l(line) (file) &Barre degli strumenti - + C++ standard - + &C standard C standard - + &Edit &Modifica - + &License... &Licenza... - + A&uthors... A&utori... - + &About... I&nformazioni su... - + &Files... &File... - - + + Analyze files Check files Scansiona i file - + Ctrl+F Ctrl+F - + &Directory... &Cartella... - - + + Analyze directory Check directory Scansiona la cartella - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop &Ferma - - + + Stop analysis Stop checking Ferma la scansione - + Esc Esc - + &Save results to file... &Salva i risultati nel file... - + Ctrl+S Ctrl+S - + &Quit &Esci - + &Clear results &Cancella i risultati - + &Preferences &Preferenze - - - + + + Show errors Mostra gli errori - - - + + + Show warnings Mostra gli avvisi - - + + Show performance warnings Mostra gli avvisi sulle prestazioni - + Show &hidden Mostra &i nascosti - + Information Informazione - + Show information messages Mostra messaggi di informazione - + Show portability warnings Mostra gli avvisi sulla portabilità - + Show Cppcheck results - + Clang - + Show Clang results - + &Filter &Filtro - + Filter results Filtra i risultati - + Windows 32-bit ANSI Windows 32-bit, ANSI - + Windows 32-bit Unicode Windows 32-bit, Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - + &Print... - + Print the Current Report - + Print Pre&view... - + Open a Print Preview Dialog for the Current Results - + Open library editor - + &Check all &Seleziona tutto @@ -775,325 +775,335 @@ Parametri: -l(line) (file) - + Report - + Filter Filtro - + &Reanalyze modified files &Recheck modified files - + Reanal&yze all files - + Ctrl+Q - + Style war&nings - + E&rrors - + &Uncheck all &Deseleziona tutto - + Collapse &all Riduci &tutto - + &Expand all &Espandi tutto - + &Standard &Standard - + Standard items Oggetti standard - + Toolbar Barra degli strumenti - + &Categories &Categorie - + Error categories Categorie di errore - + &Open XML... &Apri XML... - + Open P&roject File... Apri file di p&rogetto... - + Ctrl+Shift+O - + Sh&ow Scratchpad... - + &New Project File... &Nuovo file di progetto... - + Ctrl+Shift+N - + &Log View &Visualizza il rapporto - + Log View Visualizza il rapporto - + C&lose Project File C&hiudi il file di progetto - + &Edit Project File... &Modifica il file di progetto... - + &Statistics &Statistiche - + &Warnings - + Per&formance warnings - + &Information - + &Portability - + P&latforms - + C++&11 - + C&99 - + &Posix - + C&11 - + &C89 - + &C++03 - + &Library Editor... - + &Auto-detect language - + &Enforce C++ - + E&nforce C - + C++14 C++14 - + Reanalyze and check library - + Check configuration (defines, includes) - + C++17 C++17 - + C++20 C++20 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + &Contents &Contenuti - + Categories Categorie - - + + Show style warnings Mostra gli avvisi sullo stile - + Open the help contents Apri i contenuti di aiuto - + F1 F1 - + &Help &Aiuto - - + + Quick Filter: Rapido filtro: - + Select configuration - + Found project file: %1 Do you want to load this project file instead? @@ -1102,32 +1112,32 @@ Do you want to load this project file instead? Vuoi piuttosto caricare questo file di progetto? - + File not found - + Bad XML - + Missing attribute - + Bad attribute value - + Unsupported format - + Duplicate define @@ -1148,50 +1158,50 @@ Vuoi piuttosto caricare questo file di progetto? - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + License Licenza - + Authors Autori - + Save the report file Salva il file di rapporto - - + + XML files (*.xml) File XML (*.xml) - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. @@ -1200,126 +1210,127 @@ This is probably because the settings were changed between the Cppcheck versions Probabilmente ciò è avvenuto perché le impostazioni sono state modificate tra le versioni di Cppcheck. Per favore controlla (e sistema) le impostazioni delle applicazioni editor, altrimenti il programma editor può non partire correttamente. - + You must close the project file before selecting new files or directories! Devi chiudere il file di progetto prima di selezionare nuovi file o cartelle! - + The library '%1' contains unknown elements: %2 - + Duplicate platform type - + Platform type redefined - + Unknown element - Unknown issue + Unknown element + Unknown issue - - - - + + + + Error - + Open the report file Apri il file di rapporto - + Text files (*.txt) File di testo (*.txt) - + CSV files (*.csv) Files CSV (*.csv) - + Project files (*.cppcheck);;All files(*.*) Files di progetto (*.cppcheck);;Tutti i files(*.*) - + Select Project File Seleziona il file di progetto - - - - + + + + Project: Progetto: - + No suitable files found to analyze! - + C/C++ Source - + Compile database - + Visual Studio - + Borland C++ Builder 6 - + Select files to analyze - + Select directory to analyze - + Select the configuration that will be analyzed - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1327,81 +1338,81 @@ Do you want to proceed? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Build dir '%1' does not exist, create it? - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Project files (*.cppcheck) - + Select Project Filename Seleziona il nome del file di progetto - + No project file loaded Nessun file di progetto caricato - + The project file %1 @@ -1418,67 +1429,67 @@ Do you want to remove the file from the recently used projects -list? Vuoi rimuovere il file dalla lista dei progetti recentemente usati? - + Install - + New version available: %1. %2 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1835,12 +1846,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting - + External tools @@ -1951,17 +1967,17 @@ Options: - + Bug hunting (Premium) - + Clang analyzer - + Clang-tidy @@ -1974,82 +1990,82 @@ Options: ProjectFileDialog - + Project file: %1 File di progetto: %1 - + Select Cppcheck build dir - + Select include directory Seleziona la cartella da includere - + Select a directory to check Seleziona una cartella da scansionare - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore Seleziona la cartella da ignorare - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -2082,7 +2098,7 @@ Options: - + (Not found) @@ -2132,158 +2148,158 @@ Options: - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Foreground Color Class ForegroundColor - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + File File - + Line Linea - + Severity Severità - + Classification - + Level - + Inconclusive - + Summary Riassunto - + Id Id - + Guideline - + Rule - + Since date - + Tags - + CWE @@ -2334,37 +2350,37 @@ Options: File indefinito - + Copy - + Could not find file: - + Please select the folder '%1' - + Select Directory '%1' - + Please select the directory where file is located. - + debug debug - + note @@ -2373,53 +2389,53 @@ Options: Nascondi - + Hide all with id - + Suppress selected id(s) - + Open containing folder - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag - + No tag - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2428,7 +2444,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2437,12 +2453,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! Non è stato possibile trovare il file! - + Could not start %1 Please check the application path and parameters are correct. @@ -2451,7 +2467,7 @@ Please check the application path and parameters are correct. Per favore verifica che il percorso dell'applicazione e i parametri siano corretti. - + Select Directory Seleziona Cartella @@ -2460,32 +2476,32 @@ Per favore verifica che il percorso dell'applicazione e i parametri siano c Id - + style stile - + error errore - + warning avviso - + performance performance - + portability portabilità - + information Informazione @@ -3152,10 +3168,18 @@ Per vedere il tipo di errori che sono mostrati, apri il menu Visualizza.Messaggi di informazione + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked %1 su %2 file scansionati diff --git a/gui/cppcheck_ja.ts b/gui/cppcheck_ja.ts index 461f1ef3f07..4c0cc7a95f2 100644 --- a/gui/cppcheck_ja.ts +++ b/gui/cppcheck_ja.ts @@ -337,42 +337,42 @@ Parameters: -l(line) (file) 編集 - - + + Library files (*.cfg) ライブラリファイル(*.cfg) - + Open library file ライブラリファイルを開く - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. ファイルが見つかりません %1。 - + Failed to load %1. %2. 読み込みに失敗しました(%1.%2)。 - + Cannot save file %1. Can not save file %1. ファイルが保存できません %1。 - + Save the library as このライブラリに名前をつけて保存する @@ -502,20 +502,20 @@ Parameters: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck @@ -535,271 +535,271 @@ Parameters: -l(line) (file) ツールバー(&T) - + &Help ヘルプ(&H) - + C++ standard C++標準 - + &C standard C standard &C標準 - + &Edit 編集(&E) - + Standard 言語規格 - + Categories カテゴリ - + &License... ライセンス(&L)... - + A&uthors... 作者(&u)... - + &About... Cppcheckについて(&A)... - + &Files... ファイル選択(&F)... - - + + Analyze files Check files ファイルをチェックする - + Ctrl+F Ctrl+F - + &Directory... ディレクトリ選択(&D)... - - + + Analyze directory Check directory ディレクトリをチェックする - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop 停止(&S) - - + + Stop analysis Stop checking チェックを停止する - + Esc Esc - + &Save results to file... 結果をファイルに保存(&S)... - + Ctrl+S Ctrl+S - + &Quit 終了(&Q) - + &Clear results 結果をクリア(&C) - + &Preferences 設定(&P) - - + + Show style warnings スタイル警告を表示 - - - + + + Show errors エラーを表示 - + Information 情報 - + Show information messages 情報メッセージを表示 - + Show portability warnings 移植可能性の問題を表示 - + Show Cppcheck results Cppcheck結果を表示する - + Clang Clang - + Show Clang results Clangの結果を表示 - + &Filter フィルター(&F) - + Filter results フィルタ結果 - + Windows 32-bit ANSI Windows 32-bit ANSIエンコード - + Windows 32-bit Unicode Windows 32-bit Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - + &Print... 印刷(&P)... - + Print the Current Report 現在のレポートを印刷 - + Print Pre&view... 印刷プレビュー(&v)... - + Open a Print Preview Dialog for the Current Results 現在のレポートをプレビュー表示 - + Open library editor ライブラリエディタを開く - + C&lose Project File プロジェクトを閉じる(&l) - + &Edit Project File... プロジェクトの編集(&E)... - + &Statistics 統計情報(&S) - - - + + + Show warnings 警告を表示 - - + + Show performance warnings パフォーマンス警告を表示 - + Show &hidden 非表示を表示(&h) - + &Check all すべてのエラーを表示(&C) @@ -815,288 +815,298 @@ Parameters: -l(line) (file) - + Report レポート - + A&nalyze チェック(&n) - + Filter フィルター - + &Reanalyze modified files &Recheck modified files 変更ありファイルを再解析(&R) - + Reanal&yze all files 全ファイル再解析(&y) - + Ctrl+Q Ctrl+Q - + Style war&nings スタイル警告(&n) - + E&rrors エラー(&r) - + &Uncheck all すべてのエラーを非表示(&U) - + Collapse &all ツリーを折り畳む(&a) - + &Expand all ツリーを展開(&E) - + &Standard 言語規格(&S) - + Standard items 標準項目 - + &Contents コンテンツ(&C) - + Open the help contents ヘルプファイルを開く - + F1 F1 - + Toolbar ツールバー - + &Categories カテゴリ(&C) - + Error categories エラーカテゴリ - + &Open XML... XMLを開く(&O)... - + Open P&roject File... プロジェクトを開く(&R)... - + Ctrl+Shift+O Ctrl+Shift+O - + Sh&ow Scratchpad... スクラッチパッドを表示(&o)... - + &New Project File... 新規プロジェクト(&N)... - + Ctrl+Shift+N Ctrl+Shift+N - + &Log View ログを表示(&L) - + Log View ログ表示 - + &Warnings 警告(&W) - + Per&formance warnings パフォーマンス警告(&f) - + &Information 情報(&I) - + &Portability 移植可能性(&P) - + P&latforms プラットフォーム(&l) - + C++&11 C++11(&1) - + C&99 C99(&9) - + &Posix Posix(&P) - + C&11 C11(&1) - + &C89 C89(&C) - + &C++03 C++03(&C) - + &Library Editor... ライブラリエディタ(&L)... - + &Auto-detect language 自動言語検出(&A) - + &Enforce C++ C++ 強制(&E) - + E&nforce C C 強制(&n) - + C++14 C++14 - + Reanalyze and check library ライブラリを再チェックする - + Check configuration (defines, includes) チェックの設定(define、インクルード) - + C++17 C++17 - + C++20 C++20 - + Compliance report... コンプライアンスレポート... - + Normal ノーマル - + Misra C MISRA C - + Misra C++ 2008 MISRA C++ 2008 - + Cert C CERT C - + Cert C++ Cert C++ - + Misra C++ 2023 MISRA C++ 2023 - + Autosar AUTOSAR - + EULA... EULA... - + + Thread Details + + + + + Show thread details + + + + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. @@ -1105,23 +1115,23 @@ This is probably because the settings were changed between the Cppcheck versions Cppcheckの古いバージョンの設定には互換性がありません。エディタアプリケーションの設定を確認して修正してください、そうしないと正しく起動できないかもしれません。 - + You must close the project file before selecting new files or directories! 新しいファイル/ディレクトリをチェックするには現在のプロジェクトを閉じてください! - - + + Quick Filter: クイックフィルタ: - + Select configuration コンフィグレーションの選択 - + Found project file: %1 Do you want to load this project file instead? @@ -1130,56 +1140,57 @@ Do you want to load this project file instead? 現在のプロジェクトの代わりにこのプロジェクトファイルを読み込んでもかまいませんか? - + The library '%1' contains unknown elements: %2 このライブラリ '%1' には次の不明な要素が含まれています。 %2 - + File not found ファイルがありません - + Bad XML 不正なXML - + Missing attribute 属性がありません - + Bad attribute value 不正な属性があります - + Unsupported format サポートされていないフォーマット - + Duplicate platform type プラットフォームの種類が重複しています - + Platform type redefined プラットフォームの種類が再定義されました - + Unknown element 不明な要素 - Unknown issue - 不明な課題 + Unknown element + Unknown issue + 不明な課題 @@ -1189,10 +1200,10 @@ Do you want to load this project file instead? %2 - - - - + + + + Error エラー @@ -1205,73 +1216,73 @@ Do you want to load this project file instead? %1 - %2 の読み込みに失敗 - - + + XML files (*.xml) XML ファイル (*.xml) - + Open the report file レポートを開く - + License ライセンス - + Authors 作者 - + Save the report file レポートを保存 - + Text files (*.txt) テキストファイル (*.txt) - + CSV files (*.csv) CSV形式ファイル (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. コンプライアンスレポートをすぐに生成できません。解析が完了し成功していなければなりません。コードを再解析して、致命的なエラーがないことを確認してください。 - + Project files (*.cppcheck);;All files(*.*) プロジェクトファイル (*.cppcheck);;すべてのファイル(*.*) - + Select Project File プロジェクトファイルを選択 - + Failed to open file ファイルを開くのに失敗しました - + Unknown project file format プロジェクトファイルの形式が不明です - + Failed to import project file プロジェクトファイルのインポートに失敗しました - + Failed to import '%1': %2 Analysis is stopped. @@ -1280,70 +1291,70 @@ Analysis is stopped. 解析を停止しました。 - + Failed to import '%1' (%2), analysis is stopped '%1' (%2) のインポートに失敗しました。解析は停止 - + Install インストール - + New version available: %1. %2 新しいバージョンが利用可能です。: %1. %2 - - - - + + + + Project: プロジェクト: - + No suitable files found to analyze! チェック対象のファイルがみつかりません! - + C/C++ Source C/C++のソースコード - + Compile database コンパイルデータベース - + Visual Studio Visual Studio - + Borland C++ Builder 6 Borland C++ Builder 6 - + Select files to analyze チェック対象のファイルを選択 - + Select directory to analyze チェックするディレクトリを選択してください - + Select the configuration that will be analyzed チェックの設定を選択 - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? @@ -1352,7 +1363,7 @@ Do you want to proceed analysis without using any of these project files? - + Duplicate define 重複した定義 @@ -1367,22 +1378,22 @@ Do you want to proceed analysis without using any of these project files?アドオンの読み込みまたは設定に失敗 %1 - %2 - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. %1のロードに失敗しました。あなたの Cppcheck は正しくインストールされていません。あなたは --data-dir=<directory> コマンドラインオプションを使ってこのファイルの場所を指定できます。ただし、この --data-dir はインストールスクリプトによって使用されていなければなりません。またGUI版はこれを使用しません。さらに、全ての設定は調整済みでなければなりません。 - + Failed to load %1 - %2 Analysis is aborted. 読み込みに失敗 %1 - %2 - - + + %1 Analysis is aborted. @@ -1391,7 +1402,7 @@ Analysis is aborted. 解析は中止した。 - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1401,7 +1412,7 @@ Do you want to proceed? 新しくXMLファイルを開くと現在の結果が削除されます。実行しますか? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? @@ -1410,77 +1421,77 @@ Do you want to stop the analysis and exit Cppcheck? チェックを中断して、Cppcheckを終了しますか? - + About CppCheckについて - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML ファイル (*.xml);;テキストファイル (*.txt);;CSVファイル (*.csv) - + Build dir '%1' does not exist, create it? ビルドディレクトリ'%1'がありません。作成しますか? - + To check the project using addons, you need a build directory. アドオンを使用してプロジェクトをチェックするためには、ビルドディレクトリが必要です。 - + Show Mandatory 必須を表示 - + Show Required 要求を表示 - + Show Advisory 推奨を表示 - + Show Document ドキュメントを表示 - + Show L1 L1を表示 - + Show L2 L2を表示 - + Show L3 L3を表示 - + Show style スタイルを表示 - + Show portability 移植可能性を表示 - + Show performance パフォーマンスを表示 - + Show information 情報を表示 @@ -1489,22 +1500,22 @@ Do you want to stop the analysis and exit Cppcheck? '%1'のインポートに失敗しました。(チェック中断) - + Project files (*.cppcheck) プロジェクトファイル (*.cppcheck) - + Select Project Filename プロジェクトファイル名を選択 - + No project file loaded プロジェクトファイルが読み込まれていません - + The project file %1 @@ -1878,12 +1889,17 @@ Options: Cert C++ - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting (Premium) バグハンティング(プレミアム) - + External tools 外部ツール @@ -2007,17 +2023,17 @@ Options: AUTOSAR - + Bug hunting バグハント - + Clang analyzer Clang Analyzer - + Clang-tidy Clang-tidy @@ -2030,82 +2046,82 @@ Options: ProjectFileDialog - + Project file: %1 プロジェクトファイル:%1 - + Select Cppcheck build dir Cppcheckビルドディレクトリ - + Select include directory includeディレクトリを選択 - + Select a directory to check チェックするディレクトリを選択してください - + Note: Open source Cppcheck does not fully implement Misra C 2012 注意: オープンソースのCppcheckはMisra C 2012を完全にサポートしていません。 - + Clang-tidy (not found) Clang-tidy (みつかりません) - + Visual Studio Visual Studio - + Compile database コンパイルデータベース - + Borland C++ Builder 6 Borland C++ Builder 6 - + Import Project プロジェクトのインポート - + Select directory to ignore 除外するディレクトリを選択してください - + Source files ソースファイル - + All files 全ファイル - + Exclude file 除外ファイル - + Select MISRA rule texts file MISRAルールテキストファイルを選択 - + MISRA rule texts file (%1) MISRAルールテキストファイル (%1) @@ -2146,7 +2162,7 @@ Options: 行 %1: 必須の属性 '%2' が '%3'にない - + (Not found) (見つかりません) @@ -2196,158 +2212,158 @@ Options: - + Editor Foreground Color エディタの前景色 - + Editor Background Color エディタの背景色 - + Highlight Background Color ハイライトの背景色 - + Line Number Foreground Color 行番号の前景色 - + Line Number Background Color 行番号の背景色 - + Keyword Foreground Color キーワードの前景色 - + Keyword Font Weight キーワードのフォントのウェイト - + Class Foreground Color Class ForegroundColor クラスの前景色 - + Class Font Weight クラスフォントのウェイト - + Quote Foreground Color クォートの前景色 - + Quote Font Weight クォートのフォントウェイト - + Comment Foreground Color コメントの前景色 - + Comment Font Weight コメントフォントのウェイト - + Symbol Foreground Color シンボルの前景色 - + Symbol Background Color シンボルの背景色 - + Symbol Font Weight シンボルのフォントウェイト - + Set to Default Light デフォルトをライトに設定 - + Set to Default Dark デフォルトをダークに設定 - + File ファイル - + Line - + Severity 警告の種別 - + Classification 分類 - + Level レベル - + Inconclusive 結論のでない - + Summary 要約 - + Id Id - + Guideline ガイドライン - + Rule ルール - + Since date 日付 - + Tags タグ - + CWE CWE @@ -2398,37 +2414,37 @@ Options: 未定義ファイル - + Copy コピー - + Could not find file: ファイルが見つかりません: - + Please select the folder '%1' フォルダ '%1' を選択してください - + Select Directory '%1' ディレクトリ '%1' 選択 - + Please select the directory where file is located. ファイルのあるディレクトリを選択してください。 - + debug デバッグ - + note 注意 @@ -2441,53 +2457,53 @@ Options: 非表示 - + Hide all with id IDで非表示を指定 - + Suppress selected id(s) 選択したidを抑制 - + Open containing folder 含まれるフォルダを開く - + internal 内部 - + Recheck %1 file(s) - 再チェック %1 件のファイル + 再チェック %1 件のファイル - + Hide %1 result(s) 非表示 %1 件の結果 - + Tag タグ - + No tag タグなし - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2497,7 +2513,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2506,12 +2522,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! ファイルが見つかりません! - + Could not start %1 Please check the application path and parameters are correct. @@ -2520,7 +2536,7 @@ Please check the application path and parameters are correct. 実行ファイルパスや引数の設定を確認してください。 - + Select Directory ディレクトリを選択 @@ -2537,32 +2553,32 @@ Please check the application path and parameters are correct. 日付 - + style スタイル - + error エラー - + warning 警告 - + performance パフォーマンス - + portability 移植可能性 - + information 情報 @@ -3233,10 +3249,18 @@ To toggle what kind of errors are shown, open view menu. 情報メッセージ + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked チェック: %1 / %2 (ファイル数) diff --git a/gui/cppcheck_ka.ts b/gui/cppcheck_ka.ts index 306308fced3..ecc47d7d090 100644 --- a/gui/cppcheck_ka.ts +++ b/gui/cppcheck_ka.ts @@ -325,41 +325,41 @@ Parameters: -l(line) (file) ჩასწორება - - + + Library files (*.cfg) ბიბლიოთეკის ფაილები (*.cfg) - + Open library file ბიბლიოთეკის ფაილის გახსნა - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. ფაილის '%1' გახსნის შეცდომა. - + Failed to load %1. %2. %1-ის ჩატვირთვის შეცდომა. %2. - + Cannot save file %1. ფაილის შენახვის შეცდომა: %1 . - + Save the library as ბიბლიოთეკის შენახვა, როგორც @@ -478,30 +478,30 @@ Parameters: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck - + A&nalyze ა&ნალიზი - + Standard სტანდარტული @@ -521,235 +521,235 @@ Parameters: -l(line) (file) &ხელსაწყოთა ზოლები - + C++ standard C++-ის სტანდარტი - + &C standard C standard &C-ის სტანდარტი - + &Edit &ჩასწორება - + &License... &ლიცენზია... - + A&uthors... &ავტორები... - + &About... &შესახებ... - + &Files... ფაილ&ები... - - + + Analyze files Check files ფაილების ანალიზი - + Ctrl+F Ctrl+F - + &Directory... &საქაღალდე.... - - + + Analyze directory Check directory საქაღალდის ანალიზი - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop &გაჩერება - - + + Stop analysis Stop checking ანალიზის გაჩერება - + Esc Esc - + &Save results to file... შედეგები&ს შენახვა ფაილში.... - + Ctrl+S Ctrl+S - + &Quit გამოსვლა - + &Clear results შედეგების &გასუფთავება - + &Preferences &გამართვა - - - + + + Show errors შეცდომების ჩვენება - - - + + + Show warnings გაფრთხილების ჩვენება - - + + Show performance warnings წარმადობის გაფრთხილებების ჩვენება - + Show &hidden დამალულის &ჩვენება - + Information ინფორმაცია - + Show information messages ინფორმაციის შეტყობინებების ჩვენება - + Show portability warnings გადატანადობის გაფრთხილებების ჩვენება - + Show Cppcheck results Cppcheck-ის შედეგები ჩვენება - + Clang Clang - + Show Clang results Clang-ის შედეგები ჩვენება - + &Filter &ფილტრი - + Filter results შედეგების გაფილტვრა - + Windows 32-bit ANSI Windows 32-bit ANSI - + Windows 32-bit Unicode Windows 32-bit Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - + &Print... &ბეჭდვა… - + Print the Current Report მიმდინარე ანგარიშის დაბეჭდვა - + Print Pre&view... საბეჭდის &გადახედვა... - + Open a Print Preview Dialog for the Current Results მიმდინარე შედეგების დაბეჭდვის მინიატურის დიალოგის ჩვენება - + Open library editor ბიბლიოთეკის რედაქტორის გახსნა - + &Check all &ყველას ჩართვა @@ -765,325 +765,335 @@ Parameters: -l(line) (file) - + Report - + Filter ფილტრი - + &Reanalyze modified files &Recheck modified files ყველა შეცვლილი ფაილის თავიდან ანალი&ზი - + Reanal&yze all files &ყველა ფაილის თავიდან ანალიზი - + Ctrl+Q Ctrl+Q - + Style war&nings ს&ტილის გაფრთხილებები - + E&rrors &შეცდომები - + &Uncheck all ყველას ჩამოყ&რა - + Collapse &all ყველას ჩაკეცვ&ა - + &Expand all &ყველას ამოკეცვა - + &Standard &სტანდარტული - + Standard items სტანდარტული ელემენტები - + Toolbar ხელსაწყოთა ზოლი - + &Categories &კატეგორიები - + Error categories შეცდომის კატეგორიები - + &Open XML... &XML-ის გახსნა... - + Open P&roject File... პ&პროექტის ფაილის გახსნა... - + Ctrl+Shift+O Ctrl+Shift+O - + Sh&ow Scratchpad... ბლ&ოკნოტის ჩვენება... - + &New Project File... &ახალი პროექტის ფაილი... - + Ctrl+Shift+N Ctrl+Shift+N - + &Log View ჟურნა&ლის ხედი - + Log View ჟურნალის ხედი - + C&lose Project File პროექტის ფაი&ლის დახურვა - + &Edit Project File... პროექტის ფაილის ჩასწორ&ება... - + &Statistics &სტატისტიკა - + &Warnings &გაფრთხილებები - + Per&formance warnings წარმატების გა&ფრთხილებები - + &Information &ინფორმაცია - + &Portability &გადატანადობა - + P&latforms პ&ლატფორმები - + C++&11 C++&11 - + C&99 C&99 - + &Posix &Posix - + C&11 C&11 - + &C89 &C89 - + &C++03 &C++03 - + &Library Editor... ბიბ&ლიოთეკის რედაქტორი... - + &Auto-detect language ენის &ავტოდადგენა - + &Enforce C++ ძ&ალით C++ - + E&nforce C ძა&ლით C - + C++14 C++14 - + Reanalyze and check library ბიბლიოთეკის თავიდან ანალიზი და შემოწმება - + Check configuration (defines, includes) კონფიგურაციის შემოწმება (defines, includes) - + C++17 C++17 - + C++20 C++20 - + Compliance report... შესაბამისობის ანგარიში... - + Normal ნორმალური - + Misra C Misra C - + Misra C++ 2008 - + Cert C Cert C - + Cert C++ Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + &Contents &შემცველობა - + Categories კატეგორიები - - + + Show style warnings სტილის გაფრთხილების ჩვენება - + Open the help contents დახმარების შემცველობის გახსნა - + F1 F1 - + &Help &დახმარება - - + + Quick Filter: სწრაფი ფილტრი: - + Select configuration აირჩიეთ კონფიგურაცია - + Found project file: %1 Do you want to load this project file instead? @@ -1092,32 +1102,32 @@ Do you want to load this project file instead? გნებავთ, სამაგიეროდ, ეს პროექტის ფაილი ჩატვირთოთ? - + File not found ფაილი ნაპოვნი არაა - + Bad XML არასწორი XML - + Missing attribute აკლია ატრიბუტი - + Bad attribute value არასწორი ატრიბუტის მნიშვნელობა - + Unsupported format მხარდაუჭერელი ფორმატი - + Duplicate define გამეორებული აღწერა @@ -1139,14 +1149,14 @@ Do you want to load this project file instead? დამატების (%1) ჩატვირთვა/მორგება ჩავარდა: %2 - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. @@ -1155,8 +1165,8 @@ Analysis is aborted. ანალიზი შეწყდა. - - + + %1 Analysis is aborted. @@ -1165,148 +1175,149 @@ Analysis is aborted. ანალიზი შეწყვეტილია. - + License ლიცენზია - + Authors ავტორები - + Save the report file ანგარიშის ფაილში ჩაწერა - - + + XML files (*.xml) XML ფაილები (*.xml) - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. - + You must close the project file before selecting new files or directories! ახალი ფაილების ან საქაღალდეების არჩევამდე პრორექტის ფაილი უნდა დახუროთ! - + The library '%1' contains unknown elements: %2 ბიბლიოთეკა '%1' უცნობ ელემენტებს შეიცავს: %2 - + Duplicate platform type გამეორებული პლატფორმის ტიპი - + Platform type redefined პლატფორმის ტიპი თავდან აღიწერა - + Unknown element უცნობი ელემენტი - Unknown issue - უცნობი პრობლემა + Unknown element + Unknown issue + უცნობი პრობლემა - - - - + + + + Error შეცდომა - + Open the report file ანგარიშის ფაილის გახსნა - + Text files (*.txt) ტექსტური ფაილები (*.txt) - + CSV files (*.csv) CSV ფაილები (*.csv) - + Project files (*.cppcheck);;All files(*.*) პროექტის ფაილები (*.cppcheck);;ყველა ფაილი(*.*) - + Select Project File აირჩიეთ პროექტის ფაილი - - - - + + + + Project: პროექტი: - + No suitable files found to analyze! ანალიზისათვის შესაფერისი ფაილები აღმოჩენილი არაა! - + C/C++ Source C/C++ საწყისი კოდი - + Compile database მონაცემთა ბაზის კომპილაცია - + Visual Studio Visual Studio - + Borland C++ Builder 6 Borland C++ Builder 6 - + Select files to analyze აირჩეთ ფაილები ანალიზისთვის - + Select directory to analyze აირჩიეთ საქაღალდე ანალიზისთვის - + Select the configuration that will be analyzed აირჩიეთ კონფიგურაცია ანალიზისთვის - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? @@ -1315,7 +1326,7 @@ Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1326,7 +1337,7 @@ Do you want to proceed? გნებავთ, გააგრძელოთ? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? @@ -1335,47 +1346,47 @@ Do you want to stop the analysis and exit Cppcheck? გნებავთ, გააჩეროთ ანალიზი და გახვიდეთ Cppcheck-დან? - + About შესახებ - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML ფაილები (*.xml);;ტექსტური ფაილები (*.txt);;CSV ფაილები (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. შესაბამისობის ანგარიშის გენერაცია ახლა შეუძლებელია, რადგან ჯერ ანალიზი წარმატებით უნდა დასრულდეს. სცადეთ, კოდის ანალიზი თავიდან გაუშვათ და დარწმუნდეთ, რომ კრიტიკული შეცდომები არ არსებობს. - + Build dir '%1' does not exist, create it? აგების საქაღალდე (%1) არ არსებობს. შევქმნა? - + To check the project using addons, you need a build directory. პროექტის დამატებებით შესამოწმებლად აგების საქაღალდე გჭირდებათ. - + Failed to open file ფაილის გახსნის შეცდომა - + Unknown project file format უცნობი პროექტის ფაილის ფორმატი - + Failed to import project file პროექტის ფაილის შემოტანა ჩავარდა - + Failed to import '%1': %2 Analysis is stopped. @@ -1384,27 +1395,27 @@ Analysis is stopped. ანალიზი შეწყდა. - + Failed to import '%1' (%2), analysis is stopped '%1'-ის (%2) შემოტანა ჩავარდა. ანალიზი შეწყდა - + Project files (*.cppcheck) პროექტის ფაილები (*.cppcheck) - + Select Project Filename აირჩიეთ პროექტის ფაილის სახელი - + No project file loaded პროექტის ფაილი ჩატვირთული არაა - + The project file %1 @@ -1421,67 +1432,67 @@ Do you want to remove the file from the recently used projects -list? გნებავთ წაშალოთ ეს ფაილი ახლახან გამოყენებული პროექტების სიიდან? - + Install დაყენება - + New version available: %1. %2 ხელმისაწვდომია ახალი ვერსია: %1. %2 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1860,12 +1871,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting შეცდომებზე ნადირობა - + External tools გარე ხელსაწყოები @@ -1967,17 +1983,17 @@ Options: Cert C++ - + Bug hunting (Premium) შეცდომებზე ნადირობა (ფასიანი) - + Clang analyzer Clang-ის ანალიზატორი - + Clang-tidy Clang-tidy @@ -1990,82 +2006,82 @@ Options: ProjectFileDialog - + Project file: %1 პროექტის ფაილი: %1 - + Select Cppcheck build dir აირჩიეთ Cppcheck-ის აგების საქაღალდე - + Select include directory აირჩიეთ ჩასასმელი საქაღალდე - + Select a directory to check აირჩიეთ შესამოწმებელი საქაღალდე - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) Clang-tidy (ვერ ვიპოვე) - + Visual Studio Visual Studio - + Compile database მონაცემთა ბაზის კომპილაცია - + Borland C++ Builder 6 Borland C++ Builder 6 - + Import Project პროექტის შემოტანა - + Select directory to ignore აირჩიეთ გამოსატოვებელი საქაღალდე - + Source files კოდის ფაილები - + All files ყველა ფაილი - + Exclude file ფაილის ამოღება - + Select MISRA rule texts file აირჩიეთ MISRA-ის წესების ტექსტის ფაილი - + MISRA rule texts file (%1) MISRA-ის წესის ტექსტების ფაილი (%1) @@ -2100,7 +2116,7 @@ Options: ხაზი %1: აუცილებელი ატრიბუტი '%2' '%3'-ში აღმოჩენილი არაა - + (Not found) (ვერ ვიპოვე) @@ -2150,158 +2166,158 @@ Options: შავი - + Editor Foreground Color რედაქტორის წინა პლანის ფერი - + Editor Background Color რედაქტორის ფონის ფერი - + Highlight Background Color ფონის ფერის გაოკვეთა - + Line Number Foreground Color ხაზის ნომრის წინა პლანის ფერი - + Line Number Background Color ხაზის ნომრის ფონის ფერი - + Keyword Foreground Color საკვანძო სიტყვის წინა პლანის ფერი - + Keyword Font Weight საკვანძო სიტყვის ფონტის სიმძიმე - + Class Foreground Color Class ForegroundColor კლასის წინა პლანის ფერი - + Class Font Weight კლასის ფონტის სიმძიმე - + Quote Foreground Color ციტატის წინა პლანის ფერი - + Quote Font Weight ციტატის ფონტის სიმძიმე - + Comment Foreground Color კომენტარის წინა პლანს ფერი - + Comment Font Weight კომენტარის ფონტის სიმძიმე - + Symbol Foreground Color სიმბოლოს წინა პლანის ფერი - + Symbol Background Color სიმბოლოს ფონის ფერი - + Symbol Font Weight სიმბოლოს ფონტის სიმძიმე - + Set to Default Light ნაგულისხმევად ღიას დაყენება - + Set to Default Dark ნაგულისხმევად მუქის დაყენება - + File ფაილი - + Line ხაზი - + Severity სიმძიმე - + Classification - + Level - + Inconclusive არადამაჯერებელი - + Summary შეჯამება - + Id Id - + Guideline - + Rule - + Since date თარიღიდან - + Tags - + CWE @@ -2352,37 +2368,37 @@ Options: გაურკვეველი ფაილი - + Copy კოპირება - + Could not find file: ვერ ვიპოვე ფაილი: - + Please select the folder '%1' აირჩიეთ საქაღალდე '%1' - + Select Directory '%1' აირჩიეთ საქაღალდე '%1' - + Please select the directory where file is located. აირჩიეთ საქაღალდე, სადაც ფაილია მოთავსებული. - + debug შეცდომების მოძებნა - + note ნოტა @@ -2395,53 +2411,53 @@ Options: დამალვა - + Hide all with id დამალვა ყველასი id-ით - + Suppress selected id(s) მონიშნული id(ებ)-ის ჩახშობა - + Open containing folder შემცველი საქაღალდის გახსნა - + internal შიდა - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag იარლიყი - + No tag ჭდის გარეშე - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2451,7 +2467,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2460,12 +2476,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! ფაილი ვერ ვიპოვე! - + Could not start %1 Please check the application path and parameters are correct. @@ -2474,7 +2490,7 @@ Please check the application path and parameters are correct. შეამოწმეთ, სწორია, თუ არა აპლიკაციის ბილიკი და მისი პარამეტრები. - + Select Directory აირჩიეთ საქაღალდე @@ -2491,32 +2507,32 @@ Please check the application path and parameters are correct. თარიღიდან - + style სტილი - + error შეცდომა - + warning გაფრთხილება - + performance წარმადობა - + portability გადატანადობა - + information ინფორმაცია @@ -3188,10 +3204,18 @@ To toggle what kind of errors are shown, open view menu. საინფორმაციო შეტყობინებები + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked შემოწმებულია %1 ფაილი %2-დან diff --git a/gui/cppcheck_ko.ts b/gui/cppcheck_ko.ts index 972a54bd889..da6bac85bb7 100644 --- a/gui/cppcheck_ko.ts +++ b/gui/cppcheck_ko.ts @@ -313,13 +313,13 @@ Kate로 파일을 열고, 해당 행으로 이동하는 예제: 편집 - - + + Library files (*.cfg) - + Open library file @@ -344,29 +344,29 @@ Kate로 파일을 열고, 해당 행으로 이동하는 예제: - - - + + + Cppcheck Cppcheck - + Save the library as - + Failed to load %1. %2. - + Cannot open file %1. - + Cannot save file %1. @@ -485,20 +485,20 @@ Kate로 파일을 열고, 해당 행으로 이동하는 예제: MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck @@ -529,345 +529,355 @@ Kate로 파일을 열고, 해당 행으로 이동하는 예제: - + Report - + &Help 도움말(&H) - + &Edit 편집(&E) - + Standard 표준 도구 - + Categories 분류 도구 - + Filter 필터 도구 - + &License... 저작권(&L)... - + A&uthors... 제작자(&u)... - + &About... 정보(&A)... - + &Files... 파일(&F)... - + Ctrl+F Ctrl+F - + &Directory... 디렉토리(&D)... - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop 중지(&S) - + Esc Esc - + &Save results to file... 결과를 파일에 저장(&S)... - + Ctrl+S Ctrl+S - + &Quit 종료(&Q) - + &Clear results 결과 지우기(&C) - + &Preferences 설정(&P) - - + + Show style warnings 스타일 경고 표시 - - - + + + Show errors 애러 표시 - + &Check all 전체 선택(&C) - + &Uncheck all 전체 해제(&U) - + Collapse &all 전체 접기(&A) - + &Expand all 전체 펼치기(&E) - + &Standard 표준 도구(&S) - + Standard items 표준 아이템 - + &Contents 내용(&C) - + Open the help contents 도움말을 엽니다 - + F1 F1 - + Toolbar 도구바 - + &Categories 분류 도구(&C) - + Error categories 에러 종류 - + &Open XML... XML 열기(&O)... - + Open P&roject File... 프로젝트 파일 열기(&R)... - + &New Project File... 새 프로젝트 파일(&N)... - + &Log View 로그 보기(&L) - + Log View 로그 보기 - + C&lose Project File 프로젝트 파일 닫기(&L) - + &Edit Project File... 프로젝트 파일 편집(&E)... - + &Statistics 통계 보기(&S) - - - + + + Show warnings 경고 표시 - - + + Show performance warnings 성능 경고 표시 - + Show &hidden 숨기기 보기(&H) - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + Information 정보 - + Show information messages 정보 표시 - + Show portability warnings 이식성 경고 표시 - + &Filter 필터 도구(&F) - + Filter results 필터링 결과 - + Windows 32-bit ANSI Windows 32-bit ANSI - + Windows 32-bit Unicode Windows 32-bit Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - - + + Quick Filter: 빠른 필터: - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. @@ -876,12 +886,12 @@ This is probably because the settings were changed between the Cppcheck versions Cppcheck 버전간 설정 방법 차이때문인 것으로 보입니다. 편집기 설정을 검사(및 수정)해주세요, 그렇지 않으면 편집기가 제대로 시작하지 않습니다. - + You must close the project file before selecting new files or directories! 새로운 파일이나 디렉토리를 선택하기 전에 프로젝트 파일을 닫으세요! - + Found project file: %1 Do you want to load this project file instead? @@ -890,158 +900,158 @@ Do you want to load this project file instead? 이 프로젝트 파일을 불러오겠습니까? - - + + XML files (*.xml) XML 파일 (*.xml) - + Open the report file 보고서 파일 열기 - + License 저작권 - + Authors 제작자 - + Save the report file 보고서 파일 저장 - + Text files (*.txt) 텍스트 파일 (*.txt) - + CSV files (*.csv) CSV 파일 (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Project files (*.cppcheck);;All files(*.*) 프로젝트 파일 (*.cppcheck);;모든 파일(*.*) - + Select Project File 프로젝트 파일 선택 - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Install - + New version available: %1. %2 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information - - - - + + + + Project: 프로젝트: - + Duplicate define @@ -1056,49 +1066,49 @@ Analysis is stopped. - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + About - + To check the project using addons, you need a build directory. - + Select Project Filename 프로젝트 파일이름 선택 - + No project file loaded 프로젝트 파일 불러오기 실패 - + The project file %1 @@ -1120,35 +1130,35 @@ Do you want to remove the file from the recently used projects -list? - + C++ standard - - - - + + + + Error - + File not found - + Bad XML - + Missing attribute - + Bad attribute value @@ -1159,63 +1169,64 @@ Do you want to remove the file from the recently used projects -list? - + Unsupported format - + The library '%1' contains unknown elements: %2 - + Duplicate platform type - + Platform type redefined - + &Print... - + Print the Current Report - + Print Pre&view... - + Open a Print Preview Dialog for the Current Results - + Open library editor - + Unknown element - Unknown issue + Unknown element + Unknown issue - + Select configuration @@ -1238,259 +1249,259 @@ Options: - + Build dir '%1' does not exist, create it? - - + + Analyze files - - + + Analyze directory - + &Reanalyze modified files - - + + Stop analysis - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + No suitable files found to analyze! - + Select files to analyze - + Select directory to analyze - + Select the configuration that will be analyzed - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? - + A&nalyze - + &C standard - + Reanal&yze all files - + Ctrl+Q - + Style war&nings - + E&rrors - + Ctrl+Shift+O - + Sh&ow Scratchpad... - + Ctrl+Shift+N - + &Warnings - + Per&formance warnings - + &Information - + &Portability - + Show Cppcheck results - + Clang - + Show Clang results - + P&latforms - + C++&11 - + C&99 - + &Posix - + C&11 - + &C89 - + &C++03 - + &Library Editor... - + &Auto-detect language - + &Enforce C++ - + E&nforce C - + C++14 C++14 - + Project files (*.cppcheck) - + Reanalyze and check library - + Check configuration (defines, includes) - + C++17 C++17 - + C++20 C++20 - + C/C++ Source - + Compile database - + Visual Studio - + Borland C++ Builder 6 - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1744,17 +1755,17 @@ Do you want to proceed? - + Bug hunting - + Clang analyzer - + Clang-tidy @@ -1907,12 +1918,17 @@ Do you want to proceed? - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting (Premium) - + External tools @@ -1952,82 +1968,82 @@ Do you want to proceed? ProjectFileDialog - + Project file: %1 프로젝트 파일: %1 - + Select include directory Include 디렉토리 선택 - + Select a directory to check 검사할 디렉토리 선택 - + Select directory to ignore 무시할 디렉토리 선택 - + Select Cppcheck build dir - + Import Project - + Clang-tidy (not found) - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) - + Visual Studio - + Compile database - + Borland C++ Builder 6 @@ -2060,7 +2076,7 @@ Do you want to proceed? - + (Not found) @@ -2110,157 +2126,157 @@ Do you want to proceed? - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + Class Foreground Color - + File 파일 - + Line - + Severity 분류 - + Classification - + Level - + Inconclusive - + Summary 요약 - + Id - + Guideline - + Rule - + Since date - + Tags - + CWE @@ -2311,42 +2327,42 @@ Do you want to proceed? 미정의된 파일 - + style 스타일 - + error 에러 - + warning 경고 - + performance 성능 - + portability 이식성 - + information 정보 - + debug 디버그 - + internal @@ -2355,13 +2371,13 @@ Do you want to proceed? 숨기기 - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2370,7 +2386,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2379,12 +2395,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! 파일을 찾을 수 없습니다! - + Could not start %1 Please check the application path and parameters are correct. @@ -2393,72 +2409,72 @@ Please check the application path and parameters are correct. 경로와 인자가 정확한지 확인하세요. - + Select Directory 디렉토리 선택 - + Hide all with id - + Open containing folder - + note - + Recheck %1 file(s) - + Hide %1 result(s) - + Suppress selected id(s) - + Tag - + No tag - + Could not find file: - + Please select the folder '%1' - + Select Directory '%1' - + Please select the directory where file is located. - + Copy @@ -3125,10 +3141,18 @@ To toggle what kind of errors are shown, open view menu. + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked %2 중 %1 파일 검사됨 diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts index 732073d404a..2d3149d2f0a 100644 --- a/gui/cppcheck_nl.ts +++ b/gui/cppcheck_nl.ts @@ -335,42 +335,42 @@ Parameters: -l(lijn) (bestand) Bewerk - - + + Library files (*.cfg) - + Open library file - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. - + Failed to load %1. %2. - + Cannot save file %1. Can not save file %1. - + Save the library as @@ -489,30 +489,30 @@ Parameters: -l(lijn) (bestand) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck - + A&nalyze - + Standard Standaard @@ -532,235 +532,235 @@ Parameters: -l(lijn) (bestand) &Werkbalken - + C++ standard C++standaard - + &C standard C standard C standaard - + &Edit Be&werken - + &License... &Licentie... - + A&uthors... A&uteurs... - + &About... &Over... - + &Files... &Bestanden... - - + + Analyze files Check files Controleer bestanden - + Ctrl+F Ctrl+F - + &Directory... &Mappen... - - + + Analyze directory Check directory Controleer Map - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop &Stop - - + + Stop analysis Stop checking Stop controle - + Esc Esc - + &Save results to file... &Resultaten opslaan... - + Ctrl+S Ctrl+S - + &Quit &Afsluiten - + &Clear results &Resultaten wissen - + &Preferences &Voorkeuren - - - + + + Show errors Toon fouten - - - + + + Show warnings Toon waarschuwingen - - + + Show performance warnings Toon presentatie waarschuwingen - + Show &hidden Toon &verborgen - + Information Informatie - + Show information messages Toon informatie bericht - + Show portability warnings Toon portabiliteit waarschuwingen - + Show Cppcheck results - + Clang - + Show Clang results - + &Filter &Filter - + Filter results Filter resultaten - + Windows 32-bit ANSI Windows 32-bit ANSI - + Windows 32-bit Unicode - + Unix 32-bit - + Unix 64-bit - + Windows 64-bit - + &Print... - + Print the Current Report - + Print Pre&view... - + Open a Print Preview Dialog for the Current Results - + Open library editor - + &Check all &Controleer alles @@ -776,325 +776,335 @@ Parameters: -l(lijn) (bestand) - + Report - + Filter - + &Reanalyze modified files &Recheck modified files - + Reanal&yze all files - + Ctrl+Q - + Style war&nings - + E&rrors - + &Uncheck all Selecteer &niets - + Collapse &all Alles Inkl&appen - + &Expand all Alles &Uitklappen - + &Standard &Standaard - + Standard items Standaard items - + Toolbar Werkbalk - + &Categories &Categorieën - + Error categories Foute Categorieën - + &Open XML... - + Open P&roject File... Open P&oject bestand... - + Ctrl+Shift+O - + Sh&ow Scratchpad... - + &New Project File... &Nieuw Project Bestand... - + Ctrl+Shift+N - + &Log View &Log weergave - + Log View Log weergave - + C&lose Project File &Sluit Project Bestand - + &Edit Project File... &Bewerk Project Bestand... - + &Statistics &Statistieken - + &Warnings - + Per&formance warnings - + &Information - + &Portability - + P&latforms - + C++&11 - + C&99 - + &Posix - + C&11 - + &C89 - + &C++03 - + &Library Editor... - + &Auto-detect language - + &Enforce C++ - + E&nforce C - + C++14 - + Reanalyze and check library - + Check configuration (defines, includes) - + C++17 - + C++20 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + &Contents &Inhoud - + Categories Categorieën - - + + Show style warnings Toon stijl waarschuwingen - + Open the help contents Open de help inhoud - + F1 - + &Help &Help - - + + Quick Filter: Snel Filter: - + Select configuration - + Found project file: %1 Do you want to load this project file instead? @@ -1102,27 +1112,27 @@ Do you want to load this project file instead? Wilt u dit project laden in plaats van? - + File not found - + Bad XML - + Missing attribute - + Bad attribute value - + Duplicate define @@ -1143,50 +1153,50 @@ Wilt u dit project laden in plaats van? - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + License Licentie - + Authors Auteurs - + Save the report file Rapport opslaan - - + + XML files (*.xml) XML bestanden (*.xml) - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. @@ -1195,131 +1205,132 @@ This is probably because the settings were changed between the Cppcheck versions Dit is waarschijnlijk omdat de instellingen zijn gewijzigd tussen de versies van cppcheck. Controleer (en maak) de bewerker instellingen, anders zal de bewerker niet correct starten. - + You must close the project file before selecting new files or directories! Je moet project bestanden sluiten voordat je nieuwe bestanden of mappen selekteerd! - + The library '%1' contains unknown elements: %2 - + Unsupported format - + Duplicate platform type - + Platform type redefined - + Unknown element - Unknown issue + Unknown element + Unknown issue - - - - + + + + Error - + Open the report file Open het rapport bestand - + Text files (*.txt) Tekst bestanden (*.txt) - + CSV files (*.csv) CSV bestanden (*.csv) - + Project files (*.cppcheck);;All files(*.*) Project bestanden (*.cppcheck);;Alle bestanden(*.*) - + Select Project File Selecteer project bestand - - - - + + + + Project: Project: - + No suitable files found to analyze! - + C/C++ Source - + Compile database - + Visual Studio - + Borland C++ Builder 6 - + Select files to analyze - + Select directory to analyze - + Select the configuration that will be analyzed - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1327,81 +1338,81 @@ Do you want to proceed? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Build dir '%1' does not exist, create it? - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Project files (*.cppcheck) - + Select Project Filename Selecteer project bestandsnaam - + No project file loaded Geen project bestand geladen - + The project file %1 @@ -1417,67 +1428,67 @@ Kan niet worden gevonden! Wilt u het bestand van de onlangs gebruikte project verwijderen -lijst? - + Install - + New version available: %1. %2 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1834,12 +1845,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting - + External tools @@ -1950,17 +1966,17 @@ Options: - + Bug hunting (Premium) - + Clang analyzer - + Clang-tidy @@ -1973,82 +1989,82 @@ Options: ProjectFileDialog - + Project file: %1 Project Bestand %1 - + Select Cppcheck build dir - + Select include directory Selecteer include map - + Select a directory to check Selecteer een map om te controleren - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore Selecteer een map om te negeren - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -2083,7 +2099,7 @@ Options: - + (Not found) @@ -2133,158 +2149,158 @@ Options: - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Foreground Color Class ForegroundColor - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + File Bestand - + Line Regel - + Severity Ernst - + Classification - + Level - + Inconclusive - + Summary Overzicht - + Id Id - + Guideline - + Rule - + Since date - + Tags - + CWE @@ -2335,37 +2351,37 @@ Options: Niet gedefinieerd bestand - + Copy - + Could not find file: - + Please select the folder '%1' - + Select Directory '%1' - + Please select the directory where file is located. - + debug - + note @@ -2374,53 +2390,53 @@ Options: Verberg - + Hide all with id Verberg alles met id - + Suppress selected id(s) - + Open containing folder - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag - + No tag - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2430,7 +2446,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2438,12 +2454,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! Kon het bestand niet vinden! - + Could not start %1 Please check the application path and parameters are correct. @@ -2452,7 +2468,7 @@ Please check the application path and parameters are correct. Gelieve te controleren of de het pad en de parameters correct zijn. - + Select Directory Selecteer map @@ -2461,32 +2477,32 @@ Gelieve te controleren of de het pad en de parameters correct zijn.Id - + style Stijlfouten - + error Fouten - + warning Waarschuwing - + performance Presentatie - + portability Portabiliteit - + information Informatie @@ -3150,10 +3166,18 @@ Gebruik het uitzicht menu om te selecteren welke fouten getoond worden.Informatie bericht + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked %1 van %2 bestanden gecontroleerd diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 3256348229a..124e4d783aa 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -335,42 +335,42 @@ Parameters: -l(line) (file) Изменить - - + + Library files (*.cfg) Файлы библиотек (*.cfg) - + Open library file Открыть файл библиотеки - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. Невозможно открыть файл %1. - + Failed to load %1. %2. Ошибка загрузки %1. %2. - + Cannot save file %1. Can not save file %1. Невозможно сохранить файл %1. - + Save the library as Сохранить библиотеку как @@ -489,30 +489,30 @@ Parameters: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck - + A&nalyze Анализ - + Standard Стандартные @@ -532,235 +532,235 @@ Parameters: -l(line) (file) &Панель инструментов - + C++ standard Стандарт C++ - + &C standard C standard &Стандарт C - + &Edit &Правка - + &License... &Лицензия... - + A&uthors... &Авторы... - + &About... &О программе... - + &Files... &Файлы... - - + + Analyze files Check files Проверить файлы - + Ctrl+F Ctrl+F - + &Directory... &Каталог... - - + + Analyze directory Check directory Проверка каталога - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop Остановить - - + + Stop analysis Stop checking Остановить проверку - + Esc Esc - + &Save results to file... Сохранить отчёт в файл... - + Ctrl+S Ctrl+S - + &Quit Выход - + &Clear results Очистить отчёт - + &Preferences Параметры - - - + + + Show errors Показать ошибки - - - + + + Show warnings Показать предупреждения - - + + Show performance warnings Показать предупреждения производительности - + Show &hidden Показать скрытые - + Information Информационные сообщения - + Show information messages Показать информационные сообщения - + Show portability warnings Показать предупреждения переносимости - + Show Cppcheck results Просмотр результатов Cppcheck - + Clang Clang - + Show Clang results Просмотр результатов Clang - + &Filter Фильтр - + Filter results Результаты фильтрации - + Windows 32-bit ANSI Windows 32-bit ANSI - + Windows 32-bit Unicode Windows 32-bit Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - + &Print... Печать... - + Print the Current Report Напечатать текущий отчет - + Print Pre&view... Предварительный просмотр... - + Open a Print Preview Dialog for the Current Results Открыть диалог печати для текущих результатов - + Open library editor Открыть редактор библиотек - + &Check all Отметить все @@ -776,325 +776,335 @@ Parameters: -l(line) (file) - + Report - + Filter Фильтр - + &Reanalyze modified files &Recheck modified files Заново проверить измененные файлы - + Reanal&yze all files Заново проверить все файлы - + Ctrl+Q - + Style war&nings Стилистические предупреждения - + E&rrors Ошибки - + &Uncheck all Сбросить все - + Collapse &all Свернуть все - + &Expand all Развернуть все - + &Standard Стандартные - + Standard items Стандартные элементы - + Toolbar Панель инструментов - + &Categories Категории - + Error categories Категории ошибок - + &Open XML... &Открыть XML... - + Open P&roject File... Открыть файл &проекта... - + Ctrl+Shift+O - + Sh&ow Scratchpad... Показать Блокнот - + &New Project File... &Новый файл проекта... - + Ctrl+Shift+N - + &Log View Посмотреть &лог - + Log View Посмотреть лог - + C&lose Project File &Закрыть файл проекта - + &Edit Project File... &Изменить файл проекта... - + &Statistics &Статистика - + &Warnings Предупреждения - + Per&formance warnings Предупреждения производительности - + &Information Информационные предупреждения - + &Portability Предупреждения переносимости - + P&latforms Платформы - + C++&11 - + C&99 - + &Posix - + C&11 - + &C89 - + &C++03 - + &Library Editor... Редактор библиотеки - + &Auto-detect language Автоматическое определение языка - + &Enforce C++ Принудительно C++ - + E&nforce C Принудительно C - + C++14 C++14 - + Reanalyze and check library Повторный анализ библиотеки - + Check configuration (defines, includes) Проверить конфигурацию (defines, includes) - + C++17 C++17 - + C++20 C++20 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + &Contents Помощь - + Categories Категории - - + + Show style warnings Показать стилистические предупреждения - + Open the help contents Открыть помощь - + F1 F1 - + &Help Помощь - - + + Quick Filter: Быстрый фильтр: - + Select configuration Выбор конфигурации - + Found project file: %1 Do you want to load this project file instead? @@ -1103,32 +1113,32 @@ Do you want to load this project file instead? Вы хотите загрузить этот проект? - + File not found Файл не найден - + Bad XML Некорректный XML - + Missing attribute Пропущен атрибут - + Bad attribute value Некорректное значение атрибута - + Unsupported format Неподдерживаемый формат - + Duplicate define @@ -1150,50 +1160,50 @@ Do you want to load this project file instead? - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + License Лицензия - + Authors Авторы - + Save the report file Сохранить файл с отчетом - - + + XML files (*.xml) XML-файлы (*.xml) - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. @@ -1202,42 +1212,43 @@ This is probably because the settings were changed between the Cppcheck versions Возможно, это связано с изменениями в версии программы. Пожалуйста, проверьте (и исправьте) настройки приложения. - + You must close the project file before selecting new files or directories! Вы должны закрыть проект перед выбором новых файлов или каталогов! - + The library '%1' contains unknown elements: %2 Библиотека '%1' содержит неизвестные элементы: %2 - + Duplicate platform type Дубликат типа платформы - + Platform type redefined Переобъявление типа платформы - + Unknown element Неизвестный элемент - Unknown issue - Неизвестная проблема + Unknown element + Unknown issue + Неизвестная проблема - - - - + + + + Error Ошибка @@ -1246,80 +1257,80 @@ This is probably because the settings were changed between the Cppcheck versions Невозможно загрузить %1. Cppcheck установлен некорректно. Вы можете использовать --data-dir=<directory> в командной строке для указания расположения файлов конфигурации. Обратите внимание, что --data-dir предназначен для использования сценариями установки. При включении данной опции, графический интерфейс пользователя не запускается. - + Open the report file Открыть файл с отчетом - + Text files (*.txt) Текстовые файлы (*.txt) - + CSV files (*.csv) CSV файлы(*.csv) - + Project files (*.cppcheck);;All files(*.*) Файлы проекта (*.cppcheck);;Все файлы(*.*) - + Select Project File Выберите файл проекта - - - - + + + + Project: Проект: - + No suitable files found to analyze! Не найдено подходящих файлов для анализа - + C/C++ Source Исходный код C/C++ - + Compile database - + Visual Studio Visual Studio - + Borland C++ Builder 6 Borland C++ Builder 6 - + Select files to analyze Выбор файлов для анализа - + Select directory to analyze Выбор каталога для анализа - + Select the configuration that will be analyzed Выбор используемой конфигурации - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? @@ -1328,7 +1339,7 @@ Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1339,7 +1350,7 @@ Do you want to proceed? Вы хотите продолжить? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? @@ -1348,109 +1359,109 @@ Do you want to stop the analysis and exit Cppcheck? Вы хотите остановить анализ и выйти из Cppcheck? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML файлы (*.xml);;Текстовые файлы (*.txt);;CSV файлы (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Build dir '%1' does not exist, create it? Директория для сборки '%1' не существует, создать? - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1459,22 +1470,22 @@ Analysis is stopped. Невозможно импортировать '%1', анализ остановлен - + Project files (*.cppcheck) Файлы проекта (*.cppcheck) - + Select Project Filename Выберите имя файла для проекта - + No project file loaded Файл с проектом не загружен - + The project file %1 @@ -1490,12 +1501,12 @@ Do you want to remove the file from the recently used projects -list? Хотите удалить его из списка проектов? - + Install - + New version available: %1. %2 @@ -1878,12 +1889,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting - + External tools Внешние инструменты @@ -1985,17 +2001,17 @@ Options: - + Bug hunting (Premium) - + Clang analyzer - + Clang-tidy @@ -2008,82 +2024,82 @@ Options: ProjectFileDialog - + Project file: %1 Файл проекта: %1 - + Select Cppcheck build dir Выбрать директорию сборки Cppcheck - + Select include directory Выберите директорию для поиска заголовочных файлов - + Select a directory to check Выберите директорию для проверки - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) Clang-tidy (не найден) - + Visual Studio Visual Studio - + Compile database - + Borland C++ Builder 6 Borland C++ Builder 6 - + Import Project Импорт проекта - + Select directory to ignore Выберите директорию, которую надо проигнорировать - + Source files - + All files - + Exclude file - + Select MISRA rule texts file Выбрать файл текстов правил MISRA - + MISRA rule texts file (%1) Файл текстов правил MISRA (%1) @@ -2118,7 +2134,7 @@ Options: - + (Not found) (Недоступно) @@ -2168,158 +2184,158 @@ Options: - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Foreground Color Class ForegroundColor - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + File Файл - + Line Строка - + Severity Важность - + Classification - + Level - + Inconclusive Спорное - + Summary Кратко - + Id Id - + Guideline - + Rule - + Since date Начиная с даты - + Tags - + CWE @@ -2370,37 +2386,37 @@ Options: Неопределенный файл - + Copy Копировать - + Could not find file: Невозможно найти файл: - + Please select the folder '%1' Выберите каталог '%1' - + Select Directory '%1' Выбрать каталог '%1' - + Please select the directory where file is located. Укажите каталог с расположением файла. - + debug отлаживать - + note заметка @@ -2413,53 +2429,53 @@ Options: Скрыть - + Hide all with id Скрыть все с id - + Suppress selected id(s) Подавить выбранные id - + Open containing folder Открыть содержащую папку - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag Тег - + No tag Тег отсутствует - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2468,7 +2484,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2476,12 +2492,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! Не удается найти файл! - + Could not start %1 Please check the application path and parameters are correct. @@ -2489,7 +2505,7 @@ Please check the application path and parameters are correct. Пожалуйста, проверьте путь приложения, и верны ли параметры. - + Select Directory Выберите директорию @@ -2506,32 +2522,32 @@ Please check the application path and parameters are correct. Начиная с даты - + style стиль - + error ошибка - + warning предупреждение - + performance производительность - + portability переносимость - + information информация @@ -3199,10 +3215,18 @@ To toggle what kind of errors are shown, open view menu. Информационные сообщения + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked %1 из %2 файлов проверены diff --git a/gui/cppcheck_sr.ts b/gui/cppcheck_sr.ts index 093d6846612..70b04dd196f 100644 --- a/gui/cppcheck_sr.ts +++ b/gui/cppcheck_sr.ts @@ -323,42 +323,42 @@ Parameters: -l(line) (file) - - + + Library files (*.cfg) - + Open library file - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. - + Failed to load %1. %2. - + Cannot save file %1. Can not save file %1. - + Save the library as @@ -477,30 +477,30 @@ Parameters: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck - + A&nalyze - + Standard Standard @@ -520,235 +520,235 @@ Parameters: -l(line) (file) - + C++ standard - + &C standard C standard - + &Edit &Edit - + &License... &License... - + A&uthors... A&uthors... - + &About... &About... - + &Files... &Files... - - + + Analyze files Check files - + Ctrl+F Ctrl+F - + &Directory... &Directory... - - + + Analyze directory Check directory - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop &Stop - - + + Stop analysis Stop checking - + Esc Esc - + &Save results to file... &Save results to file... - + Ctrl+S Ctrl+S - + &Quit &Quit - + &Clear results &Clear results - + &Preferences &Preferences - - - + + + Show errors - - - + + + Show warnings - - + + Show performance warnings - + Show &hidden - + Information - + Show information messages - + Show portability warnings - + Show Cppcheck results - + Clang - + Show Clang results - + &Filter - + Filter results - + Windows 32-bit ANSI Windows 32-bit ANSI - + Windows 32-bit Unicode Windows 32-bit Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - + &Print... - + Print the Current Report - + Print Pre&view... - + Open a Print Preview Dialog for the Current Results - + Open library editor - + &Check all &Check all @@ -764,352 +764,362 @@ Parameters: -l(line) (file) - + Report - + Filter - + &Reanalyze modified files &Recheck modified files - + Reanal&yze all files - + Ctrl+Q - + Style war&nings - + E&rrors - + &Uncheck all &Uncheck all - + Collapse &all Collapse &all - + &Expand all &Expand all - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + &Open XML... - + Open P&roject File... - + Ctrl+Shift+O - + Sh&ow Scratchpad... - + &New Project File... - + Ctrl+Shift+N - + &Log View - + Log View - + C&lose Project File - + &Edit Project File... - + &Statistics - + &Warnings - + Per&formance warnings - + &Information - + &Portability - + P&latforms - + C++&11 - + C&99 - + &Posix - + C&11 - + &C89 - + &C++03 - + &Library Editor... - + &Auto-detect language - + &Enforce C++ - + E&nforce C - + C++14 C++14 - + Reanalyze and check library - + Check configuration (defines, includes) - + C++17 C++17 - + C++20 C++20 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + &Contents - + Categories - - + + Show style warnings - + Open the help contents - + F1 F1 - + &Help &Help - - + + Quick Filter: - + Select configuration - + Found project file: %1 Do you want to load this project file instead? - + File not found - + Bad XML - + Missing attribute - + Bad attribute value - + Duplicate define @@ -1130,181 +1140,182 @@ Do you want to load this project file instead? - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + License License - + Authors Authors - + Save the report file Save the report file - - + + XML files (*.xml) XML files (*.xml) - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. - + You must close the project file before selecting new files or directories! - + The library '%1' contains unknown elements: %2 - + Unsupported format - + Duplicate platform type - + Platform type redefined - + Unknown element - Unknown issue + Unknown element + Unknown issue - - - - + + + + Error - + Open the report file - + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Project files (*.cppcheck);;All files(*.*) - + Select Project File - - - - + + + + Project: - + No suitable files found to analyze! - + C/C++ Source - + Compile database - + Visual Studio - + Borland C++ Builder 6 - + Select files to analyze - + Select directory to analyze - + Select the configuration that will be analyzed - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1312,81 +1323,81 @@ Do you want to proceed? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Build dir '%1' does not exist, create it? - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Project files (*.cppcheck) - + Select Project Filename - + No project file loaded - + The project file %1 @@ -1397,67 +1408,67 @@ Do you want to remove the file from the recently used projects -list? - + Install - + New version available: %1. %2 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1803,12 +1814,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting - + External tools @@ -1930,17 +1946,17 @@ Options: - + Bug hunting (Premium) - + Clang analyzer - + Clang-tidy @@ -1953,82 +1969,82 @@ Options: ProjectFileDialog - + Project file: %1 - + Select Cppcheck build dir - + Select include directory - + Select a directory to check - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) - + Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project - + Select directory to ignore - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) @@ -2061,7 +2077,7 @@ Options: - + (Not found) @@ -2111,158 +2127,158 @@ Options: - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Foreground Color Class ForegroundColor - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + File File - + Line Line - + Severity Severity - + Classification - + Level - + Inconclusive - + Summary - + Id - + Guideline - + Rule - + Since date - + Tags - + CWE @@ -2309,107 +2325,107 @@ Options: Undefined file - + Copy - + Could not find file: - + Please select the folder '%1' - + Select Directory '%1' - + Please select the directory where file is located. - + debug - + note - + Hide all with id - + Suppress selected id(s) - + Open containing folder - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag - + No tag - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. You can open this error by specifying applications in program's settings. - + No default editor application selected. Please select the default editor application in preferences/Applications. - + Could not find the file! - + Could not start %1 Please check the application path and parameters are correct. @@ -2418,37 +2434,37 @@ Please check the application path and parameters are correct. Please check the application path and parameters are correct. - + Select Directory - + style Style - + error Error - + warning - + performance - + portability - + information @@ -3107,10 +3123,18 @@ To toggle what kind of errors are shown, open view menu. + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked diff --git a/gui/cppcheck_sv.ts b/gui/cppcheck_sv.ts index 8070d7ee1ea..f37121c2f2f 100644 --- a/gui/cppcheck_sv.ts +++ b/gui/cppcheck_sv.ts @@ -335,42 +335,42 @@ Parametrar: -l(line) (file) Redigera - - + + Library files (*.cfg) Library fil (*.cfg) - + Open library file Öppna Library fil - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. Kunde ej öppna filen %1. - + Failed to load %1. %2. - + Cannot save file %1. Can not save file %1. Kunde ej spara filen %1. - + Save the library as Spara library som @@ -495,30 +495,30 @@ Exempel: MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck - + A&nalyze Analysera - + Standard Standard @@ -538,235 +538,235 @@ Exempel: Verktygsfält - + C++ standard C++ standard - + &C standard C standard C standard - + &Edit &Redigera - + &License... &Licens... - + A&uthors... &Utvecklat av... - + &About... &Om... - + &Files... &Filer... - - + + Analyze files Check files Analysera filer - + Ctrl+F Ctrl+F - + &Directory... &Katalog... - - + + Analyze directory Check directory Analysera mapp - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop &Stoppa - - + + Stop analysis Stop checking Stoppa analys - + Esc Esc - + &Save results to file... &Spara resultat till fil... - + Ctrl+S Ctrl+S - + &Quit &Avsluta - + &Clear results &Töm resultat - + &Preferences &Inställningar - - - + + + Show errors Visa fel - - - + + + Show warnings Visa varningar - - + + Show performance warnings Visa prestanda varningar - + Show &hidden Visa dolda - + Information Information - + Show information messages Visa informations meddelanden - + Show portability warnings Visa portabilitets varningar - + Show Cppcheck results Visa Cppcheck resultat - + Clang Clang - + Show Clang results Visa Clang resultat - + &Filter &Filter - + Filter results Filtrera resultat - + Windows 32-bit ANSI Windows 32-bit ANSI - + Windows 32-bit Unicode Windows 32-bit Unicode - + Unix 32-bit Unix 32-bit - + Unix 64-bit Unix 64-bit - + Windows 64-bit Windows 64-bit - + &Print... Skriv ut... - + Print the Current Report Skriv ut aktuell rapport - + Print Pre&view... Förhandsgranska utskrift... - + Open a Print Preview Dialog for the Current Results Öppnar förhandsgranskning för nuvarande resultat - + Open library editor Öppna library editor - + &Check all &Kryssa alla @@ -782,326 +782,336 @@ Exempel: - + Report - + Filter Filter - + &Reanalyze modified files &Recheck modified files Analysera om ändrade filer - + Reanal&yze all files Analysera om alla filer - + Ctrl+Q - + Style war&nings Style varningar - + E&rrors Fel - + &Uncheck all Kryssa &ur alla - + Collapse &all Ingen bra översättning! &Fäll ihop alla - + &Expand all &Expandera alla - + &Standard &Standard - + Standard items Standard poster - + Toolbar Verktygsfält - + &Categories &Kategorier - + Error categories Fel kategorier - + &Open XML... &Öppna XML... - + Open P&roject File... Öppna Projektfil... - + Ctrl+Shift+O - + Sh&ow Scratchpad... Visa Scratchpad... - + &New Project File... Ny projektfil... - + Ctrl+Shift+N - + &Log View - + Log View Logg vy - + C&lose Project File Stäng projektfil - + &Edit Project File... Redigera projektfil... - + &Statistics Statistik - + &Warnings Varningar - + Per&formance warnings Optimerings varningar - + &Information Information - + &Portability Portabilitet - + P&latforms Plattformar - + C++&11 C++11 - + C&99 C99 - + &Posix Posix - + C&11 C11 - + &C89 C89 - + &C++03 C++03 - + &Library Editor... Library Editor... - + &Auto-detect language Detektera språk automatiskt - + &Enforce C++ Tvinga C++ - + E&nforce C Tvinga C - + C++14 C++14 - + Reanalyze and check library - + Check configuration (defines, includes) - + C++17 C++17 - + C++20 C++20 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + &Contents &Innehåll - + Categories Kategorier - - + + Show style warnings Visa stil varningar - + Open the help contents Öppna hjälp - + F1 F1 - + &Help &Hjälp - - + + Quick Filter: Snabbfilter: - + Select configuration Välj konfiguration - + Found project file: %1 Do you want to load this project file instead? @@ -1110,32 +1120,32 @@ Do you want to load this project file instead? Vill du ladda denna projektfil istället? - + File not found Filen hittades ej - + Bad XML Ogiltig XML - + Missing attribute Attribut finns ej - + Bad attribute value Ogiltigt attribut värde - + Unsupported format Format stöds ej - + Duplicate define @@ -1157,50 +1167,50 @@ Vill du ladda denna projektfil istället? - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + License Licens - + Authors Utvecklare - + Save the report file Spara rapport - - + + XML files (*.xml) XML filer (*.xml) - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. @@ -1209,42 +1219,43 @@ This is probably because the settings were changed between the Cppcheck versions En trolig orsak är att inställningarna ändrats för olika Cppcheck versioner. Kontrollera programinställningarna. - + You must close the project file before selecting new files or directories! Du måste stänga projektfilen innan nya filer eller sökvägar kan väljas! - + The library '%1' contains unknown elements: %2 Library filen '%1' har element som ej hanteras: %2 - + Duplicate platform type Dubbel plattformstyp - + Platform type redefined Plattformstyp definieras igen - + Unknown element Element hanteras ej - Unknown issue - Något problem + Unknown element + Unknown issue + Något problem - - - - + + + + Error Fel @@ -1253,80 +1264,80 @@ En trolig orsak är att inställningarna ändrats för olika Cppcheck versioner. Misslyckades att ladda %1. Din Cppcheck installation är ej komplett. Du kan använda --data-dir<directory> på kommandoraden för att specificera var denna fil finns. Det är meningen att --data-dir kommandot skall köras under installationen,så GUIt kommer ej visas när --data-dir används allt som händer är att en inställning görs. - + Open the report file Öppna rapportfilen - + Text files (*.txt) Text filer (*.txt) - + CSV files (*.csv) CSV filer (*.csv) - + Project files (*.cppcheck);;All files(*.*) Projektfiler (*.cppcheck);;Alla filer(*.*) - + Select Project File Välj projektfil - - - - + + + + Project: Projekt: - + No suitable files found to analyze! Inga filer hittades att analysera! - + C/C++ Source - + Compile database - + Visual Studio Visual Studio - + Borland C++ Builder 6 - + Select files to analyze Välj filer att analysera - + Select directory to analyze Välj mapp att analysera - + Select the configuration that will be analyzed Välj konfiguration som kommer analyseras - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? @@ -1335,7 +1346,7 @@ Do you want to proceed analysis without using any of these project files? - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1343,7 +1354,7 @@ Do you want to proceed? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? @@ -1352,109 +1363,109 @@ Do you want to stop the analysis and exit Cppcheck? Vill du stoppa analysen och avsluta Cppcheck? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Build dir '%1' does not exist, create it? Build dir '%1' existerar ej, skapa den? - + To check the project using addons, you need a build directory. - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1463,22 +1474,22 @@ Analysis is stopped. Misslyckades att importera '%1', analysen stoppas - + Project files (*.cppcheck) Projekt filer (*.cppcheck) - + Select Project Filename Välj Projektfil - + No project file loaded Inget projekt laddat - + The project file %1 @@ -1495,12 +1506,12 @@ Do you want to remove the file from the recently used projects -list? Vill du ta bort filen från 'senast använda projekt'-listan? - + Install - + New version available: %1. %2 @@ -1843,12 +1854,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting (Premium) - + External tools @@ -1986,17 +2002,17 @@ Options: - + Bug hunting - + Clang analyzer Clang analyzer - + Clang-tidy Clang-tidy @@ -2009,82 +2025,82 @@ Options: ProjectFileDialog - + Project file: %1 Projektfil: %1 - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) - + Select Cppcheck build dir Välj Cppcheck build dir - + Select include directory Välj include sökväg - + Source files - + All files - + Exclude file - + Select MISRA rule texts file - + MISRA rule texts file (%1) - + Select a directory to check Välj mapp att analysera - + Visual Studio Visual Studio - + Compile database - + Borland C++ Builder 6 - + Import Project Importera Projekt - + Select directory to ignore Välj sökväg att ignorera @@ -2119,7 +2135,7 @@ Options: - + (Not found) @@ -2169,158 +2185,158 @@ Options: - + Editor Foreground Color - + Editor Background Color - + Highlight Background Color - + Line Number Foreground Color - + Line Number Background Color - + Keyword Foreground Color - + Keyword Font Weight - + Class Foreground Color Class ForegroundColor - + Class Font Weight - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color - + Symbol Background Color - + Symbol Font Weight - + Set to Default Light - + Set to Default Dark - + File Fil - + Line Rad - + Severity Typ - + Classification - + Level - + Inconclusive Inconclusive - + Summary Sammanfattning - + Id Id - + Guideline - + Rule - + Since date Sedan datum - + Tags - + CWE @@ -2371,37 +2387,37 @@ Options: Odefinierad fil - + Copy - + Could not find file: - + Please select the folder '%1' - + Select Directory '%1' - + Please select the directory where file is located. - + debug debug - + note note @@ -2414,53 +2430,53 @@ Options: Dölj - + Hide all with id Dölj alla med id - + Suppress selected id(s) Stäng av valda id - + Open containing folder Öppna mapp - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag Tag - + No tag Ingen tag - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2470,7 +2486,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2479,12 +2495,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! Kunde inte hitta filen! - + Could not start %1 Please check the application path and parameters are correct. @@ -2493,7 +2509,7 @@ Please check the application path and parameters are correct. Kontrollera att sökvägen och parametrarna är korrekta. - + Select Directory Välj mapp @@ -2510,32 +2526,32 @@ Kontrollera att sökvägen och parametrarna är korrekta. Sedan datum - + style stil - + error fel - + warning varning - + performance prestanda - + portability portabilitet - + information information @@ -3203,10 +3219,18 @@ För att ställa in vilka fel som skall visas använd visa menyn. Informationsmeddelanden + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked %1 av %2 filer analyserade diff --git a/gui/cppcheck_zh_CN.ts b/gui/cppcheck_zh_CN.ts index 5e329d74f3c..02477e72e81 100644 --- a/gui/cppcheck_zh_CN.ts +++ b/gui/cppcheck_zh_CN.ts @@ -332,42 +332,42 @@ Parameters: -l(line) (file) 编辑 - - + + Library files (*.cfg) 库文件 (*.cfg) - + Open library file 打开库文件 - - - + + + Cppcheck Cppcheck - + Cannot open file %1. Can not open file %1. 无法打开文件 %1。 - + Failed to load %1. %2. 加载文件 %1 失败。%2。 - + Cannot save file %1. Can not save file %1. 无法保存文件 %1。 - + Save the library as 库另存为 @@ -496,20 +496,20 @@ Parameters: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck @@ -529,271 +529,271 @@ Parameters: -l(line) (file) 工具栏(&T) - + &Help 帮助(&H) - + C++ standard C++ 标准 - + &C standard C standard &C 标准 - + &Edit 编辑(&E) - + Standard 标准 - + Categories 分类 - + &License... 许可证(&L)... - + A&uthors... 作者(&U)... - + &About... 关于(&A)... - + &Files... 文件(&F)... - - + + Analyze files Check files 分析文件 - + Ctrl+F Ctrl+F - + &Directory... 目录(&D)... - - + + Analyze directory Check directory 分析目录 - + Ctrl+D Ctrl+D - + Ctrl+R Ctrl+R - + &Stop 停止(&S) - - + + Stop analysis Stop checking 停止分析 - + Esc Esc - + &Save results to file... 保存结果到文件(&S)... - + Ctrl+S Ctrl+S - + &Quit 退出(&Q) - + &Clear results 清空结果(&C) - + &Preferences 首选项(&P) - - + + Show style warnings 显示风格警告 - - - + + + Show errors 显示错误 - + Information 信息 - + Show information messages 显示信息消息 - + Show portability warnings 显示可移植性警告 - + Show Cppcheck results 显示 Cppcheck 结果 - + Clang Clang - + Show Clang results 显示 Clang 结果 - + &Filter 滤器(&F) - + Filter results 过滤结果 - + Windows 32-bit ANSI - + Windows 32-bit Unicode - + Unix 32-bit - + Unix 64-bit - + Windows 64-bit - + &Print... 打印(&P)... - + Print the Current Report 打印当前报告 - + Print Pre&view... 打印预览(&v)... - + Open a Print Preview Dialog for the Current Results 打开当前结果的打印预览窗口 - + Open library editor 打开库编辑器 - + C&lose Project File 关闭项目文件(&L) - + &Edit Project File... 编辑项目文件(&E)... - + &Statistics 统计(&S) - - - + + + Show warnings 显示警告 - - + + Show performance warnings 显示性能警告 - + Show &hidden 显示隐藏项(&H) - + &Check all 全部选中(&C) @@ -809,288 +809,298 @@ Parameters: -l(line) (file) - + Report - + A&nalyze 分析(&A) - + Filter 滤器 - + &Reanalyze modified files &Recheck modified files 重新分析已修改的文件(&R) - + Reanal&yze all files 重新分析全部文件(&y) - + Ctrl+Q Ctrl+Q - + Style war&nings 风格警告(&n) - + E&rrors 编辑(&r) - + &Uncheck all 全部取消选中(&U) - + Collapse &all 全部折叠(&A) - + &Expand all 全部展开(&E) - + &Standard 标准(&S) - + Standard items 标准项 - + &Contents 内容(&C) - + Open the help contents 打开帮助内容 - + F1 F1 - + Toolbar 工具栏 - + &Categories 分类(&C) - + Error categories 错误分类 - + &Open XML... 打开 XML (&O)... - + Open P&roject File... 打开项目文件(&R)... - + Ctrl+Shift+O Ctrl+Shift+O - + Sh&ow Scratchpad... 显示便条(&o)... - + &New Project File... 新建项目文件(&N)... - + Ctrl+Shift+N Ctrl+Shift+N - + &Log View 日志视图(&L) - + Log View 日志视图 - + &Warnings 警告(&W) - + Per&formance warnings 性能警告(&f) - + &Information 信息(&I) - + &Portability 可移植性(&P) - + P&latforms 平台(&l) - + C++&11 C++&11 - + C&99 C&99 - + &Posix &Posix - + C&11 C&11 - + &C89 &C89 - + &C++03 &C++03 - + &Library Editor... 库编辑器(&L)... - + &Auto-detect language 自动检测语言(&A) - + &Enforce C++ &Enforce C++ - + E&nforce C E&nforce C - + C++14 C++14 - + Reanalyze and check library 重新分析并检查库 - + Check configuration (defines, includes) 检查配置(defines, includes) - + C++17 C++17 - + C++20 C++20 - + Compliance report... - + Normal 常规 - + Misra C - + Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 - + Autosar - + EULA... - + + Thread Details + + + + + Show thread details + + + + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. @@ -1099,23 +1109,23 @@ This is probably because the settings were changed between the Cppcheck versions 这可能是因为 Cppcheck 不同版本间的设置有所不同。请检查(并修复)编辑器应用程序设置,否则编辑器程序可能不会正确启动。 - + You must close the project file before selecting new files or directories! 在选择新的文件或目录之前,你必须先关闭此项目文件! - - + + Quick Filter: 快速滤器: - + Select configuration 选择配置 - + Found project file: %1 Do you want to load this project file instead? @@ -1124,56 +1134,57 @@ Do you want to load this project file instead? 你是否想加载该项目文件? - + The library '%1' contains unknown elements: %2 库 '%1' 包含未知元素: %2 - + File not found 文件未找到 - + Bad XML 无效的 XML - + Missing attribute 缺失属性 - + Bad attribute value 无效的属性值 - + Unsupported format 不支持的格式 - + Duplicate platform type 重复的平台类型 - + Platform type redefined 平台类型重定义 - + Unknown element 位置元素 - Unknown issue - 未知问题 + Unknown element + Unknown issue + 未知问题 @@ -1183,10 +1194,10 @@ Do you want to load this project file instead? %2 - - - - + + + + Error 错误 @@ -1195,143 +1206,143 @@ Do you want to load this project file instead? 加载 %1 失败。您的 Cppcheck 安装已损坏。您可以在命令行添加 --data-dir=<目录> 参数来指定文件位置。请注意,'--data-dir' 参数应当由安装脚本使用,因此,当使用此参数时,GUI不会启动,所发生的一切只是配置了设置。 - - + + XML files (*.xml) XML 文件(*.xml) - + Open the report file 打开报告文件 - + License 许可证 - + Authors 作者 - + Save the report file 保存报告文件 - + Text files (*.txt) 文本文件(*.txt) - + CSV files (*.csv) CSV 文件(*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Project files (*.cppcheck);;All files(*.*) 项目文件(*.cppcheck);;所有文件(*.*) - + Select Project File 选择项目文件 - + Failed to open file - + Unknown project file format - + Failed to import project file - + Failed to import '%1': %2 Analysis is stopped. - + Failed to import '%1' (%2), analysis is stopped - + Install - + New version available: %1. %2 - - - - + + + + Project: 项目: - + No suitable files found to analyze! 没有找到合适的文件来分析! - + C/C++ Source C/C++ 源码 - + Compile database Compile database - + Visual Studio Visual Studio - + Borland C++ Builder 6 Borland C++ Builder 6 - + Select files to analyze 选择要分析的文件 - + Select directory to analyze 选择要分析的目录 - + Select the configuration that will be analyzed 选择要分析的配置 - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? @@ -1340,7 +1351,7 @@ Do you want to proceed analysis without using any of these project files? - + Duplicate define @@ -1355,29 +1366,29 @@ Do you want to proceed analysis without using any of these project files? - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1388,7 +1399,7 @@ Do you want to proceed? 你想继续吗? - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? @@ -1397,77 +1408,77 @@ Do you want to stop the analysis and exit Cppcheck? 您想停止分析并退出 Cppcheck 吗? - + About - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML 文件 (*.xml);;文本文件 (*.txt);;CSV 文件 (*.csv) - + Build dir '%1' does not exist, create it? 构建文件夹 '%1' 不能存在,创建它吗? - + To check the project using addons, you need a build directory. 要使用插件检查项目,您需要一个构建目录。 - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1476,22 +1487,22 @@ Do you want to stop the analysis and exit Cppcheck? 导入 '%1' 失败,分析已停止 - + Project files (*.cppcheck) 项目文件 (*.cppcheck) - + Select Project Filename 选择项目文件名 - + No project file loaded 项目文件未加载 - + The project file %1 @@ -1860,12 +1871,17 @@ Options: - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting - + External tools 外部工具 @@ -1992,17 +2008,17 @@ Options: - + Bug hunting (Premium) - + Clang analyzer Clang analyzer - + Clang-tidy Clang-tidy @@ -2015,82 +2031,82 @@ Options: ProjectFileDialog - + Project file: %1 项目文件: %1 - + Select Cppcheck build dir 选择 Cppcheck 构建目录 - + Select include directory 选择 Include 目录 - + Select a directory to check 选择一个检查目录 - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) Clang-tidy (未找到) - + Visual Studio Visual Studio - + Compile database Compile database - + Borland C++ Builder 6 Borland C++ Builder 6 - + Import Project 导入项目 - + Select directory to ignore 选择忽略的目录 - + Source files 源文件 - + All files 全部文件 - + Exclude file 排除文件 - + Select MISRA rule texts file 选择 MISRA 规则文本文件 - + MISRA rule texts file (%1) MISRA 规则文本文件 (%1) @@ -2123,7 +2139,7 @@ Options: 第%1行:在 "%3" 中缺失的必选属性 "%2" - + (Not found) (未找到) @@ -2173,158 +2189,158 @@ Options: 极粗 - + Editor Foreground Color 编辑器前景色 - + Editor Background Color 编辑器背景色 - + Highlight Background Color 高亮背景色 - + Line Number Foreground Color 行号前景色 - + Line Number Background Color 行号背景色 - + Keyword Foreground Color 关键字前景色 - + Keyword Font Weight 关键字字体大小 - + Class Foreground Color Class ForegroundColor 类前景色 - + Class Font Weight 类字体大小 - + Quote Foreground Color 引用前景色 - + Quote Font Weight 引用字体大小 - + Comment Foreground Color 注释前景色 - + Comment Font Weight 注释字体大小 - + Symbol Foreground Color 符号前景色 - + Symbol Background Color 符号背景色 - + Symbol Font Weight 符号字体大小 - + Set to Default Light 设置为默认亮色 - + Set to Default Dark 设置为默认暗色 - + File 文件 - + Line - + Severity 严重性 - + Classification - + Level - + Inconclusive 不确定的 - + Summary 概要 - + Id Id - + Guideline - + Rule - + Since date 日期 - + Tags - + CWE @@ -2375,37 +2391,37 @@ Options: 未定义文件 - + Copy 复制 - + Could not find file: 找不到文件: - + Please select the folder '%1' 请选择文件夹 '%1' - + Select Directory '%1' 选择目录 '%1' - + Please select the directory where file is located. 请选择文件所在的目录。 - + debug 调试 - + note 注意 @@ -2418,53 +2434,53 @@ Options: 隐藏 - + Hide all with id 隐藏全部 ID - + Suppress selected id(s) 抑制选择的 ID - + Open containing folder 打开包含的文件夹 - + internal - + Recheck %1 file(s) - + Hide %1 result(s) - + Tag 标记 - + No tag 取消标记 - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. @@ -2474,7 +2490,7 @@ Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. @@ -2483,12 +2499,12 @@ Please select the default editor application in preferences/Applications. - + Could not find the file! 找不到文件! - + Could not start %1 Please check the application path and parameters are correct. @@ -2497,7 +2513,7 @@ Please check the application path and parameters are correct. 请检查此应用程序的路径与参数是否正确。 - + Select Directory 选择目录 @@ -2514,32 +2530,32 @@ Please check the application path and parameters are correct. 日期 - + style 风格 - + error 错误 - + warning 警告 - + performance 性能 - + portability 移植可能性 - + information 信息 @@ -3211,10 +3227,18 @@ To toggle what kind of errors are shown, open view menu. 信息 + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked %2 个文件已检查 %1 个 diff --git a/gui/cppcheck_zh_TW.ts b/gui/cppcheck_zh_TW.ts index c7c220899e8..644e92e7b49 100644 --- a/gui/cppcheck_zh_TW.ts +++ b/gui/cppcheck_zh_TW.ts @@ -322,40 +322,40 @@ Parameters: -l(line) (file) 編輯 - - + + Library files (*.cfg) 程式庫檔案 (*.cfg) - + Open library file 開啟程式庫檔案 - - - + + + Cppcheck Cppcheck - + Cannot open file %1. 無法開啟檔案 %1。 - + Failed to load %1. %2. 無法載入 %1. %2。 - + Cannot save file %1. 無法儲存檔案 %1。 - + Save the library as 另存程式庫為 @@ -474,20 +474,20 @@ Parameters: -l(line) (file) MainWindow - - - - - - - - - - - - - - + + + + + + + + + + + + + + Cppcheck Cppcheck @@ -518,545 +518,555 @@ Parameters: -l(line) (file) - + Report - + &Help 幫助(&H) - + A&nalyze 分析(&N) - + C++ standard C++ 標準 - + &C standard C 標準(&C) - + &Edit 編輯(&E) - + Standard 標準 - + Categories 分類 - + Filter 篩選 - + &License... 授權(&L)... - + A&uthors... 作者(&U)... - + &About... 關於(&A)... - + &Files... 檔案(&F)... - - + + Analyze files 分析檔案 - + Ctrl+F Ctrl+F - + &Directory... 目錄(&D)... - - + + Analyze directory 分析目錄 - + Ctrl+D Ctrl+D - + &Reanalyze modified files 重新分析已修改的檔案(&R) - + Ctrl+R Ctrl+R - + Reanal&yze all files 重新分析所有檔案(&Y) - + &Stop 停止(&S) - - + + Stop analysis 停止分析 - + Esc Esc - + &Save results to file... 儲存結果為檔案(&S)... - + Ctrl+S Ctrl+S - + &Quit 退出(&Q) - + Ctrl+Q Ctrl+Q - + &Clear results 清除結果(&C) - + &Preferences 偏好設定(&P) - + Style war&nings 樣式警告(&N) - - + + Show style warnings 顯示樣式警告 - + E&rrors 錯誤(&R) - - - + + + Show errors 顯示錯誤 - + &Check all 全部檢查(&C) - + &Uncheck all - + Collapse &all 全部摺疊(&A) - + &Expand all 全部展開(&E) - + &Standard 標準(&S) - + Standard items 標準項目 - + &Contents 內容(&C) - + Open the help contents 開啟幫助內容 - + F1 F1 - + Toolbar 工具條 - + &Categories 分類(&C) - + Error categories 錯誤分類 - + &Open XML... 開啟 XML(&O)... - + Open P&roject File... 開啟專案檔(&R)... - + Ctrl+Shift+O Ctrl+Shift+O - + Sh&ow Scratchpad... - + &New Project File... 新增專案檔(&N)... - + Ctrl+Shift+N Ctrl+Shift+N - + &Log View 日誌檢視(&L) - + Log View 日誌檢視 - + C&lose Project File 關閉專案檔(&L) - + &Edit Project File... 編輯專案檔(&E)... - + &Statistics 統計資料(&S) - + &Warnings 警告(&W) - - - + + + Show warnings 顯示警告 - + Per&formance warnings 效能警告(&F) - - + + Show performance warnings 顯示下效能警告 - + Show &hidden 顯示隱藏項目(&H) - + &Information 資訊(&I) - + Show information messages 顯示資訊訊息 - + &Portability 可移植性(&P) - + Show portability warnings 顯示可移植性警告 - + Show Cppcheck results 顯示 Cppcheck 結果 - + Clang Clang - + Show Clang results 顯示 Clang 結果 - + &Filter 篩選(&F) - + Filter results 篩選結果 - + Windows 32-bit ANSI Windows 32 位元 ANSI - + Windows 32-bit Unicode Windows 32 位元 Unicode - + Unix 32-bit Unix 32 位元 - + Unix 64-bit Unix 64 位元 - + Windows 64-bit Windows 64 位元 - + P&latforms 平臺(&L) - + C++&11 C++&11 - + C&99 C&99 - + &Posix - + C&11 C&11 - + &C89 &C89 - + &C++03 &C++03 - + &Print... 列印(&P)... - + Print the Current Report 列印當前報告 - + Print Pre&view... 列印預覽(&V)... - + Open a Print Preview Dialog for the Current Results 開啟當前結果的列印預覽視窗 - + &Library Editor... 程式庫編輯器(&L)... - + Open library editor 開啟程式庫編輯器 - + &Auto-detect language 自動偵測語言(&A) - + &Enforce C++ - + E&nforce C - + C++14 C++14 - + Reanalyze and check library 重新分析並檢查程式庫 - + Check configuration (defines, includes) 檢查組態 (定義、包含) - + C++17 C++17 - + C++20 C++20 - + Compliance report... - + Normal - + Misra C - + Misra C++ 2008 Misra C++ 2008 - + Cert C - + Cert C++ - + Misra C++ 2023 Misra C++ 2023 - + Autosar - + EULA... + + + Thread Details + + + + + Show thread details + + Cppcheck GUI. @@ -1081,151 +1091,152 @@ Options: Cppcheck GUI - 命令行參數 - - + + Quick Filter: 快速篩選: - - - - + + + + Project: 專案: - + There was a problem with loading the editor application settings. This is probably because the settings were changed between the Cppcheck versions. Please check (and fix) the editor application settings, otherwise the editor program might not start correctly. - + No suitable files found to analyze! 找不到適合的檔案來分析! - + You must close the project file before selecting new files or directories! 您必須在選取新檔案或目錄之前關閉該專案檔! - + C/C++ Source C/C++ 來源檔 - + Compile database 編譯資料庫 - + Visual Studio Visual Studio - + Borland C++ Builder 6 Borland C++ Builder 6 - + Select files to analyze 選取要分析的檔案 - + Select directory to analyze 選取要分析的目錄 - + Select configuration 選取組態 - + Select the configuration that will be analyzed 選取要分析的組態 - + Found project file: %1 Do you want to load this project file instead? - + Found project files from the directory. Do you want to proceed analysis without using any of these project files? - + Information 資訊 - + The library '%1' contains unknown elements: %2 - + File not found 找不到檔案 - + Bad XML - + Missing attribute - + Bad attribute value - + Unsupported format 未支援的格式 - + Duplicate platform type 重複的平臺型別 - + Platform type redefined 平臺型別重定義 - + Duplicate define - + Unknown element 未知的元素 - Unknown issue - 未知的議題 + Unknown element + Unknown issue + 未知的議題 @@ -1245,37 +1256,37 @@ Do you want to proceed analysis without using any of these project files? - - - - + + + + Error 錯誤 - + Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located. Please note that --data-dir is supposed to be used by installation scripts and therefore the GUI does not start when it is used, all that happens is that the setting is configured. Analysis is aborted. - + Failed to load %1 - %2 Analysis is aborted. - - + + %1 Analysis is aborted. - + Current results will be cleared. Opening a new XML file will clear current results. @@ -1283,18 +1294,18 @@ Do you want to proceed? - - + + XML files (*.xml) XML 檔案 (*.xml) - + Open the report file 開啟報告檔 - + Analyzer is running. Do you want to stop the analysis and exit Cppcheck? @@ -1303,82 +1314,82 @@ Do you want to stop the analysis and exit Cppcheck? 您想停止分析並離開 Cppcheck 嗎? - + About 關於 - + License 授權 - + Authors 作者 - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML 檔案 (*.xml);;文字檔 (*.txt);;CSV 檔案 (*.csv) - + Save the report file 儲存報告檔 - + Text files (*.txt) 文字檔 (*.txt) - + CSV files (*.csv) CSV 檔案 (*.csv) - + Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors. - + Project files (*.cppcheck);;All files(*.*) 專案檔 (*.cppcheck);;所有檔案 (*.*) - + Select Project File 選取專案檔 - + Build dir '%1' does not exist, create it? 建置目錄 '%1' 不存在,是否建立它? - + To check the project using addons, you need a build directory. - + Failed to open file 無法開啟檔案 - + Unknown project file format 未知的專案檔格式 - + Failed to import project file 無法匯入專案檔 - + Failed to import '%1': %2 Analysis is stopped. @@ -1387,62 +1398,62 @@ Analysis is stopped. 停止分析。 - + Failed to import '%1' (%2), analysis is stopped - + Show Mandatory - + Show Required - + Show Advisory - + Show Document - + Show L1 - + Show L2 - + Show L3 - + Show style - + Show portability - + Show performance - + Show information @@ -1451,22 +1462,22 @@ Analysis is stopped. 無法匯入 '%1',停止分析 - + Project files (*.cppcheck) 專案檔 (*.cppcheck) - + Select Project Filename 選取專案檔案名稱 - + No project file loaded - + The project file %1 @@ -1483,12 +1494,12 @@ Do you want to remove the file from the recently used projects -list? 您要從最近使用的專案列表中移除該檔案嗎? - + Install 安章 - + New version available: %1. %2 可用的新版本: %1. %2 @@ -1926,27 +1937,32 @@ Do you want to remove the file from the recently used projects -list? - + + Safety profiles (defined in C++ core guidelines) + + + + Bug hunting (Premium) - + Bug hunting - + External tools 外部工具 - + Clang-tidy Clang-tidy - + Clang analyzer Clang 分析器 @@ -1954,82 +1970,82 @@ Do you want to remove the file from the recently used projects -list? ProjectFileDialog - + Project file: %1 專案檔: %1 - + Note: Open source Cppcheck does not fully implement Misra C 2012 - + Clang-tidy (not found) Clang-tidy (找不到) - + Select Cppcheck build dir 選取 Cppcheck 建置目錄 - + Visual Studio Visual Studio - + Compile database 編譯資料庫 - + Borland C++ Builder 6 Borland C++ Builder 6 - + Import Project 匯入專案 - + Select a directory to check 選取要檢查的目錄 - + Select include directory 選取包含目錄 - + Select directory to ignore 選取要忽略的目錄 - + Source files 來源檔 - + All files 所有檔案 - + Exclude file 排除檔案 - + Select MISRA rule texts file 選取 MISRA 規則文字檔 - + MISRA rule texts file (%1) MISRA 規則文字檔 (%1) @@ -2082,92 +2098,92 @@ Do you want to remove the file from the recently used projects -list? - + Editor Foreground Color 編輯器前景色 - + Editor Background Color 編輯器背景色 - + Highlight Background Color 標明背景色 - + Line Number Foreground Color 行號前景色 - + Line Number Background Color 行號背景色 - + Keyword Foreground Color 關鍵字前景色 - + Keyword Font Weight - + Class Foreground Color 類別前景色 - + Class Font Weight 類別字型粗細 - + Quote Foreground Color - + Quote Font Weight - + Comment Foreground Color - + Comment Font Weight - + Symbol Foreground Color 符號前景色 - + Symbol Background Color 符號被景色 - + Symbol Font Weight 符號字型粗細 - + Set to Default Light - + Set to Default Dark @@ -2182,7 +2198,7 @@ Do you want to remove the file from the recently used projects -list? - + (Not found) (找不到) @@ -2202,67 +2218,67 @@ Do you want to remove the file from the recently used projects -list? - + File 檔案 - + Line 行號 - + Severity 安全性 - + Classification - + Level - + Inconclusive - + Summary - + Id 識別號 - + Guideline - + Rule - + Since date - + Tags - + CWE @@ -2297,52 +2313,52 @@ Do you want to remove the file from the recently used projects -list? 未定義的檔案 - + note - + style 樣式 - + error 錯誤 - + warning 警告 - + performance 效能 - + portability - + information 資訊 - + debug - + internal - + Copy 複製 @@ -2351,94 +2367,94 @@ Do you want to remove the file from the recently used projects -list? 隱藏 - + Recheck %1 file(s) - + Hide %1 result(s) - + Hide all with id - + Open containing folder - + Suppress selected id(s) - + Tag 標記 - + No tag 取消標記 - - + + Cppcheck Cppcheck - + No editor application configured. Configure the editor application for Cppcheck in preferences/Applications. - + No default editor application selected. Please select the default editor application in preferences/Applications. - + Could not find the file! 找不到該檔案! - + Could not start %1 Please check the application path and parameters are correct. - + Could not find file: - + Please select the folder '%1' 請選取資料夾 '%1' - + Select Directory '%1' 選取目錄 '%1' - + Please select the directory where file is located. 請選取資料夾所在的目錄。 - + Select Directory 選取目錄 @@ -3112,10 +3128,18 @@ To toggle what kind of errors are shown, open view menu. 掃描時間 + + ThreadDetails + + + Thread Details + + + ThreadResult - + %1 of %2 files checked From 9a00e4a1050abdd7452f9afe7d5b323aed0e789a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 2 Mar 2026 13:19:49 +0100 Subject: [PATCH 203/675] Release: Update copyright year (#8285) --- cli/cmdlineparser.cpp | 2 +- cli/cmdlineparser.h | 2 +- cli/cppcheckexecutor.cpp | 2 +- cli/cppcheckexecutor.h | 2 +- cli/executor.cpp | 2 +- cli/executor.h | 2 +- cli/main.cpp | 2 +- cli/processexecutor.cpp | 2 +- cli/processexecutor.h | 2 +- cli/signalhandler.cpp | 2 +- cli/singleexecutor.cpp | 2 +- cli/singleexecutor.h | 2 +- cli/threadexecutor.cpp | 2 +- cli/threadexecutor.h | 2 +- democlient/democlient.cpp | 2 +- gui/checkstatistics.cpp | 2 +- gui/checkthread.cpp | 2 +- gui/checkthread.h | 2 +- gui/codeeditor.cpp | 2 +- gui/codeeditor.h | 2 +- gui/codeeditorstyle.cpp | 2 +- gui/codeeditstyledialog.cpp | 2 +- gui/codeeditstyledialog.h | 2 +- gui/erroritem.h | 2 +- gui/helpdialog.h | 2 +- gui/librarydialog.cpp | 2 +- gui/mainwindow.cpp | 2 +- gui/mainwindow.h | 2 +- gui/projectfile.cpp | 2 +- gui/projectfile.h | 2 +- gui/projectfiledialog.cpp | 2 +- gui/resultitem.cpp | 2 +- gui/resultitem.h | 2 +- gui/resultstree.cpp | 2 +- gui/resultstree.h | 2 +- gui/resultsview.cpp | 2 +- gui/resultsview.h | 2 +- gui/threadhandler.cpp | 2 +- gui/threadhandler.h | 2 +- gui/threadresult.cpp | 2 +- gui/threadresult.h | 2 +- gui/translationhandler.h | 2 +- gui/xmlreportv2.h | 2 +- lib/addoninfo.cpp | 2 +- lib/addoninfo.h | 2 +- lib/analyzerinfo.cpp | 2 +- lib/analyzerinfo.h | 2 +- lib/astutils.cpp | 2 +- lib/astutils.h | 2 +- lib/check64bit.cpp | 2 +- lib/checkautovariables.cpp | 2 +- lib/checkbufferoverrun.cpp | 2 +- lib/checkclass.cpp | 2 +- lib/checkclass.h | 2 +- lib/checkcondition.cpp | 2 +- lib/checkers.h | 2 +- lib/checkersreport.cpp | 2 +- lib/checkexceptionsafety.cpp | 2 +- lib/checkfunctions.cpp | 2 +- lib/checkio.cpp | 2 +- lib/checkleakautovar.cpp | 2 +- lib/checkmemoryleak.cpp | 2 +- lib/checknullpointer.cpp | 2 +- lib/checkother.cpp | 2 +- lib/checksizeof.cpp | 2 +- lib/checktype.cpp | 2 +- lib/checkuninitvar.cpp | 2 +- lib/checkunusedfunctions.cpp | 2 +- lib/checkunusedvar.cpp | 2 +- lib/clangimport.cpp | 2 +- lib/config.h | 2 +- lib/cppcheck.cpp | 2 +- lib/cppcheck.h | 2 +- lib/ctu.cpp | 2 +- lib/errorlogger.cpp | 2 +- lib/errorlogger.h | 2 +- lib/filesettings.h | 2 +- lib/fwdanalysis.cpp | 2 +- lib/importproject.cpp | 2 +- lib/importproject.h | 2 +- lib/json.h | 2 +- lib/library.cpp | 2 +- lib/library.h | 2 +- lib/mathlib.cpp | 2 +- lib/pathmatch.cpp | 2 +- lib/pathmatch.h | 2 +- lib/platform.cpp | 2 +- lib/platform.h | 2 +- lib/preprocessor.cpp | 2 +- lib/reverseanalyzer.cpp | 2 +- lib/sarifreport.cpp | 2 +- lib/sarifreport.h | 2 +- lib/settings.cpp | 2 +- lib/settings.h | 2 +- lib/summaries.cpp | 2 +- lib/summaries.h | 2 +- lib/suppressions.cpp | 2 +- lib/suppressions.h | 2 +- lib/symboldatabase.cpp | 2 +- lib/symboldatabase.h | 2 +- lib/templatesimplifier.cpp | 2 +- lib/templatesimplifier.h | 2 +- lib/timer.cpp | 2 +- lib/timer.h | 2 +- lib/token.cpp | 2 +- lib/token.h | 2 +- lib/tokenize.cpp | 2 +- lib/tokenize.h | 2 +- lib/tokenlist.cpp | 2 +- lib/tokenlist.h | 2 +- lib/utils.h | 2 +- lib/valueflow.cpp | 2 +- lib/valueflow.h | 2 +- lib/version.h | 4 ++-- lib/vf_analyzers.cpp | 2 +- lib/vf_common.cpp | 2 +- lib/vf_settokenvalue.cpp | 2 +- lib/vfvalue.cpp | 2 +- oss-fuzz/main.cpp | 2 +- test/fixture.cpp | 2 +- test/fixture.h | 2 +- test/helpers.cpp | 2 +- test/main.cpp | 2 +- test/testanalyzerinformation.cpp | 2 +- test/testautovariables.cpp | 2 +- test/testbufferoverrun.cpp | 2 +- test/testclangimport.cpp | 2 +- test/testclass.cpp | 2 +- test/testcmdlineparser.cpp | 2 +- test/testcondition.cpp | 2 +- test/testcppcheck.cpp | 2 +- test/testexceptionsafety.cpp | 2 +- test/testexecutor.cpp | 2 +- test/testfunctions.cpp | 2 +- test/testgarbage.cpp | 2 +- test/testimportproject.cpp | 2 +- test/testleakautovar.cpp | 2 +- test/testmathlib.cpp | 2 +- test/testmemleak.cpp | 2 +- test/testnullpointer.cpp | 2 +- test/testother.cpp | 2 +- test/testpath.cpp | 2 +- test/testpathmatch.cpp | 2 +- test/testplatform.cpp | 2 +- test/testpreprocessor.cpp | 2 +- test/testprocessexecutor.cpp | 2 +- test/testprogrammemory.cpp | 2 +- test/testsarifreport.cpp | 2 +- test/testsettings.cpp | 2 +- test/testsimplifytemplate.cpp | 2 +- test/testsimplifytypedef.cpp | 2 +- test/testsimplifyusing.cpp | 2 +- test/testsingleexecutor.cpp | 2 +- test/teststl.cpp | 2 +- test/testsuppressions.cpp | 2 +- test/testsymboldatabase.cpp | 2 +- test/testthreadexecutor.cpp | 2 +- test/testtimer.cpp | 2 +- test/testtoken.cpp | 2 +- test/testtokenize.cpp | 2 +- test/testtype.cpp | 2 +- test/testuninitvar.cpp | 2 +- test/testunusedvar.cpp | 2 +- test/testutils.cpp | 2 +- test/testvalueflow.cpp | 2 +- test/testvarid.cpp | 2 +- 166 files changed, 167 insertions(+), 167 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index e5c990ab494..11f735e1ae5 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/cmdlineparser.h b/cli/cmdlineparser.h index 3fafce3ce57..54e7ae4b0aa 100644 --- a/cli/cmdlineparser.h +++ b/cli/cmdlineparser.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 6744a2e50d8..d5980db6f70 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index a063a795241..a1b35280597 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/executor.cpp b/cli/executor.cpp index c9c0c73c56e..d0a05eda5f7 100644 --- a/cli/executor.cpp +++ b/cli/executor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/executor.h b/cli/executor.h index d5a20fd4527..7e6fb83eeba 100644 --- a/cli/executor.h +++ b/cli/executor.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/main.cpp b/cli/main.cpp index aa9b2aa3889..1c39ab14544 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index 963818ecfb2..7b750fdc26b 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/processexecutor.h b/cli/processexecutor.h index f813b1893e5..6c590da4072 100644 --- a/cli/processexecutor.h +++ b/cli/processexecutor.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/signalhandler.cpp b/cli/signalhandler.cpp index d09bbd349d0..c87822454ae 100644 --- a/cli/signalhandler.cpp +++ b/cli/signalhandler.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/singleexecutor.cpp b/cli/singleexecutor.cpp index 9da1645a6a4..b84aa70772e 100644 --- a/cli/singleexecutor.cpp +++ b/cli/singleexecutor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/singleexecutor.h b/cli/singleexecutor.h index b6cae501214..8b908bd6c4e 100644 --- a/cli/singleexecutor.h +++ b/cli/singleexecutor.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index bdf1fb6f2e0..8e8893e72cb 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cli/threadexecutor.h b/cli/threadexecutor.h index e827969037c..a0ab4933573 100644 --- a/cli/threadexecutor.h +++ b/cli/threadexecutor.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/democlient/democlient.cpp b/democlient/democlient.cpp index 177aff28b71..8560596f4f3 100644 --- a/democlient/democlient.cpp +++ b/democlient/democlient.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/checkstatistics.cpp b/gui/checkstatistics.cpp index 54762f1c4fe..612e79da63b 100644 --- a/gui/checkstatistics.cpp +++ b/gui/checkstatistics.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index ab20602a09b..81471638e62 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/checkthread.h b/gui/checkthread.h index e78f1580440..a630ef7fc13 100644 --- a/gui/checkthread.h +++ b/gui/checkthread.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/codeeditor.cpp b/gui/codeeditor.cpp index b6d88a061d3..98886716556 100644 --- a/gui/codeeditor.cpp +++ b/gui/codeeditor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/codeeditor.h b/gui/codeeditor.h index 1ba8b3fd84d..4dfbaa66047 100644 --- a/gui/codeeditor.h +++ b/gui/codeeditor.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/codeeditorstyle.cpp b/gui/codeeditorstyle.cpp index 566d20eb1a3..6d7a15fb2f8 100644 --- a/gui/codeeditorstyle.cpp +++ b/gui/codeeditorstyle.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/codeeditstyledialog.cpp b/gui/codeeditstyledialog.cpp index 1c1bae22b92..44304ddddc1 100644 --- a/gui/codeeditstyledialog.cpp +++ b/gui/codeeditstyledialog.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/codeeditstyledialog.h b/gui/codeeditstyledialog.h index 28c3e738601..763372cbef6 100644 --- a/gui/codeeditstyledialog.h +++ b/gui/codeeditstyledialog.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/erroritem.h b/gui/erroritem.h index 2c657698d60..54c5a32a7f3 100644 --- a/gui/erroritem.h +++ b/gui/erroritem.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/helpdialog.h b/gui/helpdialog.h index 53ea0409a76..4f592f5c7f6 100644 --- a/gui/helpdialog.h +++ b/gui/helpdialog.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2024 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/librarydialog.cpp b/gui/librarydialog.cpp index e48e68e1c88..15572813c81 100644 --- a/gui/librarydialog.cpp +++ b/gui/librarydialog.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index c0d42a32d0d..f4e1dc2af9b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/mainwindow.h b/gui/mainwindow.h index e29d4d48f5b..45506f3f6b8 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index d2913fbfd65..9001b6ad604 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/projectfile.h b/gui/projectfile.h index 01abe0643a5..e7f8d342180 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2024 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 76fe51d2274..d1ddfc13200 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/resultitem.cpp b/gui/resultitem.cpp index 4215115be07..4f8c14fa056 100644 --- a/gui/resultitem.cpp +++ b/gui/resultitem.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/resultitem.h b/gui/resultitem.h index a39606ad23d..e0c212b2138 100644 --- a/gui/resultitem.h +++ b/gui/resultitem.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 1b7f8b878c3..c553855e99e 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/resultstree.h b/gui/resultstree.h index a2b07788f56..23fe5567ed9 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index b8ff3d8c598..8183214bb27 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/resultsview.h b/gui/resultsview.h index 500d40df981..77b4610145c 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index 55f60de673d..74735a9b666 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/threadhandler.h b/gui/threadhandler.h index 9f3d01f17e6..f98d5a6508d 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/threadresult.cpp b/gui/threadresult.cpp index f3a7e67ab16..a3929da7cca 100644 --- a/gui/threadresult.cpp +++ b/gui/threadresult.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/threadresult.h b/gui/threadresult.h index b7bece3e28c..f7ba6ad8216 100644 --- a/gui/threadresult.h +++ b/gui/threadresult.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/translationhandler.h b/gui/translationhandler.h index 8ab5b46b6f7..4cea7d4ce80 100644 --- a/gui/translationhandler.h +++ b/gui/translationhandler.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2024 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h index 55487db4317..58d368c4bc2 100644 --- a/gui/xmlreportv2.h +++ b/gui/xmlreportv2.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2024 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/addoninfo.cpp b/lib/addoninfo.cpp index ed10435a368..c0139320d7e 100644 --- a/lib/addoninfo.cpp +++ b/lib/addoninfo.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/addoninfo.h b/lib/addoninfo.h index dacb49be2df..902a26c2e12 100644 --- a/lib/addoninfo.h +++ b/lib/addoninfo.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2024 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index e76cae3bad6..8f220f34552 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index d324e7fc223..d8a220a5c55 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 2330a9d2b94..2d53ef0b0c1 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/astutils.h b/lib/astutils.h index 4002e065ab5..5b6b878f3ae 100644 --- a/lib/astutils.h +++ b/lib/astutils.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index a106b0afe5f..d203eb5f279 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index c164643594d..d867930f517 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 1b3e8bfbef9..a8f7efeabd6 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index a72603c782b..2b972e221fc 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkclass.h b/lib/checkclass.h index 3b49861126a..9a2d42442a9 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 2b3ca4ed93d..59aad6a9598 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkers.h b/lib/checkers.h index e7dd4164570..bda4a0320f5 100644 --- a/lib/checkers.h +++ b/lib/checkers.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkersreport.cpp b/lib/checkersreport.cpp index a5d9c619cb3..59b3cf99495 100644 --- a/lib/checkersreport.cpp +++ b/lib/checkersreport.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkexceptionsafety.cpp b/lib/checkexceptionsafety.cpp index 9311ed6b10e..34303cc0f4a 100644 --- a/lib/checkexceptionsafety.cpp +++ b/lib/checkexceptionsafety.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 1ab21eacfd2..3d6ff2ce755 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkio.cpp b/lib/checkio.cpp index a250e044c9f..ee1b4e36c73 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 148bd43c689..00c8492498a 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index b2ea542b964..81eb36b053d 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 4b6a21f82f9..42b9f76646e 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 4285154d841..32dedf8f374 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checksizeof.cpp b/lib/checksizeof.cpp index eead36c9f67..f7c0d44d399 100644 --- a/lib/checksizeof.cpp +++ b/lib/checksizeof.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 509d13b54e0..3f42bf075ef 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index d2e72e0c82f..7dc89eb398c 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 8f7c3ab3812..e10d25a87f1 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 5819eed715e..6e9381657b0 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index a7d9e710366..c96a678347a 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/config.h b/lib/config.h index 1b217e4546d..a63cf773d54 100644 --- a/lib/config.h +++ b/lib/config.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 200895e3050..1154d55bd9f 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 868100df170..2aeee1a0beb 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/ctu.cpp b/lib/ctu.cpp index b88bd049255..3f50dd1a485 100644 --- a/lib/ctu.cpp +++ b/lib/ctu.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 13f66c13d1a..07332d94fe9 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/errorlogger.h b/lib/errorlogger.h index 19d423f7f02..8c86224aa0f 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/filesettings.h b/lib/filesettings.h index aaa2f28779a..e9f883d5a87 100644 --- a/lib/filesettings.h +++ b/lib/filesettings.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/fwdanalysis.cpp b/lib/fwdanalysis.cpp index 64a896733d2..6363100b083 100644 --- a/lib/fwdanalysis.cpp +++ b/lib/fwdanalysis.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/importproject.cpp b/lib/importproject.cpp index ec0f3c4a97d..33b75b5dc7e 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/importproject.h b/lib/importproject.h index 45a8dbac8b1..ba873b69ae5 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/json.h b/lib/json.h index 51101842677..7f7107f7864 100644 --- a/lib/json.h +++ b/lib/json.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/library.cpp b/lib/library.cpp index f2363f75d14..1628cc3cdcd 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/library.h b/lib/library.h index d8c9e0c47cc..dea9c1e66c7 100644 --- a/lib/library.h +++ b/lib/library.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index effd03f0e7f..403662f4df2 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/pathmatch.cpp b/lib/pathmatch.cpp index 5dd11e1d755..90844befa82 100644 --- a/lib/pathmatch.cpp +++ b/lib/pathmatch.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/pathmatch.h b/lib/pathmatch.h index ab9d2a3c43d..b196528245c 100644 --- a/lib/pathmatch.h +++ b/lib/pathmatch.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/platform.cpp b/lib/platform.cpp index 48567c86d05..931a0d145a1 100644 --- a/lib/platform.cpp +++ b/lib/platform.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/platform.h b/lib/platform.h index 2ab33461ddb..97e7d296fba 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 50db3dd34a6..9528360906e 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/reverseanalyzer.cpp b/lib/reverseanalyzer.cpp index 6ebceb41b8f..50aad01fdd9 100644 --- a/lib/reverseanalyzer.cpp +++ b/lib/reverseanalyzer.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/sarifreport.cpp b/lib/sarifreport.cpp index ce142430f54..38eb9ea96ca 100644 --- a/lib/sarifreport.cpp +++ b/lib/sarifreport.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/sarifreport.h b/lib/sarifreport.h index 90667322b2f..6baf88cb04d 100644 --- a/lib/sarifreport.h +++ b/lib/sarifreport.h @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/settings.cpp b/lib/settings.cpp index 305af5a143c..645488260b0 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/settings.h b/lib/settings.h index 6521ba4581d..24fa2e93907 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/summaries.cpp b/lib/summaries.cpp index 52a5d06b141..fa5399fd73d 100644 --- a/lib/summaries.cpp +++ b/lib/summaries.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/summaries.h b/lib/summaries.h index a7a314da9a8..26d61e75e65 100644 --- a/lib/summaries.h +++ b/lib/summaries.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 1115414c21b..34eb8b52e5e 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/suppressions.h b/lib/suppressions.h index d164aa0caa4..7f5ffb87b09 100644 --- a/lib/suppressions.h +++ b/lib/suppressions.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index d731c2a8884..4dc75ba8c1f 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 0eaa0aab9ee..a4cdfc5370a 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 16b4bd18cd9..d73b3e7a9aa 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/templatesimplifier.h b/lib/templatesimplifier.h index b5285071841..f6e507459a9 100644 --- a/lib/templatesimplifier.h +++ b/lib/templatesimplifier.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/timer.cpp b/lib/timer.cpp index 9e2dd901bea..a135ad13233 100644 --- a/lib/timer.cpp +++ b/lib/timer.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/timer.h b/lib/timer.h index c3d477d5802..043e1c40b14 100644 --- a/lib/timer.h +++ b/lib/timer.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/token.cpp b/lib/token.cpp index 5aaf0960157..5424ac3396e 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/token.h b/lib/token.h index eec2c986493..51fe1b6b7d0 100644 --- a/lib/token.h +++ b/lib/token.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 301906e30fc..984269d07e8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/tokenize.h b/lib/tokenize.h index 61d1003f316..23669be7225 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 03095a40992..d5b48ceab22 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/tokenlist.h b/lib/tokenlist.h index 764eb67bdee..48cf5d99547 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/utils.h b/lib/utils.h index 90bb67c087f..abe1477a2a8 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index fdf7394aa3a..bf732566fff 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/valueflow.h b/lib/valueflow.h index a813ff8d286..f701f55c418 100644 --- a/lib/valueflow.h +++ b/lib/valueflow.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/version.h b/lib/version.h index 3a7c5918b45..4828a568104 100644 --- a/lib/version.h +++ b/lib/version.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,6 @@ #define CPPCHECK_VERSION_STRING "2.19 dev" #define CPPCHECK_VERSION 2,18,99,0 -#define LEGALCOPYRIGHT L"Copyright (C) 2007-2025 Cppcheck team." +#define LEGALCOPYRIGHT L"Copyright (C) 2007-2026 Cppcheck team." #endif diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index ec026f2f487..58fbe0b6d61 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/vf_common.cpp b/lib/vf_common.cpp index 333f850d07d..78f44de6754 100644 --- a/lib/vf_common.cpp +++ b/lib/vf_common.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/vf_settokenvalue.cpp b/lib/vf_settokenvalue.cpp index b2647bf46ec..12acc01dedd 100644 --- a/lib/vf_settokenvalue.cpp +++ b/lib/vf_settokenvalue.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/vfvalue.cpp b/lib/vfvalue.cpp index 4ec1c742ab3..308b42b91d1 100644 --- a/lib/vfvalue.cpp +++ b/lib/vfvalue.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/oss-fuzz/main.cpp b/oss-fuzz/main.cpp index 8500bb966cb..e1bd5952966 100644 --- a/oss-fuzz/main.cpp +++ b/oss-fuzz/main.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/fixture.cpp b/test/fixture.cpp index b59b47855f7..fb535b1a1d0 100644 --- a/test/fixture.cpp +++ b/test/fixture.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/fixture.h b/test/fixture.h index 2d519f40f45..35fb9ed6277 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/helpers.cpp b/test/helpers.cpp index 25b4564ed38..252658cc531 100644 --- a/test/helpers.cpp +++ b/test/helpers.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/main.cpp b/test/main.cpp index afe3e3b4171..571f7742f76 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2023 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testanalyzerinformation.cpp b/test/testanalyzerinformation.cpp index 22f868ffb1d..0936dbbf3f2 100644 --- a/test/testanalyzerinformation.cpp +++ b/test/testanalyzerinformation.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 6c1267ae288..560220f8c9e 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 91118c3dab5..7118a7ae906 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index ff670a172d8..6a39b563982 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -1,5 +1,5 @@ // Cppcheck - A tool for static C/C++ code analysis -// Copyright (C) 2007-2025 Cppcheck team. +// Copyright (C) 2007-2026 Cppcheck team. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/test/testclass.cpp b/test/testclass.cpp index ff486e3e450..9698916c41a 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index b6690f8d5c7..ef8afc1eb0a 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testcondition.cpp b/test/testcondition.cpp index f7a40e2d90b..a592c489c59 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 39e68a1fff9..84db6db6c28 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testexceptionsafety.cpp b/test/testexceptionsafety.cpp index 4744fd0f9c9..58b26ecbc27 100644 --- a/test/testexceptionsafety.cpp +++ b/test/testexceptionsafety.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testexecutor.cpp b/test/testexecutor.cpp index a0e5e02f1fb..30b2b834834 100644 --- a/test/testexecutor.cpp +++ b/test/testexecutor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index d353c83aecc..48516faf852 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index aaacfeda3ff..d7e6ed8345b 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testimportproject.cpp b/test/testimportproject.cpp index c3bee4dcfa6..a0daea25bb2 100644 --- a/test/testimportproject.cpp +++ b/test/testimportproject.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index d23a655b492..300db8d9855 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index dee1d3f5fe9..8cbe5b50019 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 30d55e47413..39f298fa923 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 37107397a44..eb61c781b13 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testother.cpp b/test/testother.cpp index 4727c15ef27..53f14c2a31d 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testpath.cpp b/test/testpath.cpp index 5f4770f1cff..2d937950646 100644 --- a/test/testpath.cpp +++ b/test/testpath.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testpathmatch.cpp b/test/testpathmatch.cpp index dc55bacf339..31cc5e687b6 100644 --- a/test/testpathmatch.cpp +++ b/test/testpathmatch.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testplatform.cpp b/test/testplatform.cpp index f82c46640e9..ccb7d9b41a8 100644 --- a/test/testplatform.cpp +++ b/test/testplatform.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 0f22a1fbca7..d072ebbf2e3 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testprocessexecutor.cpp b/test/testprocessexecutor.cpp index c430116110e..927c1f44723 100644 --- a/test/testprocessexecutor.cpp +++ b/test/testprocessexecutor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testprogrammemory.cpp b/test/testprogrammemory.cpp index 6d7c185e80f..688efa0075b 100644 --- a/test/testprogrammemory.cpp +++ b/test/testprogrammemory.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testsarifreport.cpp b/test/testsarifreport.cpp index b4d3056a762..e9fc56d736d 100644 --- a/test/testsarifreport.cpp +++ b/test/testsarifreport.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testsettings.cpp b/test/testsettings.cpp index 7bc6aeb0352..ddd11de3273 100644 --- a/test/testsettings.cpp +++ b/test/testsettings.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index fb95cd8c136..2dda926fb40 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 866ee85a5d7..12ee24ee5e1 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 5f1c2592b12..8eba2142913 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testsingleexecutor.cpp b/test/testsingleexecutor.cpp index 4e1a258d19b..3fb4c778043 100644 --- a/test/testsingleexecutor.cpp +++ b/test/testsingleexecutor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/teststl.cpp b/test/teststl.cpp index cc4856628df..9f25d29478b 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 0e6bbffadc4..4f6628f20d6 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 19c6fab336a..192c40f51e5 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testthreadexecutor.cpp b/test/testthreadexecutor.cpp index 27d88e1d699..c99d7753d12 100644 --- a/test/testthreadexecutor.cpp +++ b/test/testthreadexecutor.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testtimer.cpp b/test/testtimer.cpp index 75fead13d2d..c8d468b1afb 100644 --- a/test/testtimer.cpp +++ b/test/testtimer.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testtoken.cpp b/test/testtoken.cpp index 7b834b2164b..2b411324dc7 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7aca456a445..a698a3c20bf 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testtype.cpp b/test/testtype.cpp index ea31fbdc313..280e3357f85 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index b48db6ef972..554eaca1f11 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 43b5d2abe40..e5f4c08f043 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testutils.cpp b/test/testutils.cpp index 2526591e11f..b3da9b1f6dc 100644 --- a/test/testutils.cpp +++ b/test/testutils.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 36410a60508..00ebe7f694f 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 55627299e1d..416ad5d6b82 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -1,6 +1,6 @@ /* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2025 Cppcheck team. + * Copyright (C) 2007-2026 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 3a4850cefdb2b5e00bdedaec8be3b7aa933596d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 2 Mar 2026 14:05:57 +0100 Subject: [PATCH 204/675] releasenotes.txt: clear notes (#8289) --- releasenotes.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/releasenotes.txt b/releasenotes.txt index fe530b2121e..f80ee8dc42d 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -1,5 +1,5 @@ -Release Notes for Cppcheck 2.20 +Release Notes for Cppcheck 2.21 Major bug fixes & crashes: - @@ -14,14 +14,10 @@ GUI: - Changed interface: -- removed CMake option "DISABLE_CRTDBG_MAP_ALLOC" -- CMake option "BUILD_TESTS" has been deprecated and will be removed in Cppcheck 2.22 - use "BUILD_TESTING" instead - Infrastructure & dependencies: - Other: -- The built-in "win*" and "unix*" platforms will now default to signed char type instead of unknown signedness. If you require unsigned chars please specify "--funsigned-char" -- bumped minimum required CMake version to 3.22 - From b672d762eb3c0340c188e1ca2f0608274b860d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 2 Mar 2026 19:02:10 +0100 Subject: [PATCH 205/675] removed unnecessary CMake generator parameters from CI (#8286) --- .github/workflows/CI-unixish-docker.yml | 2 +- .github/workflows/CI-unixish.yml | 40 ++++++++++++------------- .github/workflows/clang-tidy.yml | 2 +- .github/workflows/iwyu.yml | 4 +-- .github/workflows/selfcheck.yml | 12 ++++---- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/CI-unixish-docker.yml b/.github/workflows/CI-unixish-docker.yml index e254c1e986f..083bb7b7651 100644 --- a/.github/workflows/CI-unixish-docker.yml +++ b/.github/workflows/CI-unixish-docker.yml @@ -57,7 +57,7 @@ jobs: - name: Run CMake run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: CMake build (with GUI) run: | diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index fabe0832f4b..8f355644bc2 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -58,13 +58,13 @@ jobs: - name: CMake build on ubuntu (with GUI / system tinyxml2) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output.tinyxml2 -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output.tinyxml2 -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: CMake build on macos (with GUI / system tinyxml2) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output.tinyxml2 -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output.tinyxml2 -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: Run CMake test (system tinyxml2) @@ -127,12 +127,12 @@ jobs: - name: Run CMake on ubuntu (with GUI) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install + cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install - name: Run CMake on macos (with GUI) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 - name: Run CMake build run: | @@ -154,13 +154,13 @@ jobs: - name: Run CMake on ubuntu (no CLI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off + cmake -S . -B cmake.output_nocli -Werror=dev -DBUILD_TESTING=Off -DBUILD_CLI=Off - name: Run CMake on ubuntu (no CLI / with tests) if: matrix.os == 'ubuntu-22.04' run: | # the test and CLI code are too intertwined so for now we need to reject that - if cmake -S . -B cmake.output_nocli_tests -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DBUILD_CLI=Off; then + if cmake -S . -B cmake.output_nocli_tests -Werror=dev -DBUILD_TESTING=On -DBUILD_CLI=Off; then exit 1 else exit 0 @@ -169,18 +169,18 @@ jobs: - name: Run CMake on ubuntu (no CLI / with GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli_gui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=On + cmake -S . -B cmake.output_nocli_gui -Werror=dev -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=On - name: Run CMake on ubuntu (no GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nogui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off + cmake -S . -B cmake.output_nogui -Werror=dev -DBUILD_TESTING=Off -DBUILD_GUI=Off - name: Run CMake on ubuntu (no GUI / with triage) if: matrix.os == 'ubuntu-22.04' run: | # cannot build triage without GUI - if cmake -S . -B cmake.output_nogui_triage -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then + if cmake -S . -B cmake.output_nogui_triage -Werror=dev -DBUILD_TESTING=Off -DBUILD_GUI=Off -DBUILD_TRIAGE=On; then exit 1 else exit 0 @@ -189,7 +189,7 @@ jobs: - name: Run CMake on ubuntu (no CLI / no GUI) if: matrix.os == 'ubuntu-22.04' run: | - cmake -S . -B cmake.output_nocli_nogui -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DBUILD_GUI=Off + cmake -S . -B cmake.output_nocli_nogui -Werror=dev -DBUILD_TESTING=Off -DBUILD_GUI=Off build_cmake_cxxstd: @@ -243,12 +243,12 @@ jobs: - name: Run CMake on ubuntu (with GUI) if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output -Werror=dev -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Run CMake on macos (with GUI) if: contains(matrix.os, 'macos') run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 + cmake -S . -B cmake.output -Werror=dev -DCMAKE_CXX_STANDARD=${{ matrix.cxxstd }} -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 - name: Run CMake build run: | @@ -373,7 +373,7 @@ jobs: run: | # make sure we fail when Boost is requested and not available. # will fail because no package configuration is available. - if cmake -S . -B cmake.output.boost-force-noavail -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On; then + if cmake -S . -B cmake.output.boost-force-noavail -Werror=dev -DBUILD_TESTING=Off -DUSE_BOOST=On; then exit 1 else exit 0 @@ -386,12 +386,12 @@ jobs: - name: Run CMake on macOS (force Boost) run: | - cmake -S . -B cmake.output.boost-force -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=On + cmake -S . -B cmake.output.boost-force -Werror=dev -DBUILD_TESTING=Off -DUSE_BOOST=On - name: Run CMake on macOS (no Boost) run: | # make sure Boost is not used when disabled even though it is available - cmake -S . -B cmake.output.boost-no -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=Off -DUSE_BOOST=Off + cmake -S . -B cmake.output.boost-no -Werror=dev -DBUILD_TESTING=Off -DUSE_BOOST=Off if grep -q '\-DHAVE_BOOST' ./cmake.output.boost-no/compile_commands.json; then exit 1 else @@ -400,7 +400,7 @@ jobs: - name: Run CMake on macOS (with Boost) run: | - cmake -S . -B cmake.output.boost -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output.boost -Werror=dev -DBUILD_TESTING=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache grep -q '\-DHAVE_BOOST' ./cmake.output.boost/compile_commands.json - name: Build with CMake on macOS (with Boost) @@ -436,12 +436,12 @@ jobs: - name: Run CMake (without GUI) run: | export PATH=cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64/bin:$PATH - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On + cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On - name: Run CMake (with GUI) run: | export PATH=cmake-${{ env.CMAKE_VERSION_FULL }}-linux-x86_64/bin:$PATH - cmake -S . -B cmake.output.gui -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On + cmake -S . -B cmake.output.gui -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On build: @@ -596,7 +596,7 @@ jobs: - name: Test Signalhandler run: | - cmake -S . -B build.cmake.signal -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On + cmake -S . -B build.cmake.signal -Werror=dev -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On cmake --build build.cmake.signal --target test-signalhandler -- -j$(nproc) # TODO: how to run this without copying the file? cp build.cmake.signal/bin/test-s* . @@ -607,7 +607,7 @@ jobs: - name: Test Stacktrace if: contains(matrix.os, 'ubuntu') run: | - cmake -S . -B build.cmake.stack -Werror=dev -G "Unix Makefiles" -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On + cmake -S . -B build.cmake.stack -Werror=dev -DBUILD_TESTING=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On cmake --build build.cmake.stack --target test-stacktrace -- -j$(nproc) # TODO: how to run this without copying the file? cp build.cmake.stack/bin/test-s* . diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 540e5770382..c4f8cc0cf6b 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -61,7 +61,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -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 + 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-22 CXX: clang++-22 diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 9ac43313671..fa9be0cbba8 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -128,7 +128,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -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.stdlib == 'libc++' }} + 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.stdlib == 'libc++' }} env: CC: clang CXX: clang++ @@ -236,7 +236,7 @@ jobs: - name: Prepare CMake run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -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 }} + 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-22 CXX: clang++-22 diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index aa5b61d859b..ec52b15f939 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -64,7 +64,7 @@ jobs: # unusedFunction - start - name: CMake run: | - cmake -S . -B cmake.output -Werror=dev -G "Unix Makefiles" -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 + 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 - name: Generate dependencies run: | @@ -90,7 +90,7 @@ jobs: # unusedFunction notest - start - name: CMake (no test) run: | - cmake -S . -B cmake.output.notest -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_GUI=ON -DBUILD_TRIAGE=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_GUI=ON -DBUILD_TRIAGE=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test) run: | @@ -112,7 +112,7 @@ jobs: # unusedFunction notest nogui - start - name: CMake (no test / no gui) run: | - cmake -S . -B cmake.output.notest_nogui -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest_nogui -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test / no gui) run: | @@ -131,7 +131,7 @@ jobs: # unusedFunction notest nocli - start - name: CMake (no test / no cli) run: | - cmake -S . -B cmake.output.notest_nocli -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -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 + cmake -S . -B cmake.output.notest_nocli -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -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 - name: Generate dependencies (no test / no cli) run: | @@ -154,7 +154,7 @@ jobs: # unusedFunction notest nocli nogui - start - name: CMake (no test / no cli / no gui) run: | - cmake -S . -B cmake.output.notest_nocli_nogui -Werror=dev -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off + cmake -S . -B cmake.output.notest_nocli_nogui -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_CLI=Off -DBUILD_GUI=Off -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off - name: Generate dependencies (no test / no cli / no gui) run: | @@ -177,7 +177,7 @@ jobs: - name: CMake (corpus / no test) run: | - cmake -S cppcheck-2.8 -B cmake.output.corpus -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_GUI=ON -DUSE_QT6=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + cmake -S cppcheck-2.8 -B cmake.output.corpus -DHAVE_RULES=On -DBUILD_TESTING=Off -DBUILD_GUI=ON -DUSE_QT6=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 - name: Generate dependencies (corpus) run: | From 0c3d74f449a4ccf2ff89aa616513cedaceea892a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 2 Mar 2026 20:17:23 +0100 Subject: [PATCH 206/675] daca@home: update OLD_VERSION and SERVER_VERSION [skip ci] (#8294) --- tools/donate-cpu-server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index d8afaba2be3..6f44ea679a7 100755 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -26,10 +26,10 @@ # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # changes) -SERVER_VERSION = "1.3.67" +SERVER_VERSION = "1.3.68" # TODO: fetch from GitHub tags -OLD_VERSION = '2.19.0' +OLD_VERSION = '2.20.0' HEAD_MARKER = 'head results:' INFO_MARKER = 'info messages:' From da110ba0b12cf20fcf712865c2f4686ceca02c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 3 Mar 2026 15:59:56 +0100 Subject: [PATCH 207/675] bumped version to 2.20.99/2.21 (#8293) --- CMakeLists.txt | 2 +- cli/main.cpp | 2 +- lib/version.h | 4 ++-- man/manual.md | 2 +- man/reference-cfg-format.md | 2 +- man/writing-addons.md | 2 +- win_installer/productInfo.wxi | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e41d81029ae..b32fc90811b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.22) -project(Cppcheck VERSION 2.18.99 LANGUAGES CXX) +project(Cppcheck VERSION 2.20.99 LANGUAGES CXX) include(cmake/options.cmake) diff --git a/cli/main.cpp b/cli/main.cpp index 1c39ab14544..9bea4336c84 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -20,7 +20,7 @@ /** * * @mainpage Cppcheck - * @version 2.18.99 + * @version 2.20.99 * * @section overview_sec Overview * Cppcheck is a simple tool for static analysis of C/C++ code. diff --git a/lib/version.h b/lib/version.h index 4828a568104..2a64885ffa8 100644 --- a/lib/version.h +++ b/lib/version.h @@ -20,8 +20,8 @@ #ifndef versionH #define versionH -#define CPPCHECK_VERSION_STRING "2.19 dev" -#define CPPCHECK_VERSION 2,18,99,0 +#define CPPCHECK_VERSION_STRING "2.21 dev" +#define CPPCHECK_VERSION 2,20,99,0 #define LEGALCOPYRIGHT L"Copyright (C) 2007-2026 Cppcheck team." diff --git a/man/manual.md b/man/manual.md index 1a4e4002f10..dc07026dc2b 100644 --- a/man/manual.md +++ b/man/manual.md @@ -1,6 +1,6 @@ --- title: Cppcheck manual -subtitle: Version 2.19 dev +subtitle: Version 2.21 dev author: Cppcheck team lang: en documentclass: report diff --git a/man/reference-cfg-format.md b/man/reference-cfg-format.md index 7a9e3b6dee7..3067d0a8f2c 100644 --- a/man/reference-cfg-format.md +++ b/man/reference-cfg-format.md @@ -1,6 +1,6 @@ --- title: Cppcheck .cfg format -subtitle: Version 2.19 dev +subtitle: Version 2.21 dev author: Cppcheck team lang: en documentclass: report diff --git a/man/writing-addons.md b/man/writing-addons.md index da21ea513ad..e593c2e9cce 100644 --- a/man/writing-addons.md +++ b/man/writing-addons.md @@ -1,6 +1,6 @@ --- title: Writing addons -subtitle: Version 2.19 dev +subtitle: Version 2.21 dev author: Cppcheck team lang: en documentclass: report diff --git a/win_installer/productInfo.wxi b/win_installer/productInfo.wxi index d07ce1136c9..f89e956dbb8 100644 --- a/win_installer/productInfo.wxi +++ b/win_installer/productInfo.wxi @@ -1,8 +1,8 @@ - + - + From 0e0f9de835b394532edb2f54e4af84ee9b144cd8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 4 Mar 2026 12:39:34 +0100 Subject: [PATCH 208/675] Refs #13771, #13776: No AST for function declarations (#8222) Co-authored-by: chrchr-github --- lib/symboldatabase.cpp | 2 +- lib/tokenlist.cpp | 7 ++++--- test/testtokenize.cpp | 31 +++++++++++++++++++++++-------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 4dc75ba8c1f..3bde7a71e19 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -713,7 +713,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() } // function prototype? else if (declEnd && declEnd->str() == ";") { - if (tok->astParent() && tok->astParent()->str() == "::" && + if ((Token::simpleMatch(tok->tokAt(-1), "::") || (tok->tokAt(-1) && Token::simpleMatch(tok->tokAt(-2), ":: ~"))) && Token::Match(declEnd->previous(), "default|delete")) { addClassFunction(scope, tok, argStart); continue; diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index d5b48ceab22..0ffcf7e37e4 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1787,8 +1787,9 @@ static Token * createAstAtToken(Token *tok) } } - if (Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) { - int typecount = 0; + if ((Token::Match(tok, "%type% %name%|*|&|&&|::") && !Token::Match(tok, "return|new|delete")) || + (Token::Match(tok, ":: %type%") && !tok->next()->isKeyword())) { + int typecount = tok->str() == "::" ? 1 : 0; Token *typetok = tok; while (Token::Match(typetok, "%type%|::|*|&|&&|<")) { if (typetok->isName() && !Token::simpleMatch(typetok->previous(), "::")) @@ -1811,7 +1812,7 @@ static Token * createAstAtToken(Token *tok) !Token::Match(tok, "return|throw") && Token::Match(typetok->previous(), "%name% ( !!*") && typetok->previous()->varId() == 0 && - !typetok->previous()->isKeyword() && + (!typetok->previous()->isKeyword() || typetok->previous()->isOperatorKeyword()) && (skipMethodDeclEnding(typetok->link()) || Token::Match(typetok->link(), ") ;|{"))) return typetok; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index a698a3c20bf..e59f7b3be62 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -427,6 +427,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(astorkeyword); TEST_CASE(astenumdecl); TEST_CASE(astcompound); + TEST_CASE(astfuncdecl); TEST_CASE(startOfExecutableScope); @@ -6415,8 +6416,13 @@ class TestTokenizer : public TestFixture { Z3 }; + enum class ListSimplification : std::uint8_t { + Partial, + Full + }; + template - std::string testAst(const char (&data)[size], AstStyle style = AstStyle::Simple) { + std::string testAst(const char (&data)[size], AstStyle style = AstStyle::Simple, ListSimplification ls = ListSimplification::Partial) { // tokenize given code.. TokenList tokenlist{settings0, Standards::Language::CPP}; tokenlist.appendFileIfNew("test.cpp"); @@ -6424,13 +6430,17 @@ class TestTokenizer : public TestFixture { return "ERROR"; TokenizerTest tokenizer(std::move(tokenlist), *this); - tokenizer.combineStringAndCharLiterals(); - tokenizer.combineOperators(); - tokenizer.simplifySpaceshipOperator(); - tokenizer.createLinks(); - tokenizer.createLinks2(); - tokenizer.simplifyCAlternativeTokens(); - tokenizer.list.front()->assignIndexes(); + if (ls == ListSimplification::Partial) { + tokenizer.combineStringAndCharLiterals(); + tokenizer.combineOperators(); + tokenizer.simplifySpaceshipOperator(); + tokenizer.createLinks(); + tokenizer.createLinks2(); + tokenizer.simplifyCAlternativeTokens(); + tokenizer.list.front()->assignIndexes(); + } else { // Full + tokenizer.simplifyTokens1(""); + } // set varid.. for (Token *tok = tokenizer.list.front(); tok; tok = tok->next()) { @@ -7428,6 +7438,11 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("s(sstrlens(0:?,{(return", testAst("return (struct Str) { (unsigned char*)s, s ? strlen(s) : 0 };")); } + void astfuncdecl() { + ASSERT_EQUALS("", testAst("bool operator==(const S& a, const S& b);", AstStyle::Simple, ListSimplification::Full)); + ASSERT_EQUALS("", testAst("::int32_t f();")); + } + #define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__) template bool isStartOfExecutableScope_(int offset, const char (&code)[size], const char* file, int line) { From 2dac535684fd2c05d39905e7ed113e69787601c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 4 Mar 2026 13:38:17 +0100 Subject: [PATCH 209/675] Fix #14478: FN autoVariables for array of structs (#8247) --- lib/checkautovariables.cpp | 12 +++++++++--- test/testautovariables.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index d867930f517..387e3fd3c2d 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -265,11 +265,17 @@ static bool hasOverloadedAssignment(const Token* tok, bool& inconclusive) static bool isMemberAssignment(const Token* tok, const Token*& rhs, const Settings& settings) { - if (!Token::Match(tok, "[;{}] %var% . %var%")) - return false; + const Token *endBracket = nullptr; + if (!Token::Match(tok, "[;{}] %var% . %var%")) { + if (!Token::Match(tok, "[;{}] %var% [")) + return false; + endBracket = tok->linkAt(2); + if (!Token::Match(endBracket, "] . %var%")) + return false; + } if (!isPtrArg(tok->next())) return false; - const Token* assign = tok->tokAt(2)->astParent(); + const Token* assign = (endBracket ? endBracket->next() : tok->tokAt(2))->astParent(); while (Token::simpleMatch(assign, "[")) assign = assign->astParent(); if (!Token::simpleMatch(assign, "=")) diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 560220f8c9e..bcdba7ca0dc 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -69,6 +69,7 @@ class TestAutoVariables : public TestFixture { TEST_CASE(testautovar15); // ticket #6538 TEST_CASE(testautovar16); // ticket #8114 TEST_CASE(testautovar17); + TEST_CASE(testautovar18); TEST_CASE(testautovar_array1); TEST_CASE(testautovar_array2); TEST_CASE(testautovar_array3); @@ -516,6 +517,15 @@ class TestAutoVariables : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void testautovar18() { + check("struct S { int* p; };\n" + "void foo(struct S* s) {\n" + " int x;\n" + " s[2].p = &x;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n", errout_str()); + } + void testautovar_array1() { check("void func1(int* arr[2])\n" "{\n" From 6a14618aa9a418bebe7b9a2d32a0cbf739099f8d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 9 Mar 2026 21:04:50 +0100 Subject: [PATCH 210/675] Workaround for broken apt.llvm.org repo (revert to clang 21) (#8312) Co-authored-by: chrchr-github --- .clang-tidy | 7 ++----- .github/workflows/asan.yml | 6 +++--- .github/workflows/clang-tidy.yml | 10 +++++----- .github/workflows/tsan.yml | 6 +++--- .github/workflows/ubsan.yml | 6 +++--- cmake/clang_tidy.cmake | 3 --- 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 8c30f2c602b..91173d82e10 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -23,14 +23,12 @@ 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, @@ -39,6 +37,7 @@ 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, @@ -70,7 +69,7 @@ Checks: > -readability-implicit-bool-conversion, -readability-isolate-declaration, -readability-magic-numbers, - -readability-redundant-parentheses, + -readability-math-missing-parentheses, -readability-suspicious-call-argument, -readability-uppercase-literal-suffix, -readability-use-concise-preprocessor-directives, @@ -85,5 +84,3 @@ CheckOptions: value: '0' - key: modernize-use-trailing-return-type.TransformFunctions value: false - - key: misc-override-with-different-visibility.DisallowedVisibilityChange - value: widening diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 38e90cb760a..977d3f05337 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -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 22 + sudo ./llvm.sh 21 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -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-22 - CXX: clang++-22 + CC: clang-21 + CXX: clang++-21 - name: Build cppcheck run: | diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index c4f8cc0cf6b..00a4ee7d332 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -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 22 - sudo apt-get install -y clang-tidy-22 + sudo ./llvm.sh 21 + sudo apt-get install -y clang-tidy-21 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -57,14 +57,14 @@ jobs: - name: Verify clang-tidy configuration run: | - clang-tidy-22 --verify-config + clang-tidy-21 --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-22 - CXX: clang++-22 + CC: clang-21 + CXX: clang++-21 - name: Prepare CMake dependencies run: | diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml index 72b1764d11d..0e78566faae 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 22 + sudo ./llvm.sh 21 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -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-22 - CXX: clang++-22 + CC: clang-21 + CXX: clang++-21 - name: Build cppcheck run: | diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index 5afc5feb1f9..66c56b6966a 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 22 + sudo ./llvm.sh 21 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -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-22 - CXX: clang++-22 + CC: clang-21 + CXX: clang++-21 - name: Build cppcheck run: | diff --git a/cmake/clang_tidy.cmake b/cmake/clang_tidy.cmake index fe0efbbe32f..486c560f1f5 100644 --- a/cmake/clang_tidy.cmake +++ b/cmake/clang_tidy.cmake @@ -25,9 +25,6 @@ if(RUN_CLANG_TIDY_NAMES) endif() message(STATUS "NPROC=${NPROC}") - # TODO: introduced in run-clang-tidy-22 - set(CLANG_TIDY_CONFIG "-enable-check-profile") - # most of these are disabled because they are too noisy in our code # clang-analyzer-core.CallAndMessage # clang-analyzer-core.NonNullParamChecker From 3744a3ab598db5b1cf07fb7e4a5188d142cc97ff Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:54:38 +0100 Subject: [PATCH 211/675] Fix #14578 using-declarations not simplified with --std=c++03 (#8308) Co-authored-by: chrchr-github --- lib/tokenize.cpp | 2 +- test/testsimplifyusing.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 984269d07e8..193fa5bbb4d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2890,7 +2890,7 @@ static const Token* skipConstVolatileBackwards(const Token* tok) { bool Tokenizer::simplifyUsing() { - if (!isCPP() || mSettings.standards.cpp < Standards::CPP11) + if (!isCPP()) return false; // simplify using N::x; to using x = N::x; diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 8eba2142913..58af4c972bc 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -75,6 +75,7 @@ class TestSimplifyUsing : public TestFixture { TEST_CASE(simplifyUsing36); TEST_CASE(simplifyUsing37); TEST_CASE(simplifyUsing38); + TEST_CASE(simplifyUsing39); TEST_CASE(simplifyUsing8970); TEST_CASE(simplifyUsing8971); @@ -106,12 +107,14 @@ class TestSimplifyUsing : public TestFixture { Platform::Type type = Platform::Type::Native; bool debugwarnings = true; bool preprocess = false; + Standards::cppstd_t cppstd = Standards::CPPLatest; }; #define tok(...) tok_(__FILE__, __LINE__, __VA_ARGS__) template std::string tok_(const char* file, int line, const char (&code)[size], const TokOptions& options = make_default_obj()) { - const Settings settings = settingsBuilder(settings0).certainty(Certainty::inconclusive).debugwarnings(options.debugwarnings).platform(options.type).build(); + const Settings settings = settingsBuilder(settings0).certainty(Certainty::inconclusive).debugwarnings(options.debugwarnings) + .platform(options.type).cpp(options.cppstd).build(); if (options.preprocess) { SimpleTokenizer2 tokenizer(settings, *this, code, "test.cpp"); @@ -925,6 +928,16 @@ class TestSimplifyUsing : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void simplifyUsing39() { + const char code[] = "using std::wstring;\n" // #14578 + "std::wstring ws;"; + const char expected[] = "std :: wstring ws ;"; + ASSERT_EQUALS(expected, tok(code)); + ASSERT_EQUALS("", errout_str()); + ASSERT_EQUALS(expected, tok(code, dinit(TokOptions, $.cppstd = Standards::CPP03))); + ASSERT_EQUALS("", errout_str()); + } + void simplifyUsing8970() { const char code[] = "using V = std::vector;\n" "struct A {\n" From 26f128783bab394be540baaa7f8931fa686fd25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Tue, 10 Mar 2026 00:20:50 +0100 Subject: [PATCH 212/675] [gui] Prevent detaching from Q containers in range-based for loop (#8311) Use utils::as_const Found by Clazy (range-loop-detach). --- gui/checkthread.cpp | 4 ++-- gui/codeeditor.cpp | 5 +++-- gui/compliancereportdialog.cpp | 3 ++- gui/helpdialog.cpp | 3 ++- gui/librarydialog.cpp | 4 ++-- gui/projectfile.cpp | 12 ++++++------ gui/projectfiledialog.cpp | 2 +- gui/resultsview.cpp | 2 +- gui/threaddetails.cpp | 4 +++- gui/threadhandler.cpp | 5 +++-- 10 files changed, 25 insertions(+), 19 deletions(-) diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index 81471638e62..fa5d68ba6d6 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -190,7 +190,7 @@ void CheckThread::run() void CheckThread::runAddonsAndTools(const Settings& settings, const FileSettings *fileSettings, const QString &fileName) { - for (const QString& addon : mAddonsAndTools) { + for (const QString& addon : utils::as_const(mAddonsAndTools)) { if (addon == CLANG_ANALYZER || addon == CLANG_TIDY) { if (!fileSettings) continue; @@ -303,7 +303,7 @@ void CheckThread::runAddonsAndTools(const Settings& settings, const FileSettings { const QString cmd(clangTidyCmd()); QString debug(cmd.contains(" ") ? ('\"' + cmd + '\"') : cmd); - for (const QString& arg : args) { + for (const QString& arg : utils::as_const(args)) { if (arg.contains(" ")) debug += " \"" + arg + '\"'; else diff --git a/gui/codeeditor.cpp b/gui/codeeditor.cpp index 98886716556..d6c8c1c4071 100644 --- a/gui/codeeditor.cpp +++ b/gui/codeeditor.cpp @@ -19,6 +19,7 @@ #include "codeeditor.h" #include "codeeditorstyle.h" +#include "utils.h" #include #include @@ -133,7 +134,7 @@ Highlighter::Highlighter(QTextDocument *parent, << "volatile" << "wchar_t" << "while"; - for (const QString &pattern : keywordPatterns) { + for (const QString &pattern : utils::as_const(keywordPatterns)) { rule.pattern = QRegularExpression("\\b" + pattern + "\\b"); rule.format = mKeywordFormat; rule.ruleRole = RuleRole::Keyword; @@ -216,7 +217,7 @@ void Highlighter::setStyle(const CodeEditorStyle &newStyle) void Highlighter::highlightBlock(const QString &text) { - for (const HighlightingRule &rule : mHighlightingRulesWithSymbols) { + for (const HighlightingRule &rule : utils::as_const(mHighlightingRulesWithSymbols)) { QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text); while (matchIterator.hasNext()) { QRegularExpressionMatch match = matchIterator.next(); diff --git a/gui/compliancereportdialog.cpp b/gui/compliancereportdialog.cpp index ae903f47dc4..c61299e6e3c 100644 --- a/gui/compliancereportdialog.cpp +++ b/gui/compliancereportdialog.cpp @@ -25,6 +25,7 @@ #include "filesettings.h" #include "importproject.h" #include "projectfile.h" +#include "utils.h" #include #include @@ -191,7 +192,7 @@ void ComplianceReportDialog::save() QSet allFiles; for (const QString &sourcefile: fileList.getFileList()) addHeaders(sourcefile, allFiles); - for (const QString& fileName: allFiles) { + for (const QString& fileName: utils::as_const(allFiles)) { QFile f(fileName); if (f.open(QFile::ReadOnly)) { QCryptographicHash hash(QCryptographicHash::Algorithm::Md5); diff --git a/gui/helpdialog.cpp b/gui/helpdialog.cpp index db1125339b9..0768318531c 100644 --- a/gui/helpdialog.cpp +++ b/gui/helpdialog.cpp @@ -19,6 +19,7 @@ #include "helpdialog.h" #include "common.h" +#include "utils.h" #include "ui_helpdialog.h" @@ -65,7 +66,7 @@ static QString getHelpFile() paths << (filesdir + "/help") << filesdir; #endif - for (const QString &p: paths) { + for (const QString &p: utils::as_const(paths)) { QString filename = p + "/online-help.qhc"; if (QFileInfo::exists(filename)) return filename; diff --git a/gui/librarydialog.cpp b/gui/librarydialog.cpp index 15572813c81..f38b64bdedc 100644 --- a/gui/librarydialog.cpp +++ b/gui/librarydialog.cpp @@ -292,11 +292,11 @@ void LibraryDialog::filterFunctions(const QString& filter) QList allItems = mUi->functions->findItems(QString(), Qt::MatchContains); if (filter.isEmpty()) { - for (QListWidgetItem *item : allItems) { + for (QListWidgetItem *item : utils::as_const(allItems)) { item->setHidden(false); } } else { - for (QListWidgetItem *item : allItems) { + for (QListWidgetItem *item : utils::as_const(allItems)) { item->setHidden(!item->text().startsWith(filter)); } } diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index 9001b6ad604..b807723ceeb 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -892,7 +892,7 @@ bool ProjectFile::write(const QString &filename) if (!mIncludeDirs.isEmpty()) { xmlWriter.writeStartElement(CppcheckXml::IncludeDirElementName); - for (const QString& incdir : mIncludeDirs) { + for (const QString& incdir : utils::as_const(mIncludeDirs)) { xmlWriter.writeStartElement(CppcheckXml::DirElementName); xmlWriter.writeAttribute(CppcheckXml::DirNameAttrib, incdir); xmlWriter.writeEndElement(); @@ -902,7 +902,7 @@ bool ProjectFile::write(const QString &filename) if (!mDefines.isEmpty()) { xmlWriter.writeStartElement(CppcheckXml::DefinesElementName); - for (const QString& define : mDefines) { + for (const QString& define : utils::as_const(mDefines)) { xmlWriter.writeStartElement(CppcheckXml::DefineName); xmlWriter.writeAttribute(CppcheckXml::DefineNameAttrib, define); xmlWriter.writeEndElement(); @@ -924,7 +924,7 @@ bool ProjectFile::write(const QString &filename) if (!mPaths.isEmpty()) { xmlWriter.writeStartElement(CppcheckXml::PathsElementName); - for (const QString& path : mPaths) { + for (const QString& path : utils::as_const(mPaths)) { xmlWriter.writeStartElement(CppcheckXml::PathName); xmlWriter.writeAttribute(CppcheckXml::PathNameAttrib, path); xmlWriter.writeEndElement(); @@ -934,7 +934,7 @@ bool ProjectFile::write(const QString &filename) if (!mExcludedPaths.isEmpty()) { xmlWriter.writeStartElement(CppcheckXml::ExcludeElementName); - for (const QString& path : mExcludedPaths) { + for (const QString& path : utils::as_const(mExcludedPaths)) { xmlWriter.writeStartElement(CppcheckXml::ExcludePathName); xmlWriter.writeAttribute(CppcheckXml::ExcludePathNameAttrib, path); xmlWriter.writeEndElement(); @@ -949,7 +949,7 @@ bool ProjectFile::write(const QString &filename) if (!mSuppressions.isEmpty()) { xmlWriter.writeStartElement(CppcheckXml::SuppressionsElementName); - for (const SuppressionList::Suppression &suppression : mSuppressions) { + for (const SuppressionList::Suppression &suppression : utils::as_const(mSuppressions)) { xmlWriter.writeStartElement(CppcheckXml::SuppressionElementName); if (!suppression.fileName.empty()) xmlWriter.writeAttribute("fileName", QString::fromStdString(suppression.fileName)); @@ -1169,7 +1169,7 @@ QString ProjectFile::getAddonFilePath(QString filesDir, const QString &addon) #endif ; - for (const QString& path : searchPaths) { + for (const QString& path : utils::as_const(searchPaths)) { QString f = path + addon + ".py"; if (QFile(f).exists()) return f; diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index d1ddfc13200..21618dbb017 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -194,7 +194,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi } libs.sort(); mUI->mLibraries->clear(); - for (const QString &lib : libs) { + for (const QString &lib : utils::as_const(libs)) { auto* item = new QListWidgetItem(lib, mUI->mLibraries); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag item->setCheckState(Qt::Unchecked); // AND initialize check state diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 8183214bb27..c6c54a2fd85 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -423,7 +423,7 @@ void ResultsView::readErrorsXml(const QString &filename) msgBox.exec(); } - for (const ErrorItem& item : errors) { + for (const ErrorItem& item : utils::as_const(errors)) { handleCriticalError(item); mUI->mTree->addErrorItem(item); } diff --git a/gui/threaddetails.cpp b/gui/threaddetails.cpp index 9036c18305d..1fcb97772ef 100644 --- a/gui/threaddetails.cpp +++ b/gui/threaddetails.cpp @@ -1,4 +1,6 @@ #include "threaddetails.h" +#include "utils.h" + #include "ui_threaddetails.h" #include @@ -43,7 +45,7 @@ void ThreadDetails::updateUI() { QString text("Thread\tStart time\tFile/Progress\n"); { QMutexLocker locker(&mMutex); - for (const auto& td: mThreadDetails) { + for (const auto& td: utils::as_const(mThreadDetails)) { auto& timeProgress = mProgress[td.file]; if (timeProgress.first.isEmpty() && !timeProgress.second.isEmpty()) timeProgress.first = QTime::currentTime().toString(Qt::TextDate); diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index 74735a9b666..3f89d58b558 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -23,6 +23,7 @@ #include "filesettings.h" #include "resultsview.h" #include "settings.h" +#include "utils.h" #include #include @@ -161,7 +162,7 @@ void ThreadHandler::createThreads(const int count) void ThreadHandler::removeThreads() { - for (CheckThread* thread : mThreads) { + for (CheckThread* thread : utils::as_const(mThreads)) { if (thread->isRunning()) { thread->stop(); thread->wait(); @@ -216,7 +217,7 @@ void ThreadHandler::stop() mCheckStartTime = QDateTime(); mAnalyseWholeProgram = false; mCtuInfo.clear(); - for (CheckThread* thread : mThreads) { + for (CheckThread* thread : utils::as_const(mThreads)) { thread->stop(); } } From 5aa8739595cabcbbefc31884968bc3a1031f2418 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 10 Mar 2026 08:50:15 +0100 Subject: [PATCH 213/675] Fix #14566 FP variableScope (variable used in loop) (#8296) --- lib/checkother.cpp | 2 +- test/testother.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 32dedf8f374..bbc6bdb90d0 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1337,7 +1337,7 @@ static bool isOnlyUsedInCurrentScope(const Variable* var, const Token *tok, cons return true; if (tok->scope()->type == ScopeType::eSwitch) return false; - return !Token::findmatch(tok->scope()->bodyEnd, "%varid%", scope->bodyEnd, var->declarationId()); + return !Token::findmatch(tok->scope()->bodyEnd, "%varid%", var->scope()->bodyEnd, var->declarationId()); } bool CheckOther::checkInnerScope(const Token *tok, const Variable* var, bool& used) const diff --git a/test/testother.cpp b/test/testother.cpp index 53f14c2a31d..88c83eba4b1 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2026,6 +2026,20 @@ class TestOther : public TestFixture { " }\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void f(int& r) {\n" // #14566 + " int i = 0;\n" + " while (g()) {\n" + " {\n" + " if (g()) {\n" + " i = 0;" + " std::swap(i, r);\n" + " }\n" + " }\n" + " }\n" + " use(i);" + "}\n"); + ASSERT_EQUALS("", errout_str()); } #define checkOldStylePointerCast(...) checkOldStylePointerCast_(__FILE__, __LINE__, __VA_ARGS__) From 13f7e534f2cdac37abdcc4be2a2105187980d9ea Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 10 Mar 2026 11:18:54 +0100 Subject: [PATCH 214/675] Fix test for #14578 (#8317) --- test/testsimplifyusing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 58af4c972bc..8e27bdc12d4 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -930,7 +930,7 @@ class TestSimplifyUsing : public TestFixture { void simplifyUsing39() { const char code[] = "using std::wstring;\n" // #14578 - "std::wstring ws;"; + "wstring ws;"; const char expected[] = "std :: wstring ws ;"; ASSERT_EQUALS(expected, tok(code)); ASSERT_EQUALS("", errout_str()); From c364e626bac4056e52b0103f28df46657bfb400d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 11 Mar 2026 08:41:49 +0100 Subject: [PATCH 215/675] Fix #14575 FN constVariablePointer with std::wstring (#8301) --- cfg/std.cfg | 17 +++++++++++++++++ test/cfg/std.cpp | 16 +++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index 6cd0c371a5e..70e9cc17746 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -7130,6 +7130,16 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun false + + + + + + + + + false + @@ -7137,6 +7147,13 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun false + + + + + + false + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 8a9976a94ae..7e406ca2187 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -5166,6 +5166,20 @@ void constVariablePointer_push_back(std::vector& d, const std::vector& s } } +struct S_constVariablePointer_wstring { // #14575 + std::wstring m; + const std::wstring& get() const { return m; } +}; + +S_constVariablePointer_wstring* g_constVariablePointer_wstring(); + +void h_constVariablePointer_wstring(const wchar_t*); + +void f_constVariablePointer_wstring() { + S_constVariablePointer_wstring* s = g_constVariablePointer_wstring(); // cppcheck-suppress constVariablePointer + h_constVariablePointer_wstring(s->get().c_str()); +} + std::streampos constParameterPointer_istream_tellg(std::istream* p) { // #13801 return p->tellg(); } @@ -5318,4 +5332,4 @@ int containerOutOfBounds_std_initializer_list() { // #14340 // cppcheck-suppress derefInvalidIterator int i = *x.end(); return i + containerOutOfBounds_std_initializer_list_access(x); -} \ No newline at end of file +} From 929f95cb0b286b734144f66c61735b674ce88a1a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 11 Mar 2026 09:21:51 +0100 Subject: [PATCH 216/675] Fix #13509 information: --check-library: There is no matching configuration for function T::cbegin() (#8319) --- lib/checkfunctions.cpp | 6 ++++++ test/testfunctions.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 3d6ff2ce755..f6799d199e7 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -635,6 +635,12 @@ void CheckFunctions::checkLibraryMatchFunctions() if (!tok->scope() || !tok->scope()->isExecutable()) continue; + // skip uninstantiated templates + if (tok == tok->scope()->bodyStart && tok->scope()->function && tok->scope()->function->templateDef) { + tok = tok->link(); + continue; + } + if (tok->str() == "new") insideNew = true; else if (tok->str() == ";") diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 48516faf852..feb7f2a666f 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -2220,6 +2220,12 @@ class TestFunctions : public TestFixture { " return b;\n" "}\n", s); TODO_ASSERT_EQUALS("", "[test.cpp:6:5]: (debug) auto token with no type. [autoNoType]\n", errout_str()); + + check("template \n" // #13509 + "void f(const T& t) {\n" + " t.g();\n" + "}\n", s); + ASSERT_EQUALS("", errout_str()); } void checkUseStandardLibrary1() { From 04af809b2d65f1fc0c6387e594646d9d8a6accfa Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Wed, 11 Mar 2026 11:13:42 +0100 Subject: [PATCH 217/675] Fix #13685 FP uninitvar with nested compound statement scopes (#8300) PR #6714 introduced a regression in which variables initialized in nested compound statements are incorrectly flagged as uninitialized by uninitvar. Such scopes could be present due to usage of GNU compound statements. --- lib/symboldatabase.cpp | 14 +++++++++----- test/testsymboldatabase.cpp | 19 +++++++++++++++++++ test/testuninitvar.cpp | 12 ++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 3bde7a71e19..9748959ba53 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -160,6 +160,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() }; std::stack inIfCondition; + std::stack pendingIfScopes; auto addLambda = [this, &scope](const Token* tok, const Token* lambdaEndToken) -> const Token* { const Token* lambdaStartToken = lambdaEndToken->link(); @@ -766,13 +767,14 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() scopeList.emplace_back(*this, tok, scope, ScopeType::eSwitch, scopeStartTok); scope->nestedList.push_back(&scopeList.back()); - scope = &scopeList.back(); - if (scope->type == ScopeType::eFor) - scope->checkVariable(tok->tokAt(2), AccessControl::Local); // check for variable declaration and add it to new scope if found - else if (scope->type == ScopeType::eCatch) - scope->checkVariable(tok->tokAt(2), AccessControl::Throw); // check for variable declaration and add it to new scope if found + Scope* newScope = &scopeList.back(); + if (newScope->type == ScopeType::eFor) + newScope->checkVariable(tok->tokAt(2), AccessControl::Local); // check for variable declaration and add it to new scope if found + else if (newScope->type == ScopeType::eCatch) + newScope->checkVariable(tok->tokAt(2), AccessControl::Throw); // check for variable declaration and add it to new scope if found tok = tok->next(); inIfCondition.push(scopeStartTok); + pendingIfScopes.push(newScope); } else if (Token::Match(tok, "%var% {")) { endInitList.emplace(tok->linkAt(1), scope); tok = tok->next(); @@ -783,6 +785,8 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() endInitList.emplace(tok->link(), scope); } else if (!inIfCondition.empty() && tok == inIfCondition.top()) { inIfCondition.pop(); + scope = pendingIfScopes.top(); + pendingIfScopes.pop(); } else if (isExecutableScope(tok)) { scopeList.emplace_back(*this, tok, scope, ScopeType::eUnconditional, tok); scope->nestedList.push_back(&scopeList.back()); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 192c40f51e5..05dd0ab9b8f 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -441,6 +441,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(createSymbolDatabaseFindAllScopes8); // #12761 TEST_CASE(createSymbolDatabaseFindAllScopes9); TEST_CASE(createSymbolDatabaseFindAllScopes10); + TEST_CASE(createSymbolDatabaseFindAllScopes11); TEST_CASE(createSymbolDatabaseIncompleteVars); @@ -6110,6 +6111,24 @@ class TestSymbolDatabase : public TestFixture { } } + void createSymbolDatabaseFindAllScopes11() // #13685 + { + GET_SYMBOL_DB("int f() {\n" + " int x;\n" + " if (!({ int *p = &x; *p = 1; 1; }))\n" + " return 0;\n" + " return x;\n" + "}\n"); + ASSERT(db && db->scopeList.size() == 4); + + auto it = db->scopeList.begin(); + std::advance(it, 3); + const Scope& compoundScope = *it; + ASSERT_EQUALS_ENUM(ScopeType::eUnconditional, compoundScope.type); + ASSERT_EQUALS_ENUM(ScopeType::eFunction, compoundScope.nestedIn->type); + ASSERT_EQUALS("f", compoundScope.nestedIn->className); + } + void createSymbolDatabaseIncompleteVars() { { diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 554eaca1f11..62be497638a 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -76,6 +76,7 @@ class TestUninitVar : public TestFixture { TEST_CASE(uninitvar12); // #10218 - stream read TEST_CASE(uninitvar13); // #9772 TEST_CASE(uninitvar14); + TEST_CASE(uninitvar15); // #13685 TEST_CASE(uninitvar_unconditionalTry); TEST_CASE(uninitvar_funcptr); // #6404 TEST_CASE(uninitvar_operator); // #6680 @@ -3647,6 +3648,17 @@ class TestUninitVar : public TestFixture { (checkuninitvar.valueFlowUninit)(); } + void uninitvar15() { // #13685 + const char code[] = "int f() {\n" + " int x;\n" + " if (!({ int *p = &x; *p = 1; 1; }))\n" + " return 0;\n" + " return x;\n" + "}"; + valueFlowUninit(code, false); + ASSERT_EQUALS("", errout_str()); + } + void valueFlowUninit2_value() { valueFlowUninit("void f() {\n" From 018417d499ddde241db5aec6a1d32d460fc1a2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 11 Mar 2026 13:01:12 +0100 Subject: [PATCH 218/675] Fix #14577 (Checkers report: unsigned integer overflow can lead to huge string) (#8306) --- Makefile | 4 +++ lib/checkersreport.cpp | 8 ++++- test/testcheckersreport.cpp | 58 +++++++++++++++++++++++++++++++++++++ test/testrunner.vcxproj | 1 + 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 test/testcheckersreport.cpp diff --git a/Makefile b/Makefile index 37156d357af..7dd1228a0d7 100644 --- a/Makefile +++ b/Makefile @@ -294,6 +294,7 @@ TESTOBJ = test/fixture.o \ test/testbufferoverrun.o \ test/testcharvar.o \ test/testcheck.o \ + test/testcheckersreport.o \ test/testclangimport.o \ test/testclass.o \ test/testcmdlineparser.o \ @@ -757,6 +758,9 @@ test/testcharvar.o: test/testcharvar.cpp lib/addoninfo.h lib/check.h lib/checker test/testcheck.o: test/testcheck.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcheck.cpp +test/testcheckersreport.o: test/testcheckersreport.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/checkersreport.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h + $(CXX) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcheckersreport.cpp + test/testclangimport.o: test/testclangimport.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/clangimport.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testclangimport.cpp diff --git a/lib/checkersreport.cpp b/lib/checkersreport.cpp index 59b3cf99495..0bbe02f3d7b 100644 --- a/lib/checkersreport.cpp +++ b/lib/checkersreport.cpp @@ -209,13 +209,19 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const fout << title << std::endl; fout << std::string(title.size(), '-') << std::endl; + maxCheckerSize = 0; + for (const auto& checkReq: addonInfo.checkers) { + const std::string& checker = checkReq.first; + maxCheckerSize = std::max(checker.size(), maxCheckerSize); + } + for (const auto& checkReq: addonInfo.checkers) { const std::string& checker = checkReq.first; const bool active = mActiveCheckers.count(checkReq.first) > 0; const std::string& req = checkReq.second; fout << (active ? "Yes " : "No ") << checker; if (!active && !req.empty()) - fout << std::string(maxCheckerSize + 4 - checker.size(), ' ') << "require:" + req; + fout << std::string(maxCheckerSize + 4 - checker.size(), ' ') << "require:" << req; fout << std::endl; } } diff --git a/test/testcheckersreport.cpp b/test/testcheckersreport.cpp new file mode 100644 index 00000000000..2d539ee77cf --- /dev/null +++ b/test/testcheckersreport.cpp @@ -0,0 +1,58 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2025 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include "checkersreport.h" +#include "fixture.h" +#include "helpers.h" +#include "settings.h" + +#include + +class TestCheckersReport : public TestFixture { +public: + TestCheckersReport() : TestFixture("TestCheckersReport") {} + + + void run() final { + // AddonInfo::checkers + TEST_CASE(addonInfoCheckers); + } + + void addonInfoCheckers() const { + AddonInfo a; + a.name = "test"; + a.checkers["abcdefghijklmnopqrstuvwxyz::abcdefghijklmnopqrstuvwxyz"] = "123"; + Settings s; + s.addonInfos.emplace_back(a); + const std::set activeCheckers; + CheckersReport r(s, activeCheckers); + const std::string report = r.getReport(""); + const auto pos = report.rfind("\n\n"); + ASSERT(pos != std::string::npos); + + const char expected[] = + "test checkers\n" + "-------------\n" + "No abcdefghijklmnopqrstuvwxyz::abcdefghijklmnopqrstuvwxyz require:123\n"; + + ASSERT_EQUALS(expected, report.substr(pos+2)); + } +}; + +REGISTER_TEST(TestCheckersReport) diff --git a/test/testrunner.vcxproj b/test/testrunner.vcxproj index cd7a039c418..1c5230c5535 100755 --- a/test/testrunner.vcxproj +++ b/test/testrunner.vcxproj @@ -53,6 +53,7 @@ + From 2f1665b575530d37dc5dbdb8454fb34c1e686d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Wed, 11 Mar 2026 14:17:35 +0100 Subject: [PATCH 219/675] [utils] Add Doxygen comment for utils::as_const (#8320) Fix typos in Doxygen comment of splitString --- lib/utils.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/utils.h b/lib/utils.h index abe1477a2a8..5a6927a5d96 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -403,14 +403,18 @@ static inline T* empty_if_null(T* p) } /** - * Split string by given sperator. + * Split string by given separator. * @param str The string to split - * @param sep The seperator - * @return The list of seperate strings (including empty ones). The whole input string if no seperator found. + * @param sep The separator + * @return The list of separate strings (including empty ones). The whole input string if no separator found. */ CPPCHECKLIB std::vector splitString(const std::string& str, char sep); namespace utils { + /** + * Drop-in replacement for C++17's std::as_const + * @param t The function forms the lvalue reference to const type of this argument. + */ template constexpr typename std::add_const::type & as_const(T& t) noexcept { From e473adb8fefb0fff9035a8dbda39130b03adabe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Wed, 11 Mar 2026 14:36:06 +0100 Subject: [PATCH 220/675] iwyu.yml: reverted to Clang 21 for now [skip ci] (#8318) --- .github/workflows/iwyu.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index fa9be0cbba8..7a7d5c8d500 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -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 22 - sudo apt-get install -y clang-tools-22 + sudo ./llvm.sh 21 + sudo apt-get install -y clang-tools-21 - name: Install libc++ if: matrix.stdlib == 'libc++' run: | - sudo apt-get install -y libc++-22-dev + sudo apt-get install -y libc++-21-dev - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -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-22 - CXX: clang++-22 + CC: clang-21 + CXX: clang++-21 - name: Prepare CMake dependencies run: | @@ -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-22 --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-21 --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() From 8c99f0ece6ec054cc8fd5c755f291914bc055656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Wed, 11 Mar 2026 14:36:22 +0100 Subject: [PATCH 221/675] gui/mainwindows.cpp: removed redundant `ResultsView::clear()` call (#8315) already done in `clearResults()` above --- gui/mainwindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index f4e1dc2af9b..63917bdc912 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -597,7 +597,6 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons enableProjectActions(false); } - mUI->mResults->clear(true); mUI->mResults->setResultsSource(ResultsTree::ResultsSource::Analysis); mThread->clearFiles(); From 54b436464696a4368b7e9b7eaf302220e36bd23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Wed, 11 Mar 2026 14:36:32 +0100 Subject: [PATCH 222/675] testrunner: added option `-x` to exclude the specified tests (#8314) --- test/fixture.cpp | 23 +++++++++++++++-------- test/options.cpp | 6 ++++++ test/options.h | 3 +++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/test/fixture.cpp b/test/fixture.cpp index fb535b1a1d0..00c844815fa 100644 --- a/test/fixture.cpp +++ b/test/fixture.cpp @@ -346,7 +346,8 @@ void TestFixture::printHelp() " -q Do not print the test cases that have run.\n" " -h, --help Print this help.\n" " -n Print no summaries.\n" - " -d Do not execute the tests.\n"; + " -d Do not execute any tests (dry run).\n" + " -x Exclude the specified tests.\n"; } void TestFixture::run(const std::string &str) @@ -390,17 +391,23 @@ std::size_t TestFixture::runTests(const options& args) // TODO: bail out when given class/test is not found? for (std::string classname : args.which_test()) { std::string testname; - if (classname.find("::") != std::string::npos) { - testname = classname.substr(classname.find("::") + 2); - classname.erase(classname.find("::")); + const std::string::size_type pos = classname.find("::"); + if (pos != std::string::npos) { + // TODO: excluding indiviual tests is not supported yet + testname = classname.substr(pos + 2); + classname.erase(pos); } for (TestInstance * test : TestRegistry::theInstance().tests()) { - if (classname.empty() || test->classname == classname) { - TestFixture* fixture = test->create(); - fixture->processOptions(args); - fixture->run(testname); + if (!classname.empty()) { + const bool match = test->classname == classname; + if ((match && args.exclude_tests()) || (!match && !args.exclude_tests())) + continue; } + + TestFixture* fixture = test->create(); + fixture->processOptions(args); + fixture->run(testname); } } diff --git a/test/options.cpp b/test/options.cpp index e8b3be139ae..17e44eeb6bf 100644 --- a/test/options.cpp +++ b/test/options.cpp @@ -22,6 +22,7 @@ options::options(int argc, const char* const argv[]) ,mHelp(mWhichTests.count("-h") != 0 || mWhichTests.count("--help")) ,mSummary(mWhichTests.count("-n") == 0) ,mDryRun(mWhichTests.count("-d") != 0) + ,mExcludeTests(mWhichTests.count("-x") != 0) ,mExe(argv[0]) { for (auto it = mWhichTests.cbegin(); it != mWhichTests.cend();) { @@ -65,3 +66,8 @@ const std::string& options::exe() const { return mExe; } + +bool options::exclude_tests() const +{ + return mExcludeTests; +} diff --git a/test/options.h b/test/options.h index 18df1dd79b2..5be6ca34e61 100644 --- a/test/options.h +++ b/test/options.h @@ -37,6 +37,8 @@ class options { bool summary() const; /** Perform dry run. */ bool dry_run() const; + /** Exclude provided lists of tests. */ + bool exclude_tests() const; /** Which test should be run. Empty string means 'all tests' */ const std::set& which_test() const; @@ -52,6 +54,7 @@ class options { const bool mHelp; const bool mSummary; const bool mDryRun; + const bool mExcludeTests; std::string mExe; }; From 45e0eb04da128332a545a02c9439aff90b06f4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Wed, 11 Mar 2026 14:37:14 +0100 Subject: [PATCH 223/675] refs #14579 / refs #10543 - fixed compilation on Alpine Linux / added checks for includes / added Alpine to CI (#8313) --- .github/workflows/CI-unixish-docker.yml | 35 ++++++++++++++++++++----- CMakeLists.txt | 1 + Makefile | 3 +++ cli/CMakeLists.txt | 1 - cmake/compilerDefinitions.cmake | 4 +++ cmake/includechecks.cmake | 8 ++++++ cmake/printInfo.cmake | 3 +++ lib/config.h | 8 +++++- tools/dmake/dmake.cpp | 4 +++ 9 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 cmake/includechecks.cmake diff --git a/.github/workflows/CI-unixish-docker.yml b/.github/workflows/CI-unixish-docker.yml index 083bb7b7651..a38feb452f0 100644 --- a/.github/workflows/CI-unixish-docker.yml +++ b/.github/workflows/CI-unixish-docker.yml @@ -20,7 +20,16 @@ jobs: strategy: matrix: - image: ["ubuntu:24.04", "ubuntu:25.10"] + include: + - image: "ubuntu:24.04" + with_gui: true + full_build: true + - image: "ubuntu:25.10" + with_gui: true + full_build: true + - image: "alpine:3.23" + with_gui: false # it appears FindQt6.cmake is not provided by any package + full_build: false # FIXME: test-signalhandler.cpp fails to build since feenableexcept() is missing fail-fast: false # Prefer quick result runs-on: ubuntu-22.04 @@ -45,9 +54,15 @@ jobs: apt-get install -y cmake g++ make libxml2-utils libpcre3-dev - name: Install missing software (gui) on latest ubuntu + if: contains(matrix.image, 'ubuntu') run: | apt-get install -y qt6-base-dev qt6-charts-dev qt6-tools-dev + - name: Install missing software on Alpine + if: contains(matrix.image, 'alpine') + run: | + apk add cmake make g++ pcre-dev + # needs to be called after the package installation since # - it doesn't call "apt-get update" - name: ccache @@ -57,9 +72,10 @@ jobs: - name: Run CMake run: | - cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=${{ matrix.with_gui }} -DWITH_QCHART=On -DBUILD_TRIAGE=${{ matrix.with_gui }} -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - - name: CMake build (with GUI) + - name: CMake build + if: matrix.full_build run: | cmake --build cmake.output -- -j$(nproc) @@ -71,7 +87,7 @@ jobs: strategy: matrix: - image: ["ubuntu:24.04", "ubuntu:25.10"] + image: ["ubuntu:24.04", "ubuntu:25.10", "alpine:3.23"] fail-fast: false # Prefer quick result runs-on: ubuntu-22.04 @@ -90,6 +106,11 @@ jobs: apt-get update apt-get install -y g++ make python3 libxml2-utils libpcre3-dev + - name: Install missing software on Alpine + if: contains(matrix.image, 'alpine') + run: | + apk add make g++ pcre-dev bash python3 libxml2-utils + # needs to be called after the package installation since # - it doesn't call "apt-get update" - name: ccache @@ -97,14 +118,16 @@ jobs: with: key: ${{ github.workflow }}-${{ matrix.image }} + # /usr/lib/ccache/bin - Alpine Linux + - name: Build cppcheck run: | - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + export PATH="/usr/lib/ccache/bin:/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) HAVE_RULES=yes CXXOPTS="-Werror" - name: Build test run: | - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + export PATH="/usr/lib/ccache/bin:/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) HAVE_RULES=yes CXXOPTS="-Werror" testrunner - name: Run test diff --git a/CMakeLists.txt b/CMakeLists.txt index b32fc90811b..3c037a10b36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ include(cmake/compilerCheck.cmake) include(cmake/versions.cmake) include(cmake/findDependencies.cmake) include(cmake/compileroptions.cmake) +include(cmake/includechecks.cmake) include(cmake/compilerDefinitions.cmake) include(cmake/buildFiles.cmake) if(BUILD_GUI) diff --git a/Makefile b/Makefile index 7dd1228a0d7..da5d9e73dfa 100644 --- a/Makefile +++ b/Makefile @@ -155,6 +155,9 @@ else ifneq ($(HAVE_RULES),) $(error invalid HAVE_RULES value '$(HAVE_RULES)') endif +HAVE_EXECINFO_H=$(shell echo "\#include " | $(CXX) -c -xc - 2> /dev/null && echo "1" || echo "0") +override CPPFLAGS += -DHAVE_EXECINFO_H=$(HAVE_EXECINFO_H) + override CXXFLAGS += $(CXXOPTS) override CPPFLAGS += $(CPPOPTS) override LDFLAGS += $(LDOPTS) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 2664a29a65d..f63f3291849 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -1,4 +1,3 @@ - file(GLOB hdrs "*.h") file(GLOB srcs "*.cpp") file(GLOB mainfile "main.cpp") diff --git a/cmake/compilerDefinitions.cmake b/cmake/compilerDefinitions.cmake index 4967c282336..a43073018e6 100644 --- a/cmake/compilerDefinitions.cmake +++ b/cmake/compilerDefinitions.cmake @@ -66,6 +66,10 @@ if(NO_WINDOWS_SEH) add_definitions(-DNO_WINDOWS_SEH) endif() +if(NOT MSVC) + add_definitions(-DHAVE_EXECINFO_H=${HAVE_EXECINFO_H}) +endif() + if(FILESDIR_DEF) file(TO_CMAKE_PATH "${FILESDIR_DEF}" _filesdir) add_definitions(-DFILESDIR="${_filesdir}") diff --git a/cmake/includechecks.cmake b/cmake/includechecks.cmake new file mode 100644 index 00000000000..b9cbbd03183 --- /dev/null +++ b/cmake/includechecks.cmake @@ -0,0 +1,8 @@ +include(CheckIncludeFileCXX) + +if(NOT MSVC) + check_include_file_cxx(execinfo.h HAVE_EXECINFO_H) + if(NOT HAVE_EXECINFO_H) + set(HAVE_EXECINFO_H 0) + endif() +endif() \ No newline at end of file diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index 97f0f7d2536..ec567c74c41 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -15,6 +15,9 @@ message(STATUS "C++ flags (RelWithDebInfo) = ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") message(STATUS "C++ flags (Debug) = ${CMAKE_CXX_FLAGS_DEBUG}") message(STATUS "CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}") message(STATUS "CPPCHK_GLIBCXX_DEBUG = ${CPPCHK_GLIBCXX_DEBUG}") +if(DEFINED HAVE_EXECINFO_H) + message(STATUS "HAVE_EXECINFO_H = ${HAVE_EXECINFO_H}") +endif() get_directory_property(DirCompileDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS) message(STATUS "COMPILE_DEFINITIONS (global) = ${DirCompileDefs}") get_directory_property(DirCompileOptions DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_OPTIONS) diff --git a/lib/config.h b/lib/config.h index a63cf773d54..ff289569045 100644 --- a/lib/config.h +++ b/lib/config.h @@ -206,9 +206,15 @@ #define USE_WINDOWS_SEH #endif -#if !defined(NO_UNIX_BACKTRACE_SUPPORT) && defined(__GNUC__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__SVR4) && !defined(__QNX__) && !defined(_AIX) +#if !defined(NO_UNIX_BACKTRACE_SUPPORT) +#if defined(HAVE_EXECINFO_H) +#if HAVE_EXECINFO_H #define USE_UNIX_BACKTRACE_SUPPORT #endif +#elif defined(__GNUC__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__SVR4) && !defined(__QNX__) && !defined(_AIX) +#define USE_UNIX_BACKTRACE_SUPPORT +#endif +#endif #if !defined(NO_UNIX_SIGNAL_HANDLING) && defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OS2__) #define USE_UNIX_SIGNAL_HANDLING diff --git a/tools/dmake/dmake.cpp b/tools/dmake/dmake.cpp index f8869f2eba7..82754f1df11 100644 --- a/tools/dmake/dmake.cpp +++ b/tools/dmake/dmake.cpp @@ -771,6 +771,10 @@ int main(int argc, char **argv) << " $(error invalid HAVE_RULES value '$(HAVE_RULES)')\n" << "endif\n\n"; + // the # needs to be escaped on older make versions + fout << "HAVE_EXECINFO_H=$(shell echo \"\\#include \" | $(CXX) -c -xc - 2> /dev/null && echo \"1\" || echo \"0\")\n" + << "override CPPFLAGS += -DHAVE_EXECINFO_H=$(HAVE_EXECINFO_H)\n\n"; + fout << "override CXXFLAGS += $(CXXOPTS)\n"; fout << "override CPPFLAGS += $(CPPOPTS)\n"; fout << "override LDFLAGS += $(LDOPTS)\n\n"; From 1b9124e5d896b1336ee7153e2489a2658386a11a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 11 Mar 2026 18:42:20 +0100 Subject: [PATCH 224/675] Fix #14533, #14536 FN stlcstrConcat, stlcstrAssignment, stlcstrConstructor (#8261) Co-authored-by: chrchr-github --- gui/librarydialog.cpp | 2 +- lib/checkstl.cpp | 61 ++++++++++++++++++++++++++++++++++++------- test/teststl.cpp | 39 +++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 11 deletions(-) diff --git a/gui/librarydialog.cpp b/gui/librarydialog.cpp index f38b64bdedc..3199af9a975 100644 --- a/gui/librarydialog.cpp +++ b/gui/librarydialog.cpp @@ -167,7 +167,7 @@ void LibraryDialog::saveCfg() void LibraryDialog::saveCfgAs() { const QString filter(tr("Library files (*.cfg)")); - const QString path = Path::getPathFromFilename(mFileName.toStdString()).c_str(); + const QString path = QString::fromStdString(Path::getPathFromFilename(mFileName.toStdString())); QString selectedFile = QFileDialog::getSaveFileName(this, tr("Save the library as"), path, diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index c4827157988..882f4588eeb 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1959,6 +1959,53 @@ static bool isLocal(const Token *tok) return var && !var->isStatic() && var->isLocal(); } +static bool isc_strCall(const Token* tok, const Library::Container* container) +{ + if (!Token::simpleMatch(tok, "(")) + return false; + const Token* dot = tok->astOperand1(); + if (!Token::simpleMatch(dot, ".")) + return false; + const Token* obj = dot->astOperand1(); + if (!obj || !obj->valueType()) + return false; + const Library::Container* objContainer = obj->valueType()->container; + if (!objContainer || !container || !objContainer->stdStringLike || (objContainer != container && !container->view)) + return false; + return Token::Match(dot->astOperand2(), "c_str|data ( )"); +} + +static bool isc_strConcat(const Token* tok) +{ + if (!tok->isBinaryOp() || !Token::simpleMatch(tok, "+")) + return false; + for (const Token* op : { tok->astOperand1(), tok->astOperand2() }) { // NOLINT(readability-use-anyofallof) + const Token* sibling = op->astSibling(); + if (!sibling->valueType()) + continue; + if (isc_strCall(op, sibling->valueType()->container)) + return true; + } + return false; +} + +static bool isc_strAssignment(const Token* tok) +{ + if (!Token::simpleMatch(tok, "=")) + return false; + const Token* strTok = tok->astOperand1(); + if (!strTok || !strTok->valueType()) + return false; + return isc_strCall(tok->astOperand2(), strTok->valueType()->container); +} + +static bool isc_strConstructor(const Token* tok) +{ + if (!tok->valueType() || !Token::Match(tok, "%var% (|{")) + return false; + return isc_strCall(tok->tokAt(1)->astOperand2(), tok->valueType()->container); +} + namespace { const std::set stl_string_stream = { "istringstream", "ostringstream", "stringstream", "wstringstream" @@ -2027,16 +2074,14 @@ void CheckStl::string_c_str() const Variable* var2 = tok->tokAt(2)->variable(); if (var->isPointer() && var2 && var2->isStlType(stl_string_stream)) string_c_strError(tok); + } else if (printPerformance && isc_strAssignment(tok->tokAt(1))) { + string_c_strAssignment(tok, tok->variable()->getTypeName()); } else if (Token::Match(tok->tokAt(2), "%name% (") && Token::Match(tok->linkAt(3), ") . c_str|data ( ) ;") && tok->tokAt(2)->function() && Token::Match(tok->tokAt(2)->function()->retDef, "std :: string|wstring %name%")) { const Variable* var = tok->variable(); if (var->isPointer()) string_c_strError(tok); - } else if (printPerformance && tok->tokAt(1)->astOperand2() && Token::Match(tok->tokAt(1)->astOperand2()->tokAt(-3), "%var% . c_str|data ( ) ;")) { - const Token* vartok = tok->tokAt(1)->astOperand2()->tokAt(-3); - if ((tok->variable()->isStlStringType() || tok->variable()->isStlStringViewType()) && vartok->variable() && vartok->variable()->isStlStringType()) - string_c_strAssignment(tok, tok->variable()->getTypeName()); } } else if (printPerformance && tok->function() && Token::Match(tok, "%name% ( !!)") && tok->str() != scope.className) { const auto range = c_strFuncParam.equal_range(tok->function()); @@ -2068,13 +2113,9 @@ void CheckStl::string_c_str() } } } - } else if (printPerformance && Token::Match(tok, "%var% (|{ %var% . c_str|data ( ) !!,") && - tok->variable() && (tok->variable()->isStlStringType() || tok->variable()->isStlStringViewType()) && - tok->tokAt(2)->variable() && tok->tokAt(2)->variable()->isStlStringType()) { + } else if (printPerformance && isc_strConstructor(tok)) { string_c_strConstructor(tok, tok->variable()->getTypeName()); - } else if (printPerformance && tok->next() && tok->next()->variable() && tok->next()->variable()->isStlStringType() && tok->valueType() && tok->valueType()->type == ValueType::CONTAINER && - ((Token::Match(tok->previous(), "%var% + %var% . c_str|data ( )") && tok->previous()->variable() && tok->previous()->variable()->isStlStringType()) || - (Token::Match(tok->tokAt(-5), "%var% . c_str|data ( ) + %var%") && tok->tokAt(-5)->variable() && tok->tokAt(-5)->variable()->isStlStringType()))) { + } else if (printPerformance && isc_strConcat(tok)) { string_c_strConcat(tok); } else if (printPerformance && Token::simpleMatch(tok, "<<") && tok->astOperand2() && Token::Match(tok->astOperand2()->astOperand1(), ". c_str|data ( )")) { const Token* str = tok->astOperand2()->astOperand1()->astOperand1(); diff --git a/test/teststl.cpp b/test/teststl.cpp index 9f25d29478b..2c88f17dd14 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -4680,6 +4680,45 @@ class TestStl : public TestFixture { " return s->x.c_str();\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("std::string f(const std::string& s) {\n" // #14533 + " auto x = std::string(\"abc\") + s.c_str();\n" + " auto y = s.c_str() + std::string(\"def\");\n" + " return x + y;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:33]: (performance) Concatenating the result of c_str() and a std::string is slow and redundant. [stlcstrConcat]\n" + "[test.cpp:3:24]: (performance) Concatenating the result of c_str() and a std::string is slow and redundant. [stlcstrConcat]\n", + errout_str()); + + check("std::string get();\n" + "std::string f(const std::string& s) {\n" + " return get() + s.c_str();\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:18]: (performance) Concatenating the result of c_str() and a std::string is slow and redundant. [stlcstrConcat]\n", + errout_str()); + + check("std::string get();\n" // #14536 + " std::string f(const std::string& s) {\n" + " return s + get().c_str();\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:14]: (performance) Concatenating the result of c_str() and a std::string is slow and redundant. [stlcstrConcat]\n", + errout_str()); + + check("std::string get();\n" + "std::string f(std::string & s) {\n" + " s = get().c_str();\n" + " std::string s2{ get().c_str() };\n" + " return s2;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:5]: (performance) Assigning the result of c_str() to a std::string is slow and redundant. [stlcstrAssignment]\n" + "[test.cpp:4:17]: (performance) Constructing a std::string from the result of c_str() is slow and redundant. [stlcstrConstructor]\n", + errout_str()); + + check("void f() {\n" + " std::string s;\n" + " auto a = + s.c_str();\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void uselessCalls() { From 922bb96ad804e48c988746be95b5b218d2c9d6d8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 12 Mar 2026 08:26:20 +0100 Subject: [PATCH 225/675] CheckUninitVar: avoid redundant find() (#8321) Co-authored-by: chrchr-github --- lib/checkuninitvar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 7dc89eb398c..ecaed652c5e 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -304,7 +304,7 @@ static void conditionAlwaysTrueOrFalse(const Token *tok, const std::mapisName() || tok->str() == ".") { while (tok && tok->str() == ".") tok = tok->astOperand2(); - const auto it = utils::as_const(variableValue).find(tok ? tok->varId() : ~0U); + const auto it = tok ? variableValue.find(tok->varId()) : variableValue.end(); if (it != variableValue.end()) { *alwaysTrue = (it->second != 0LL); *alwaysFalse = (it->second == 0LL); @@ -330,7 +330,7 @@ static void conditionAlwaysTrueOrFalse(const Token *tok, const std::mapstr() == ".") vartok = vartok->astOperand2(); - const auto it = utils::as_const(variableValue).find(vartok ? vartok->varId() : ~0U); + const auto it = vartok ? variableValue.find(vartok->varId()) : variableValue.end(); if (it == variableValue.end()) return; From 649627340e36cda6e9fdca92aee172d6df378df7 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 13 Mar 2026 10:51:46 +0100 Subject: [PATCH 226/675] Fix #14560 FP constParameterPointer (bad configuration in windows.cfg) (#8325) --- cfg/windows.cfg | 6 +++--- test/cfg/windows.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cfg/windows.cfg b/cfg/windows.cfg index 7020162805a..d698f320d3f 100644 --- a/cfg/windows.cfg +++ b/cfg/windows.cfg @@ -3504,7 +3504,7 @@ HFONT CreateFont( - + @@ -3559,7 +3559,7 @@ HFONT CreateFont( - + @@ -4120,7 +4120,7 @@ HFONT CreateFont( - + diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index a07e1b09365..f92c9941d81 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -1223,3 +1224,13 @@ void SEH_unusedLabel() { // #13233 __finally { } } + +HWND constParameterPointer_CreateWindow(void* param) { // #14560 + return CreateWindow(L"MessageWnd", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, param); +} + +void constParameterPointer_SetupDiGetDeviceInstanceId(HDEVINFO info, SP_DEVINFO_DATA *data) { + const DWORD buffer_size = 256; + TCHAR buffer[buffer_size]; + SetupDiGetDeviceInstanceId(info, data, buffer, buffer_size, NULL); +} From 951567b6457095f972a9000f7f740eace0975142 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:20:08 +0100 Subject: [PATCH 227/675] Fix #14583 FP duplInheritedMember for uninstantiated template (#8326) --- lib/checkclass.cpp | 2 ++ test/testclass.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 2b972e221fc..8f3c3baa293 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -3127,6 +3127,8 @@ static std::vector getDuplInheritedMemberFunctionsRecursive( continue; if (classFuncIt.tokenDef->isExpandedMacro()) continue; + if (classFuncIt.templateDef) + continue; for (const Function& parentClassFuncIt : parentClassIt.type->classScope->functionList) { if (classFuncIt.name() == parentClassFuncIt.name() && (parentClassFuncIt.access != AccessControl::Private || !skipPrivate) && diff --git a/test/testclass.cpp b/test/testclass.cpp index 9698916c41a..96b348fd376 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -734,6 +734,13 @@ class TestClass : public TestFixture { " void Two() = delete;\n" "};\n"); ASSERT_EQUALS("", errout_str()); + + checkDuplInheritedMembers("struct B { void f(); };\n" // #14583 + "struct D : B {\n" + " template \n" + " void f();\n" + "};\n"); + ASSERT_EQUALS("", errout_str()); } #define checkCopyConstructor(...) checkCopyConstructor_( __FILE__, __LINE__, __VA_ARGS__) From 7d80f6411f04f953a65a752b511b4ba66fa3a053 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:20:53 +0100 Subject: [PATCH 228/675] Fix #14581 FP missingOverride for uninstantiated template overload (#8322) --- lib/checkclass.cpp | 2 ++ test/testclass.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 8f3c3baa293..ebdb434bb24 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -3271,6 +3271,8 @@ void CheckClass::checkOverride() continue; if (func.tokenDef->isExpandedMacro()) continue; + if (func.templateDef) + continue; const Function *baseFunc = func.getOverriddenFunction(); if (baseFunc) overrideError(baseFunc, &func); diff --git a/test/testclass.cpp b/test/testclass.cpp index 96b348fd376..43ada536df2 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -8842,6 +8842,16 @@ class TestClass : public TestFixture { "};\n"); ASSERT_EQUALS("[test.cpp:2:14] -> [test.cpp:5:6]: (style) The destructor '~D' overrides a destructor in a base class but is not marked with a 'override' specifier. [missingOverride]\n", errout_str()); + + checkOverride("struct B {\n" // #14581 + " virtual void f();\n" + "};\n" + "struct D : B {\n" + " void f() override;\n" + " template \n" + " void f();\n" + "};\n"); + ASSERT_EQUALS("", errout_str()); } void overrideCVRefQualifiers() { From aeb2328a5116e547167182f2380ff1a8f4e27313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 15 Mar 2026 01:14:57 +0100 Subject: [PATCH 229/675] refs #14084 - fixed most uninitialized CMake variables (#8292) --- cmake/clang_tidy.cmake | 2 ++ cmake/findDependencies.cmake | 7 ++++++- cmake/printInfo.cmake | 20 ++++++++++++++------ lib/CMakeLists.txt | 3 +++ test/CMakeLists.txt | 2 +- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/cmake/clang_tidy.cmake b/cmake/clang_tidy.cmake index 486c560f1f5..a192fc13320 100644 --- a/cmake/clang_tidy.cmake +++ b/cmake/clang_tidy.cmake @@ -37,6 +37,8 @@ if(RUN_CLANG_TIDY_NAMES) set(CLANG_TIDY_CSA_CONFIG "-config={InheritParentConfig: true, Checks: '-*,clang-analyzer-*,-clang-analyzer-core.CallAndMessage,-clang-analyzer-core.NonNullParamChecker,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-cplusplus.NewDelete,-clang-analyzer-core.NullDereference,-clang-analyzer-unix.Stream,-clang-analyzer-alpha.clone.CloneChecker,-clang-analyzer-alpha.webkit.*'}") if (ENABLE_CSA_ALPHA) set(CLANG_TIDY_CSA_ALPHA_OPTS "-allow-enabling-alpha-checkers" "-extra-arg=-Xclang" "-extra-arg=-analyzer-config" "-extra-arg=-Xclang" "-extra-arg=aggressive-binary-operation-simplification=true") + else() + set(CLANG_TIDY_CSA_ALPHA_OPTS "") endif() # TODO: exclude moc_*.cpp diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index f3d7b0b2fec..ddfef6718c2 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -34,6 +34,8 @@ if(HAVE_RULES) if(NOT PCRE_LIBRARY OR NOT PCRE_INCLUDE) message(FATAL_ERROR "pcre dependency for RULES has not been found") endif() +else() + set(PCRE_LIBRARY "") endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -70,6 +72,9 @@ if(NOT USE_BUNDLED_TINYXML2) endif() find_package(Threads REQUIRED) +if(NOT DEFINED CMAKE_THREAD_LIBS_INIT) + set(CMAKE_THREAD_LIBS_INIT "") +endif() if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30") # avoid legacy warning about Boost lookup in CMake @@ -90,7 +95,7 @@ if(USE_BOOST) endif() set(Boost_FOUND ON) set(Boost_INCLUDE_DIRS "${BOOST_INCLUDEDIR}") - # TODO: set Boost_VERSION_STRING + set(Boost_VERSION_STRING "") # TODO: set proper value elseif(USE_BOOST STREQUAL "Auto") find_package(Boost) else() diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index ec567c74c41..87c7e41f284 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -72,7 +72,9 @@ if(BUILD_GUI) message(STATUS "QT_VERSION = ${QT_VERSION}") message(STATUS "Qt6Core_LIBRARIES = ${Qt6Core_LIBRARIES}") message(STATUS "Qt6Core_INCLUDE_DIRS = ${Qt6Core_INCLUDE_DIRS}") - message(STATUS "QHELPGENERATOR = ${QHELPGENERATOR}") + if(BUILD_ONLINE_HELP) + message(STATUS "QHELPGENERATOR = ${QHELPGENERATOR}") + endif() endif() message(STATUS) message(STATUS "HAVE_RULES = ${HAVE_RULES}") @@ -86,16 +88,22 @@ message(STATUS "CMAKE_THREAD_LIBS_INIT = ${CMAKE_THREAD_LIBS_INIT}") message(STATUS) message(STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}") if(NOT USE_BUNDLED_TINYXML2) - message(STATUS "tinyxml2_LIBRARIES = ${tinyxml2_LIBRARIES}") - message(STATUS "tinyxml2_INCLUDE_DIRS = ${tinyxml2_INCLUDE_DIRS}") + if(TARGET tinyxml2::tinyxml2) + # TODO: print libraries and include dirs + else() + message(STATUS "tinyxml2_LIBRARIES = ${tinyxml2_LIBRARIES}") + message(STATUS "tinyxml2_INCLUDE_DIRS = ${tinyxml2_INCLUDE_DIRS}") + endif() endif() message(STATUS) message(STATUS "USE_BOOST = ${USE_BOOST}") if(USE_BOOST) message(STATUS "Boost_FOUND = ${Boost_FOUND}") - message(STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}") - message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}") - message(STATUS "USE_BOOST_INT128 = ${USE_BOOST_INT128}") + if(Boost_FOUND) + message(STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}") + message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}") + message(STATUS "USE_BOOST_INT128 = ${USE_BOOST_INT128}") + endif() endif() message(STATUS) message(STATUS "USE_LIBCXX = ${USE_LIBCXX}") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d7a94de352e..b826bc0b265 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -12,6 +12,8 @@ function(build_src output filename) set(${output} ${${output}} ${outfile} PARENT_SCOPE) if (USE_MATCHCOMPILER_OPT STREQUAL "Verify") set(verify_option "--verify") + else() + set(verify_option "") endif() add_custom_command( OUTPUT ${outfile} @@ -28,6 +30,7 @@ function(build_src output filename) endfunction() if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off") + set(srcs_build "") foreach(file ${srcs}) build_src(srcs_build ${file}) endforeach() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0462a65216e..14f3a8eac17 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -79,7 +79,7 @@ if (BUILD_TESTING) set(oneValueArgs PLATFORM NAME) set(multiValueArgs ADD_LIBRARY) - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(PARSE "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) get_filename_component(LIBRARY ${CFG_TEST} NAME_WE) # TODO: get rid of this if(PARSE_ADD_LIBRARY) From 391dd839587fe012f24c91fea287619e316922f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 15 Mar 2026 08:00:51 +0100 Subject: [PATCH 230/675] createrelease: tweak upload [skip ci] (#8339) --- createrelease | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/createrelease b/createrelease index 95eb0db7638..9dd79333119 100755 --- a/createrelease +++ b/createrelease @@ -150,9 +150,9 @@ rm -f cppcheck.cfg # TODO manual, update version on webpage # frs -git archive --format=tar --prefix=$releasename/ $tag | gzip > upload/$releasename.tar.gz -git archive --format=tar --prefix=$releasename/ $tag | bzip2 > upload/$releasename.tar.bz2 -git archive --format=zip -9 --prefix=$releasename/ $tag > upload/$releasename.zip +git archive --format=tar --prefix=$releasename/ $tag | gzip > upload/frs/$releasename.tar.gz +git archive --format=tar --prefix=$releasename/ $tag | bzip2 > upload/frs/$releasename.tar.bz2 +git archive --format=zip -9 --prefix=$releasename/ $tag > upload/frs/$releasename.zip cp releasenotes.txt upload/frs/README.md # TODO msi From fbf35b885c71a5a6a8af82e12b80ad248a8c459b Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Sun, 15 Mar 2026 08:43:22 +0100 Subject: [PATCH 231/675] Fix #14573 Only consider last NULL argument in varFuncNullUB (#8297) Resolving a FP in which the expanded macro ensures that the last variadic argument is not NULL. --- lib/checkother.cpp | 2 +- test/testother.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index bbc6bdb90d0..f051d231b69 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3557,7 +3557,7 @@ void CheckOther::checkVarFuncNullUB() for (const Scope * scope : symbolDatabase->functionScopes) { for (const Token* tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) { // Is NULL passed to a function? - if (Token::Match(tok,"[(,] NULL [,)]")) { + if (Token::Match(tok,"[(,] NULL )")) { // Locate function name in this function call. const Token *ftok = tok; int argnr = 1; diff --git a/test/testother.cpp b/test/testother.cpp index 88c83eba4b1..ec09c9dda63 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -11309,6 +11309,12 @@ class TestOther : public TestFixture { check("void a(char *p, ...);\n" "void b() { a(NULL, 2); }"); ASSERT_EQUALS("", errout_str()); + + checkP("extern const int sentinel;\n" + "void a(int, ...);\n" + "#define b(x, ...) a((x), __VA_ARGS__, &sentinel)\n" + "void c() { b(1, NULL); }"); + ASSERT_EQUALS("", errout_str()); } void checkCastIntToCharAndBack() { // #160 From ade8582175248932a48b2b8314d9b7e93430b677 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 15 Mar 2026 09:56:26 +0100 Subject: [PATCH 232/675] Fix #14582 FP uninitvar (array accessed via cast) (#8329) --- lib/astutils.cpp | 3 ++- test/testuninitvar.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 2d53ef0b0c1..aeee7a372e1 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2636,7 +2636,8 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings &settings, while ((tok2->astParent() && tok2->astParent()->isUnaryOp("*")) || (Token::simpleMatch(tok2->astParent(), ".") && !Token::Match(tok2->astParent()->astParent(), "[(,]")) || (tok2->astParent() && tok2->astParent()->isUnaryOp("&") && Token::simpleMatch(tok2->astParent()->astParent(), ".") && tok2->astParent()->astParent()->originalName()=="->") || - (Token::simpleMatch(tok2->astParent(), "[") && tok2 == tok2->astParent()->astOperand1())) { + (Token::simpleMatch(tok2->astParent(), "[") && tok2 == tok2->astParent()->astOperand1()) || + (Token::simpleMatch(tok2->astParent(), "(") && tok2->astParent()->isCast())) { if (tok2->astParent() && (tok2->astParent()->isUnaryOp("*") || (astIsLHS(tok2) && tok2->astParent()->originalName() == "->" && !hasOverloadedMemberAccess(tok2)))) derefs++; if (derefs > indirect) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 62be497638a..ecb467524c3 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -6696,6 +6696,18 @@ class TestUninitVar : public TestFixture { " return [&]() { return j; }();\n" "}\n"); ASSERT_EQUALS("[test.cpp:17:27]: (error) Uninitialized variable: j [uninitvar]\n", errout_str()); + + valueFlowUninit("int f() {\n" // #14582 + " int a[1];\n" + " static_cast(a)[0] = 0;\n" + " return a[0];\n" + "}\n" + "int g() {\n" + " int a[1];\n" + " ((int*)a)[0] = 0;\n" + " return a[0];\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value From 766c5b56480d76fab46ba0b29a317c6ec53cc352 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 15 Mar 2026 09:57:45 +0100 Subject: [PATCH 233/675] Fix #14595 FN identicalInnerCondition in for loop (#8335) --- lib/checkcondition.cpp | 2 ++ test/testcondition.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 59aad6a9598..14fa900944d 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -619,6 +619,8 @@ static bool isNonConstFunctionCall(const Token *ftok, const Library &library) return false; if (ftok->function() && ftok->function()->isConst()) return false; + if (ftok->isControlFlowKeyword()) + return false; return true; } diff --git a/test/testcondition.cpp b/test/testcondition.cpp index a592c489c59..241d0400099 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -2820,6 +2820,14 @@ class TestCondition : public TestFixture { " }\n" "}"); ASSERT_EQUALS("", errout_str()); + + check("void f(const int* p, const int* e) {\n" // #14595 + " for (; p;) {\n" + " if (p == e) {}\n" + " if (p) {}\n" + " }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2:12] -> [test.cpp:4:13]: (warning) Identical inner 'if' condition is always true. [identicalInnerCondition]\n", errout_str()); } void identicalConditionAfterEarlyExit() { @@ -4675,7 +4683,7 @@ class TestCondition : public TestFixture { " }\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5:18]: (style) Condition 'S::s' is always true [knownConditionTrueFalse]\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3:10] -> [test.cpp:5:18]: (warning) Identical inner 'if' condition is always true. [identicalInnerCondition]\n", errout_str()); check("void f() {\n" // #10811 " int i = 0;\n" @@ -4836,7 +4844,7 @@ class TestCondition : public TestFixture { " if (!b) {}\n" " if (a) {}\n" "}\n"); - ASSERT_EQUALS("[test.cpp:6:9] -> [test.cpp:9:9]: (style) Condition 'a' is always false [knownConditionTrueFalse]\n", + ASSERT_EQUALS("[test.cpp:6:9] -> [test.cpp:9:9]: (warning) Identical condition 'a', second condition is always false [identicalConditionAfterEarlyExit]\n", errout_str()); } From ca14dfa4db02cda39f9043875acc858710d41e16 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 15 Mar 2026 10:00:28 +0100 Subject: [PATCH 234/675] Partial fix for #14523 FN knownConditionTrueFalse (brace-init in if, regression) (#8330) --- lib/vf_common.cpp | 2 +- test/testvalueflow.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/vf_common.cpp b/lib/vf_common.cpp index 78f44de6754..934757edea4 100644 --- a/lib/vf_common.cpp +++ b/lib/vf_common.cpp @@ -323,7 +323,7 @@ namespace ValueFlow if (!tok->isTemplateArg()) value.setKnown(); setTokenValue(tok->next(), std::move(value), settings); - } else if (Token::simpleMatch(tok, "= { } ;")) { + } else if (Token::simpleMatch(tok, "= { }")) { const Token* lhs = tok->astOperand1(); if (lhs && lhs->valueType() && (lhs->valueType()->isIntegral() || lhs->valueType()->pointer > 0)) { Value value(0); diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 00ebe7f694f..709be2a204f 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -6451,6 +6451,11 @@ class TestValueFlow : public TestFixture { " return x;\n" "}\n"; ASSERT_EQUALS(true, testValueOfXKnown(code, 5U, 0)); + + code = "void f() {\n" + " if (int* x = {}) {}\n" + "}\n"; + ASSERT_EQUALS(true, testKnownValueOfTok(code, "=", 0)); } static std::string isPossibleContainerSizeValue(std::list values, From dd26a1a33938696dbb5c937ef498e748cd2605d7 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 15 Mar 2026 10:30:37 +0100 Subject: [PATCH 235/675] Fix #14571 FN constParameterPointer with reference to nested member (regression) (#8299) Co-authored-by: chrchr-github --- cli/signalhandler.cpp | 2 +- lib/astutils.cpp | 2 +- lib/valueflow.cpp | 2 +- test/testother.cpp | 12 ++++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cli/signalhandler.cpp b/cli/signalhandler.cpp index c87822454ae..88864efd743 100644 --- a/cli/signalhandler.cpp +++ b/cli/signalhandler.cpp @@ -108,7 +108,7 @@ static const Signalmap_t listofsignals = { * but when ending up here something went terribly wrong anyway. * And all which is left is just printing some information and terminate. */ -static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) +static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) // cppcheck-suppress constParameterCallback - info can be const { int type = -1; pid_t killid; diff --git a/lib/astutils.cpp b/lib/astutils.cpp index aeee7a372e1..b8e86b3e29d 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1084,7 +1084,7 @@ bool isAliasOf(const Token* tok, const Token* expr, nonneg int* indirect) r = findAstNode(expr, [&](const Token* childTok) { if (childTok->exprId() == 0) return false; - if (ref.token != tok && expr->exprId() == childTok->exprId()) { + if (ref.token != tok && expr->exprId() == childTok->exprId() && ref.token->isUnaryOp("*") && expr->exprId() == ref.token->astOperand1()->exprId()) { if (indirect) *indirect = 0; return true; diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index bf732566fff..f7e057da58f 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4101,7 +4101,7 @@ static bool intersects(const C1& c1, const C2& c2) return false; } -static void valueFlowAfterAssign(TokenList &tokenlist, +static void valueFlowAfterAssign(const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger &errorLogger, const Settings &settings, diff --git a/test/testother.cpp b/test/testother.cpp index ec09c9dda63..241a7512000 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4763,6 +4763,18 @@ class TestOther : public TestFixture { " return [](int* p) { return *p; }(&i);\n" "}\n"); ASSERT_EQUALS("[test.cpp:3:20]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str()); + + check("struct S {\n" // #14571 + " char* c;\n" + "};\n" + "struct T {\n" + " S s;\n" + "};\n" + "void f(std::string* p, T& t) {\n" + " S& r = t.s;\n" + " strcpy(r.c, p->c_str());\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:7:21]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str()); } void constArray() { From 4f31d0aa75c672a81c65aa37e586ce3ec7b0ee9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 15 Mar 2026 18:44:45 +0100 Subject: [PATCH 236/675] release-windows.yml: removed hardcoded aqt version [skip ci] (#8333) --- .github/workflows/release-windows.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 20868c1c607..1caa87b61e5 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -65,14 +65,13 @@ jobs: # available modules: https://github.com/miurahr/aqtinstall/blob/master/docs/getting_started.rst#installing-modules # available tools: https://github.com/miurahr/aqtinstall/blob/master/docs/getting_started.rst#installing-tools - - name: Install Qt ${{ env.QT_VERSION }} + - name: Install Qt uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' setup-python: 'false' tools: 'tools_opensslv3_x64' - aqtversion: '==3.1.*' # TODO: remove when aqtinstall 3.2.2 is available # TODO: build with multiple threads - name: Build x64 release GUI From d6ac48f6f7071d6411f99aa4b93e4867f7571112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 15 Mar 2026 18:45:17 +0100 Subject: [PATCH 237/675] fixed #14591 - store CTU function call information path with proper slashes (#8328) --- lib/ctu.cpp | 2 +- test/cli/other_test.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/ctu.cpp b/lib/ctu.cpp index 3f50dd1a485..d1be82b34fa 100644 --- a/lib/ctu.cpp +++ b/lib/ctu.cpp @@ -112,7 +112,7 @@ std::string CTU::FileInfo::FunctionCall::toXmlString() const out << ">\n"; for (const ErrorMessage::FileLocation &loc : callValuePath) out << " \n"; diff --git a/test/cli/other_test.py b/test/cli/other_test.py index ce4089c9ac4..7749ef18175 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -4234,3 +4234,41 @@ def run_and_assert_cppcheck(stdout_exp): # TODO: # - invalid error # - internalError + + +def test_ctu_function_call_path_slash(tmp_path): # #14591 + test_file = tmp_path / 'test.cpp' + with open(test_file, "w") as f: + f.write( +"""void g(T* p) +{ + *p = 0; +} + +void f(T* p) +{ + p = nullptr; + g(p); +} +""") + + build_dir = tmp_path / 'b1' + os.makedirs(build_dir) + + args = [ + '-q', + '--template=simple', + '--cppcheck-build-dir={}'.format(build_dir), + str(test_file) + ] + + exitcode, _, _ = cppcheck(args) + assert exitcode == 0 + + test_a1_file = build_dir / 'test.a1' + analyzerinfo = ElementTree.fromstring(test_a1_file.read_text()) + function_call_paths = analyzerinfo.findall('FileInfo/function-call/path') + assert len(function_call_paths) == 1 + file = function_call_paths[0].attrib['file'] + assert file + assert not '\\' in file # the path was incorrectly converted to native From 83a7e99c9a4f18b1f5ee4c0bc7bc179eb2c0a15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 15 Mar 2026 18:47:28 +0100 Subject: [PATCH 238/675] fixed #14584 - set minimum required AppleClang version to 6.0 / separated handling of `Clang` and `AppleClang` in CMake (#8257) --- cmake/compilerCheck.cmake | 8 +++++++- cmake/compilerDefinitions.cmake | 32 ++++++++++++++++++-------------- cmake/options.cmake | 4 ++++ lib/config.h | 2 ++ readme.md | 2 +- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/cmake/compilerCheck.cmake b/cmake/compilerCheck.cmake index 47c8fc1245e..c26bf9e336e 100644 --- a/cmake/compilerCheck.cmake +++ b/cmake/compilerCheck.cmake @@ -2,12 +2,18 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) message(ERROR "GCC >= 5.1 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported") endif() -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) message(ERROR "Clang >= 3.5 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported") endif() +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) + message(ERROR "AppleClang >= 6.0 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported") + endif() elseif(MSVC) if(MSVC_VERSION VERSION_LESS 1900) message(ERROR "Visual Studio >= 2015 (19.0) required - detected ${MSVC_VERSION} not supported") endif() +else() + message(WARNING "Unknown compiler ${CMAKE_CXX_COMPILER_ID}") endif() diff --git a/cmake/compilerDefinitions.cmake b/cmake/compilerDefinitions.cmake index a43073018e6..5f03b83dcee 100644 --- a/cmake/compilerDefinitions.cmake +++ b/cmake/compilerDefinitions.cmake @@ -8,26 +8,30 @@ if(MSVC) add_definitions(-DWIN32_LEAN_MEAN) endif() -# TODO: this should probably apply to the compiler and not the platform - I think it is only "broken" with MinGW -# TODO: AppleClang only has libc++ -# TODO: what about clang-cl and native Win32 clang? -if(CPPCHK_GLIBCXX_DEBUG AND UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug") - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if(USE_LIBCXX) - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18) - add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG) - else() - add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1) - endif() - # TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS? +# libstdc++-specific flags +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (NOT USE_LIBCXX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + if(CPPCHK_GLIBCXX_DEBUG AND CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-D_GLIBCXX_DEBUG) + endif() +endif() + +# TODO: what about clang-cl? +# libc++-specific flags - AppleClang only has libc++ +if ((USE_LIBCXX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if(CPPCHK_GLIBCXX_DEBUG AND CMAKE_BUILD_TYPE STREQUAL "Debug") + # TODO: determine proper version for AppleClang - current value is based on the oldest version avaialble in CI + if((CMAKE_CXX_COMPILER_ID STREQUALS "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17)) + add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG) + else() + add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1) endif() + # TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS? else() # TODO: check if this can be enabled again for Clang - also done in Makefile add_definitions(-D_GLIBCXX_DEBUG) endif() -endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND USE_LIBCXX) add_definitions(-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index 07c6f8d771d..e728d809220 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -116,6 +116,10 @@ if (NOT USE_BOOST AND USE_BOOST_INT128) endif() option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF) +if(USE_LIBCXX AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") + message(FATAL_ERROR "libc++ can only be used with a Clang-based compiler") +endif() + option(NO_UNIX_SIGNAL_HANDLING "Disable usage of Unix Signal Handling" OFF) option(NO_UNIX_BACKTRACE_SUPPORT "Disable usage of Unix Backtrace support" OFF) option(NO_WINDOWS_SEH "Disable usage of Windows SEH" OFF) diff --git a/lib/config.h b/lib/config.h index ff289569045..ca60904c5d9 100644 --- a/lib/config.h +++ b/lib/config.h @@ -96,6 +96,7 @@ # define UNUSED #endif +// TODO: AppleClang versions do not align with Clang versions - add check for proper version // warn_unused #if __has_cpp_attribute (gnu::warn_unused) || \ (defined(__clang__) && (__clang_major__ >= 15)) @@ -115,6 +116,7 @@ # define DEPRECATED #endif +// TODO: AppleClang versions do not align with Clang versions - add check for proper version // returns_nonnull #if __has_cpp_attribute (gnu::returns_nonnull) # define RET_NONNULL [[gnu::returns_nonnull]] diff --git a/readme.md b/readme.md index 9244243770a..a34dad2a57a 100644 --- a/readme.md +++ b/readme.md @@ -36,7 +36,7 @@ You can stop the script whenever you like with Ctrl C. ## Compiling -Cppcheck requires a C++ compiler with (partial) C++11 support. Minimum required versions are GCC 5.1 / Clang 3.5 / Visual Studio 2015. +Cppcheck requires a C++ compiler with (partial) C++11 support. Minimum required versions are GCC 5.1 / Clang 3.5 / AppleClang 6.0 / Visual Studio 2015. To build the GUI application, you need to use the CMake build system. From 68c91ae2c0c6a173ddf414309a920fcea1c9025f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 15 Mar 2026 18:48:06 +0100 Subject: [PATCH 239/675] fixed #14585 - store all errors in `AnalyzerInformation` even if suppressed (#8267) --- lib/cppcheck.cpp | 7 ++++++- test/cli/other_test.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 1154d55bd9f..5023a5e258e 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -177,6 +177,8 @@ class CppCheck::CppCheckLogger : public ErrorLogger // TODO: only convert if necessary const auto errorMessage = SuppressionList::ErrorMessage::fromErrorMessage(msg, macroNames); + bool suppressed = false; + if (mSuppressions.nomsg.isSuppressed(errorMessage, mUseGlobalSuppressions)) { // Safety: Report critical errors to ErrorLogger if (mSettings.safety && ErrorLogger::isCriticalErrorId(msg.id)) { @@ -193,7 +195,7 @@ class CppCheck::CppCheckLogger : public ErrorLogger mErrorLogger.reportErr(msg); } } - return; + suppressed = true; } // TODO: there should be no need for the verbose and default messages here @@ -210,6 +212,9 @@ class CppCheck::CppCheckLogger : public ErrorLogger if (mAnalyzerInformation) mAnalyzerInformation->reportErr(msg); + if (suppressed) + return; + if (!mSuppressions.nofail.isSuppressed(errorMessage) && !mSuppressions.nomsg.isSuppressed(errorMessage)) { mExitCode = 1; } diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 7749ef18175..cc8b96badf1 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -3374,6 +3374,42 @@ def test_suppress_unmatched_wildcard(tmp_path): # #13660 ] +def test_suppress_unmatched_wildcard_cached(tmp_path): # #14585 + test_file = tmp_path / 'test.c' + with open(test_file, 'wt') as f: + f.write( +"""void f() +{ + (void)(*((int*)0)); +} +""") + + build_dir = tmp_path / 'b1' + os.makedirs(build_dir) + + # need to run in the temporary folder because the path of the suppression has to match + args = [ + '-q', + '--template=simple', + '--enable=information', + '--cppcheck-build-dir={}'.format(build_dir), + '--suppress=nullPointer:test*.c', + 'test.c' + ] + + stderr_exp = [] + + exitcode, stdout, stderr = cppcheck(args, cwd=tmp_path) + assert exitcode == 0, stdout + assert stdout.splitlines() == [] + assert stderr.splitlines() == stderr_exp + + exitcode, stdout, stderr = cppcheck(args, cwd=tmp_path) + assert exitcode == 0, stdout + assert stdout.splitlines() == [] + assert stderr.splitlines() == stderr_exp + + def test_suppress_unmatched_wildcard_unchecked(tmp_path): # make sure that unmatched wildcards suppressions are reported if files matching the expressions were processesd # but isSuppressed() has never been called (i.e. no findings in file at all) From 504b33381b1a325c64b1ff07b24c3455661fdbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Mon, 16 Mar 2026 08:03:19 +0100 Subject: [PATCH 240/675] Fix #14567: internalAstError for requires expression with parameter list (#8309) --- lib/tokenlist.cpp | 5 ++++- test/testtokenize.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 0ffcf7e37e4..a46fad5d021 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1055,7 +1055,10 @@ static void compilePrecedence2(Token *&tok, AST_state& state) else compileUnaryOp(tok, state, compileExpression); tok = tok2->link()->next(); - } else if (Token::simpleMatch(tok->previous(), "requires {")) { + } else if (Token::simpleMatch(tok->previous(), "requires {") + || (Token::simpleMatch(tok->previous(), ")") + && tok->linkAt(-1) + && Token::simpleMatch(tok->linkAt(-1)->previous(), "requires ("))) { tok->astOperand1(state.op.top()); state.op.pop(); state.op.push(tok); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index e59f7b3be62..eefc0b8aba0 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7147,6 +7147,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("crequires{ac::||= a{b{||", testAst("template concept c = requires { a{} || b{}; } || a::c;")); ASSERT_EQUALS("ifrequires{(", testAst("if (requires { true; }) {}")); // #13308 + ASSERT_EQUALS("Crequires({requires({||= sizeofT(4== sizeofT(8==", testAst("concept C = requires() { sizeof(T) == 4; } || requires() { sizeof(T) == 8; };")); } void astcast() { From 36b8eb5a2d31409d3670040cc581c2fda3c302ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Mon, 16 Mar 2026 08:04:22 +0100 Subject: [PATCH 241/675] Partial fix for #14576: Missing attribute alignas (#8305) --- lib/tokenize.cpp | 11 ++++++++++- test/testtokenize.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 193fa5bbb4d..8ad49dedd37 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9761,10 +9761,19 @@ void Tokenizer::simplifyCPPAttribute() Token* atok = nullptr; if (Token::Match(tok->previous(), "%name%")) atok = tok->previous(); - else { + else if (Token::simpleMatch(tok->previous(), "]")) { + atok = tok; + while (atok && Token::simpleMatch(atok->previous(), "]")) { + atok = atok->linkAt(-1); + atok = atok ? atok->previous() : nullptr; + } + if (!Token::Match(atok, "%name%")) + atok = nullptr; + } else { atok = tok; while (isCPPAttribute(atok) || isAlignAttribute(atok)) atok = skipCPPOrAlignAttribute(atok)->next(); + atok = atok ? getVariableTokenAfterAttributes(atok) : atok; } if (atok) { std::string a; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index eefc0b8aba0..16c9335dce7 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -284,6 +284,9 @@ class TestTokenizer : public TestFixture { TEST_CASE(cppMaybeUnusedAfter2); TEST_CASE(cppMaybeUnusedStructuredBinding); + TEST_CASE(attributeAlignasBefore); + TEST_CASE(attributeAlignasAfter); + TEST_CASE(splitTemplateRightAngleBrackets); TEST_CASE(cpp03template1); @@ -4332,6 +4335,35 @@ class TestTokenizer : public TestFixture { ASSERT(var2 && var2->isAttributeMaybeUnused()); } + void attributeAlignasBefore() { + const char code[] = "alignas(long) unsigned char buffer[sizeof(long)];"; + const char expected[] = "char buffer [ sizeof ( long ) ] ;"; + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); + + ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); + + const Token *var = Token::findsimplematch(tokenizer.tokens(), "buffer"); + ASSERT(var); + ASSERT(var->hasAttributeAlignas()); + ASSERT(var->getAttributeAlignas().size() == 1); + ASSERT_EQUALS(var->getAttributeAlignas()[0], "long"); + } + + void attributeAlignasAfter() { + const char code[] = "unsigned char buffer[sizeof(long)] alignas(long);"; + const char expected[] = "char buffer [ sizeof ( long ) ] ;"; + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); + + ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); + + const Token *var = Token::findsimplematch(tokenizer.tokens(), "buffer"); + ASSERT(var); + ASSERT(var->hasAttributeAlignas()); + ASSERT(var->getAttributeAlignas().size() == 1); + ASSERT_EQUALS(var->getAttributeAlignas()[0], "long"); + } void splitTemplateRightAngleBrackets() { { From 1d1f7478a21f97633eec28d40d63a4fa23df4261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 16 Mar 2026 14:45:11 +0100 Subject: [PATCH 242/675] refs #14593 - improved string concatenation in `ScopeInfo3` constructor (#8334) --- lib/tokenize.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 8ad49dedd37..a371df76e5d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2418,7 +2418,8 @@ namespace { while (scope && scope->parent) { if (scope->name.empty()) break; - fullName = scope->name + " :: " + fullName; + fullName.insert(0, " :: "); + fullName.insert(0, scope->name); scope = scope->parent; } } From 8cb66cf41c5385276984d36c1e408af95a27c9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 16 Mar 2026 16:30:08 +0100 Subject: [PATCH 243/675] updated CI to Clang 22 - again (#8342) --- .clang-tidy | 12 ++++++++++-- .github/workflows/asan.yml | 6 +++--- .github/workflows/clang-tidy.yml | 10 +++++----- .github/workflows/iwyu.yml | 12 ++++++------ .github/workflows/tsan.yml | 6 +++--- .github/workflows/ubsan.yml | 6 +++--- clang-tidy.md | 13 +++++++++++++ cmake/clang_tidy.cmake | 6 ++++++ cmake/compileroptions.cmake | 6 ++++++ lib/vf_common.cpp | 2 +- test/testcheckersreport.cpp | 2 +- tools/triage/mainwindow.cpp | 1 + 12 files changed, 58 insertions(+), 24 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 91173d82e10..b83436861bd 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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, @@ -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, @@ -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, @@ -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 diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 977d3f05337..38e90cb760a 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -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 @@ -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: | diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 00a4ee7d332..c4f8cc0cf6b 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -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 @@ -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: | diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 7a7d5c8d500..fa9be0cbba8 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -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 @@ -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: | @@ -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() diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml index 0e78566faae..72b1764d11d 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 21 + sudo ./llvm.sh 22 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -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: | diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index 66c56b6966a..5afc5feb1f9 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 21 + sudo ./llvm.sh 22 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 @@ -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: | diff --git a/clang-tidy.md b/clang-tidy.md index aae6918e372..e6180b53d62 100644 --- a/clang-tidy.md +++ b/clang-tidy.md @@ -133,6 +133,7 @@ Does not improve the readability. `misc-unconventional-assign-operator`
`bugprone-throwing-static-initialization`
`bugprone-command-processor`
+`misc-multiple-inheritance`
To be evaluated (need to remove exclusion). @@ -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`
+ +The suggestions are too intrusive. + +`modernize-avoid-c-style-cast`
+ +Currently flags functional casts - see https://github.com/llvm/llvm-project/issues/186784. + +`misc-use-internal-linkage.AnalyzeTypes`
+ +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`
diff --git a/cmake/clang_tidy.cmake b/cmake/clang_tidy.cmake index a192fc13320..f8324b98d21 100644 --- a/cmake/clang_tidy.cmake +++ b/cmake/clang_tidy.cmake @@ -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 diff --git a/cmake/compileroptions.cmake b/cmake/compileroptions.cmake index 348ad9f2674..aa7deb8552c 100644 --- a/cmake/compileroptions.cmake +++ b/cmake/compileroptions.cmake @@ -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() diff --git a/lib/vf_common.cpp b/lib/vf_common.cpp index 934757edea4..46059985b0b 100644 --- a/lib/vf_common.cpp +++ b/lib/vf_common.cpp @@ -101,7 +101,7 @@ namespace ValueFlow return value; const MathLib::biguint unsignedMaxValue = std::numeric_limits::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; diff --git a/test/testcheckersreport.cpp b/test/testcheckersreport.cpp index 2d539ee77cf..85ef3547fd5 100644 --- a/test/testcheckersreport.cpp +++ b/test/testcheckersreport.cpp @@ -28,7 +28,7 @@ class TestCheckersReport : public TestFixture { public: TestCheckersReport() : TestFixture("TestCheckersReport") {} - +private: void run() final { // AddonInfo::checkers TEST_CASE(addonInfoCheckers); diff --git a/tools/triage/mainwindow.cpp b/tools/triage/mainwindow.cpp index ce95ff82d8d..8e5e4d39020 100644 --- a/tools/triage/mainwindow.cpp +++ b/tools/triage/mainwindow.cpp @@ -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(std::time(nullptr))); QDir workFolder(WORK_FOLDER); if (!workFolder.exists()) { From b52fd4803b890a67467a49a820f7ac5f91601697 Mon Sep 17 00:00:00 2001 From: olabetskyi <153490942+olabetskyi@users.noreply.github.com> Date: Tue, 17 Mar 2026 18:11:35 +0200 Subject: [PATCH 244/675] Fix #14606: Crash in Gui (#8346) --- gui/checkthread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index fa5d68ba6d6..07ca4e77ed2 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -170,7 +170,7 @@ void CheckThread::run() const Details details{ mThreadIndex, QString::fromStdString(fname), QTime::currentTime(), }; emit startCheck(details); - cppcheck.check(*file); + cppcheck.check(*fileSettings); runAddonsAndTools(mSettings, fileSettings, QString::fromStdString(fname)); emit finishCheck(details); From b17b4edb2963d77ccafd803db077492999ae3e3c Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Thu, 19 Mar 2026 04:40:02 -0500 Subject: [PATCH 245/675] Disable matchcompiler on old python versions (#8352) --- cmake/findDependencies.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index ddfef6718c2..b1f6571504d 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -49,7 +49,8 @@ if(NOT Python_Interpreter_FOUND) endif() else() if(${Python_VERSION} VERSION_LESS 3.7) - message(FATAL_ERROR "The minimum supported Python version is 3.7 - found ${Python_VERSION}") + message(WARNING "The minimum supported Python version is 3.7, found ${Python_VERSION} - disabling matchcompiler.") + set(USE_MATCHCOMPILER_OPT "Off") endif() endif() From 3a7e382990c0366d6cd956b1103422b18b35399c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 19 Mar 2026 10:40:53 +0100 Subject: [PATCH 246/675] Fix #11498 debug: Failed to parse 'x'. The checking continues anyway. (#8345) --- lib/tokenlist.cpp | 3 +++ test/testsimplifytemplate.cpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index a46fad5d021..7f7ca25aa5c 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -198,6 +198,7 @@ void TokenList::addtoken(const Token * tok, const nonneg int lineno, const nonne mTokensFrontBack->back->column(column); mTokensFrontBack->back->fileIndex(fileno); mTokensFrontBack->back->flags(tok->flags()); + mTokensFrontBack->back->tokType(tok->tokType()); } void TokenList::addtoken(const Token *tok, const Token *locationTok) @@ -219,6 +220,7 @@ void TokenList::addtoken(const Token *tok, const Token *locationTok) mTokensFrontBack->back->linenr(locationTok->linenr()); mTokensFrontBack->back->column(locationTok->column()); mTokensFrontBack->back->fileIndex(locationTok->fileIndex()); + mTokensFrontBack->back->tokType(tok->tokType()); } void TokenList::addtoken(const Token *tok) @@ -242,6 +244,7 @@ void TokenList::addtoken(const Token *tok) mTokensFrontBack->back->linenr(tok->linenr()); mTokensFrontBack->back->column(tok->column()); mTokensFrontBack->back->fileIndex(tok->fileIndex()); + mTokensFrontBack->back->tokType(tok->tokType()); } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 2dda926fb40..66b2e022679 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -224,6 +224,7 @@ class TestSimplifyTemplate : public TestFixture { TEST_CASE(template180); TEST_CASE(template181); TEST_CASE(template182); // #13770 + TEST_CASE(template183); TEST_CASE(template_specialization_1); // #7868 - template specialization template struct S> {..}; TEST_CASE(template_specialization_2); // #7868 - template specialization template struct S> {..}; TEST_CASE(template_specialization_3); @@ -4678,6 +4679,25 @@ class TestSimplifyTemplate : public TestFixture { ASSERT_EQUALS(exp, tok(code)); } + void template183() { // #11498 + const char code[] = "template \n" + "struct S {\n" + " void f();\n" + " using X = decltype(&S::f);\n" + "private:\n" + " X x;\n" + "};\n" + "S s;\n"; + const char exp[] = "struct S ; " + "S s ; " + "struct S { " + "void f ( ) ; " + "private: " + "decltype ( & S :: f ) x ; " + "} ;"; + ASSERT_EQUALS(exp, tok(code)); + } + void template_specialization_1() { // #7868 - template specialization template struct S> {..}; const char code[] = "template struct C {};\n" "template struct S {a};\n" From 8119a9d99211a63089258ada082e6bffad8337ec Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 19 Mar 2026 18:31:50 +0100 Subject: [PATCH 247/675] Fix #13305 FN moduloofone with %= (#8353) --- lib/checkother.cpp | 2 +- test/testother.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index f051d231b69..698ef62e78b 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -4429,7 +4429,7 @@ void CheckOther::checkModuloOfOne() for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) { if (!tok->astOperand2() || !tok->astOperand1()) continue; - if (tok->str() != "%") + if (tok->str() != "%" && tok->str() != "%=") continue; if (!tok->valueType() || !tok->valueType()->isIntegral()) continue; diff --git a/test/testother.cpp b/test/testother.cpp index 241a7512000..d2f57bbb2a4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -13284,6 +13284,13 @@ class TestOther : public TestFixture { " if (j % c) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void f() {\n" + " int i = 0;\n" + " i %= 1;\n" + " (void)i;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:7]: (style) Modulo of one is always equal to zero [moduloofone]\n", errout_str()); } void sameExpressionPointers() { From 44128339d43824960341cb619053f7b42517d5ed Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 20 Mar 2026 08:27:05 +0100 Subject: [PATCH 248/675] Fix #14612 Internal error: "Cannot find end of expression" (#8354) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a371df76e5d..20e3c6231f5 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5544,7 +5544,7 @@ void Tokenizer::createLinks2() while (!type.empty() && type.top()->str() == "<") { const Token* end = type.top()->findClosingBracket(); - if (Token::Match(end, "> %comp%|;|.|=|{|(|::")) + if (Token::Match(end, "> %comp%|;|.|=|{|(|)|::")) break; // Variable declaration if (Token::Match(end, "> %var% ;") && (type.top()->tokAt(-2) == nullptr || Token::Match(type.top()->tokAt(-2), ";|}|{"))) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 16c9335dce7..dea8d08e57f 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -3829,6 +3829,19 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(true, tok1->link() == tok2); ASSERT_EQUALS(true, tok2->link() == tok1); } + + { + const char code[] = "template \n" // #14612 + "void f(Fn && fn, Args&&... args) {\n" + " static_assert(std::is_invocable_v);\n" + "}\n"; + SimpleTokenizer tokenizer(settings0, *this); + ASSERT(tokenizer.tokenize(code)); + const Token* tok1 = Token::findsimplematch(tokenizer.tokens(), "< Fn"); + const Token* tok2 = Token::findsimplematch(tok1, "> )"); + ASSERT_EQUALS(true, tok1->link() == tok2); + ASSERT_EQUALS(true, tok2->link() == tok1); + } } void simplifyString() { From 0900f6400f94e8817968f0e5395d905cc33039d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 20 Mar 2026 14:01:55 +0100 Subject: [PATCH 249/675] fixed #13792 - release-windows.yml: use latest Python version [skip ci] (#8332) --- .github/workflows/release-windows.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 1caa87b61e5..607c8434baa 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -25,6 +25,7 @@ jobs: if: ${{ github.repository_owner == 'danmar' }} env: + PYTHON_VERSION: 3.14 # see https://www.pcre.org/original/changelog.txt PCRE_VERSION: 8.45 QT_VERSION: 6.10.0 @@ -35,6 +36,12 @@ jobs: with: persist-credentials: false + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + check-latest: true + - name: Set up Visual Studio environment uses: ilammy/msvc-dev-cmd@v1 From 0a07f76bf782a743156c70584b7f206da0a666e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 20 Mar 2026 14:03:53 +0100 Subject: [PATCH 250/675] refs #14599 - Tokenizer: use `TimerResultsIntf` (#8348) --- lib/tokenize.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tokenize.h b/lib/tokenize.h index 23669be7225..94f08f9f68e 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -34,7 +34,7 @@ class Settings; class SymbolDatabase; -class TimerResults; +class TimerResultsIntf; class Token; class TemplateSimplifier; class ErrorLogger; @@ -53,7 +53,7 @@ class CPPCHECKLIB Tokenizer { Tokenizer(TokenList tokenList, ErrorLogger &errorLogger); ~Tokenizer(); - void setTimerResults(TimerResults *tr) { + void setTimerResults(TimerResultsIntf *tr) { mTimerResults = tr; } @@ -713,9 +713,9 @@ class CPPCHECKLIB Tokenizer { nonneg int mUnnamedCount{}; /** - * TimerResults + * timer results */ - TimerResults* mTimerResults{}; + TimerResultsIntf* mTimerResults{}; }; /// @} From 498b2c6e428591fe1e3872b6c3848feb2f01e8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 20 Mar 2026 14:07:58 +0100 Subject: [PATCH 251/675] refs #14599/#4452 - test/cli/other_test.py: improved `--showtime` tests (#8337) --- test/cli/other_test.py | 94 +++++++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 19 deletions(-) diff --git a/test/cli/other_test.py b/test/cli/other_test.py index cc8b96badf1..2ff65efc052 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -954,33 +954,89 @@ def test_unused_function_include(tmpdir): __test_unused_function_include(tmpdir, []) -# TODO: test with all other types -def test_showtime_top5_file(tmpdir): - test_file = os.path.join(tmpdir, 'test.cpp') +# TODO: test with multiple files +def __test_showtime(tmp_path, showtime, exp_len, exp_last, extra_args=None): + test_file = tmp_path / 'test.cpp' with open(test_file, 'wt') as f: - f.write(""" - int main(int argc) - { - } - """) + f.write( +""" +void f() +{ + (void)(*((int*)0)); // cppcheck-suppress nullPointer +} +""") + + args = [ + f'--showtime={showtime}', + '--quiet', + '--inline-suppr', + str(test_file) + ] - args = ['--showtime=top5_file', '--quiet', test_file] + if extra_args: + args += extra_args exitcode, stdout, stderr = cppcheck(args) - assert exitcode == 0 # TODO: needs to be 1 + assert exitcode == 0 lines = stdout.splitlines() - assert len(lines) == 7 - assert lines[0] == '' - for i in range(1, 5): - if lines[i].startswith('valueFlowLifetime'): - assert lines[i].endswith(' - 2 result(s))') - elif lines[i].startswith('valueFlowEnumValue'): - assert lines[i].endswith(' - 2 result(s))') - else: - assert lines[i].endswith(' result(s))') + if 'cppcheck internal API usage' in stdout: + exp_len += 1 + assert len(lines) == exp_len + idx_last = exp_len-1 + if idx_last: + assert lines[0] == '' + for i in range(1, idx_last): + assert 'avg.' in lines[i] + assert lines[idx_last].startswith(exp_last) assert stderr == '' +def test_showtime_top5_file(tmp_path): + __test_showtime(tmp_path, 'top5_file', 7, 'Check time: ') + + +# TODO: remove extra args when --executor=process works works +def test_showtime_top5_summary(tmp_path): + __test_showtime(tmp_path, 'top5_summary', 7, 'Overall time: ', ['-j1']) + + +# TODO: remove when --executor=process works works +def test_showtime_top5_summary_j_thread(tmp_path): + __test_showtime(tmp_path, 'top5_summary', 7, 'Overall time: ', ['-j2', '--executor=thread']) + + +# TODO: remove override when fixed +@pytest.mark.skipif(sys.platform == 'win32', reason="requires ProcessExecutor") +@pytest.mark.xfail(strict=True) # TODO: need to transfer the timer results to parent process - see #4452 +def test_showtime_top5_summary_j_process(tmp_path): + __test_showtime(tmp_path, 'top5_summary', 7, 'Overall time: ', ['-j2', '--executor=process']) + + +def test_showtime_file(tmp_path): + __test_showtime(tmp_path, 'file', 79, 'Check time: ') + + +# TODO: remove extra args when --executor=process works works +def test_showtime_summary(tmp_path): + __test_showtime(tmp_path, 'summary', 79, 'Overall time: ', ['-j1']) + + +# TODO: remove when --executor=process works works +def test_showtime_summary_j_thread(tmp_path): + __test_showtime(tmp_path, 'summary', 79, 'Overall time: ', ['-j2', '--executor=thread']) + + +# TODO: remove override when fixed +@pytest.mark.skipif(sys.platform == 'win32', reason="requires ProcessExecutor") +@pytest.mark.xfail(strict=True) # TODO: need to transfer the timer results to parent process - see #4452 +def test_showtime_summary_j_process(tmp_path): + __test_showtime(tmp_path, 'summary', 79, 'Overall time: ', ['-j2', '--executor=process']) + + +def test_showtime_file_total(tmp_path): + __test_showtime(tmp_path, 'file-total', 1, 'Check time: ') + + def test_missing_addon(tmpdir): args = ['--addon=misra3', '--addon=misra', '--addon=misra2', 'file.c'] From c331d49373edd1f379af75b39e940eb824501e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 22 Mar 2026 18:01:30 +0100 Subject: [PATCH 252/675] prevent unnecessary `utils::as_const()` calls (#8316) --- cli/signalhandler.cpp | 2 +- lib/checkleakautovar.cpp | 2 +- lib/ctu.cpp | 2 +- lib/library.cpp | 6 +++--- lib/library.h | 8 ++++---- lib/settings.cpp | 12 ++++++------ lib/symboldatabase.cpp | 16 ++++++++-------- lib/tokenize.cpp | 12 ++++++------ lib/utils.h | 1 + 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/cli/signalhandler.cpp b/cli/signalhandler.cpp index 88864efd743..e1ea7f31267 100644 --- a/cli/signalhandler.cpp +++ b/cli/signalhandler.cpp @@ -124,7 +124,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) / killid = getpid(); #endif - const auto it = utils::as_const(listofsignals).find(signo); + const auto it = listofsignals.find(signo); const char * const signame = (it==listofsignals.end()) ? "unknown" : it->second.c_str(); bool unexpectedSignal=true; // unexpected indicates program failure bool terminate=true; // exit process/thread diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 00c8492498a..bb80ead84a5 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -1163,7 +1163,7 @@ void CheckLeakAutoVar::leakIfAllocated(const Token *vartok, const std::map &alloctype = varInfo.alloctype; const auto& possibleUsage = varInfo.possibleUsage; - const auto var = utils::as_const(alloctype).find(vartok->varId()); + const auto var = alloctype.find(vartok->varId()); if (var != alloctype.cend() && var->second.status == VarInfo::ALLOC) { const auto use = possibleUsage.find(vartok->varId()); if (use == possibleUsage.end()) { diff --git a/lib/ctu.cpp b/lib/ctu.cpp index d1be82b34fa..938bb2a4dcc 100644 --- a/lib/ctu.cpp +++ b/lib/ctu.cpp @@ -512,7 +512,7 @@ static bool findPath(const std::string &callId, if (index >= maxCtuDepth) return false; // TODO: add bailout message? - const auto it = utils::as_const(callsMap).find(callId); + const auto it = callsMap.find(callId); if (it == callsMap.end()) return false; diff --git a/lib/library.cpp b/lib/library.cpp index 1628cc3cdcd..bd4a62d0a42 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -46,7 +46,7 @@ struct Library::LibraryData { struct Platform { const PlatformType *platform_type(const std::string &name) const { - const auto it = utils::as_const(mPlatformTypes).find(name); + const auto it = mPlatformTypes.find(name); return (it != mPlatformTypes.end()) ? &(it->second) : nullptr; } std::map mPlatformTypes; @@ -1323,10 +1323,10 @@ const Library::ArgumentChecks * Library::getarg(const Token *ftok, int argnr) co const Function* func = nullptr; if (isNotLibraryFunction(ftok, &func)) return nullptr; - const auto it2 = utils::as_const(func->argumentChecks).find(argnr); + const auto it2 = func->argumentChecks.find(argnr); if (it2 != func->argumentChecks.cend()) return &it2->second; - const auto it3 = utils::as_const(func->argumentChecks).find(-1); + const auto it3 = func->argumentChecks.find(-1); if (it3 != func->argumentChecks.cend()) return &it3->second; return nullptr; diff --git a/lib/library.h b/lib/library.h index dea9c1e66c7..10b9463cbaa 100644 --- a/lib/library.h +++ b/lib/library.h @@ -242,21 +242,21 @@ class CPPCHECKLIB Library { bool startPatternHasStd{}; Action getAction(const std::string& function) const { - const auto i = utils::as_const(functions).find(function); + const auto i = functions.find(function); if (i != functions.end()) return i->second.action; return Action::NO_ACTION; } Yield getYield(const std::string& function) const { - const auto i = utils::as_const(functions).find(function); + const auto i = functions.find(function); if (i != functions.end()) return i->second.yield; return Yield::NO_YIELD; } const std::string& getReturnType(const std::string& function) const { - const auto i = utils::as_const(functions).find(function); + const auto i = functions.find(function); return (i != functions.end()) ? i->second.returnType : mEmptyString; } @@ -482,7 +482,7 @@ class CPPCHECKLIB Library { std::string getFunctionName(const Token *ftok, bool &error) const; static const AllocFunc* getAllocDealloc(const std::map &data, const std::string &name) { - const auto it = utils::as_const(data).find(name); + const auto it = data.find(name); return (it == data.end()) ? nullptr : &it->second; } diff --git a/lib/settings.cpp b/lib/settings.cpp index 645488260b0..cd1f094e1c1 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -109,7 +109,7 @@ std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppress } const picojson::object& obj = json.get(); { - const auto it = utils::as_const(obj).find("productName"); + const auto it = obj.find("productName"); if (it != obj.cend()) { const auto& v = it->second; if (!v.is()) @@ -118,7 +118,7 @@ std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppress } } { - const auto it = utils::as_const(obj).find("manualUrl"); + const auto it = obj.find("manualUrl"); if (it != obj.cend()) { const auto& v = it->second; if (!v.is()) @@ -127,7 +127,7 @@ std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppress } } { - const auto it = utils::as_const(obj).find("about"); + const auto it = obj.find("about"); if (it != obj.cend()) { const auto& v = it->second; if (!v.is()) @@ -136,7 +136,7 @@ std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppress } } { - const auto it = utils::as_const(obj).find("addons"); + const auto it = obj.find("addons"); if (it != obj.cend()) { const auto& entry = it->second; if (!entry.is()) @@ -154,7 +154,7 @@ std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppress } } { - const auto it = utils::as_const(obj).find("suppressions"); + const auto it = obj.find("suppressions"); if (it != obj.cend()) { const auto& entry = it->second; if (!entry.is()) @@ -171,7 +171,7 @@ std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppress } } { - const auto it = utils::as_const(obj).find("safety"); + const auto it = obj.find("safety"); if (it != obj.cend()) { const auto& v = it->second; if (!v.is()) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 9748959ba53..c9851d6e7ca 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3864,7 +3864,7 @@ void SymbolDatabase::returnImplicitIntError(const Token *tok) const const Function* Type::getFunction(const std::string& funcName) const { if (classScope) { - const auto it = utils::as_const(classScope->functionMap).find(funcName); + const auto it = classScope->functionMap.find(funcName); if (it != classScope->functionMap.end()) return it->second; } @@ -4838,7 +4838,7 @@ std::vector Function::getOverloadedFunctions() const while (scope) { const bool isMemberFunction = scope->isClassOrStruct() && !isStatic(); - for (auto it = utils::as_const(scope->functionMap).find(tokenDef->str()); + for (auto it = scope->functionMap.find(tokenDef->str()); it != scope->functionMap.end() && it->first == tokenDef->str(); ++it) { const Function* func = it->second; @@ -4889,7 +4889,7 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType const Scope *parent = derivedFromType->classScope; // check if function defined in base class - auto range = utils::as_const(parent->functionMap).equal_range(tokenDef->str()); + auto range = parent->functionMap.equal_range(tokenDef->str()); for (auto it = range.first; it != range.second; ++it) { const Function * func = it->second; if (func->isImplicitlyVirtual()) { // Base is virtual and of same name @@ -5836,7 +5836,7 @@ void Scope::findFunctionInBase(const Token* tok, nonneg int args, std::vectorclassScope == this) // Ticket #5120, #5125: Recursive class; tok should have been found already continue; - auto range = utils::as_const(base->classScope->functionMap).equal_range(tok->str()); + auto range = base->classScope->functionMap.equal_range(tok->str()); for (auto it = range.first; it != range.second; ++it) { const Function *func = it->second; if (func->isDestructor() && !Token::simpleMatch(tok->tokAt(-1), "~")) @@ -5998,7 +5998,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst, Referen const std::size_t args = arguments.size(); auto addMatchingFunctions = [&](const Scope *scope) { - auto range = utils::as_const(scope->functionMap).equal_range(tok->str()); + auto range = scope->functionMap.equal_range(tok->str()); for (auto it = range.first; it != range.second; ++it) { const Function *func = it->second; if (ref == Reference::LValue && func->hasRvalRefQualifier()) @@ -6766,7 +6766,7 @@ Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *n const Function * function = nullptr; const bool destructor = func->strAt(-1) == "~"; - auto range = utils::as_const(ns->functionMap).equal_range(func->str()); + auto range = ns->functionMap.equal_range(func->str()); for (auto it = range.first; it != range.second; ++it) { if (it->second->argsMatch(ns, it->second->argDef, func->next(), path, path_length) && it->second->isDestructor() == destructor) { @@ -7685,14 +7685,14 @@ static const Function *getOperatorFunction(const Token * const tok) const Scope *classScope = getClassScope(tok->astOperand1()); if (classScope) { - auto it = utils::as_const(classScope->functionMap).find(functionName); + auto it = classScope->functionMap.find(functionName); if (it != classScope->functionMap.end()) return it->second; } classScope = getClassScope(tok->astOperand2()); if (classScope) { - auto it = utils::as_const(classScope->functionMap).find(functionName); + auto it = classScope->functionMap.find(functionName); if (it != classScope->functionMap.end()) return it->second; } diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 20e3c6231f5..b485b3fb2cc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -135,7 +135,7 @@ Tokenizer::~Tokenizer() nonneg int Tokenizer::sizeOfType(const std::string& type) const { - const auto it = utils::as_const(mTypeSize).find(type); + const auto it = mTypeSize.find(type); if (it == mTypeSize.end()) { const Library::PodType* podtype = mSettings.library.podtype(type); if (!podtype) @@ -154,7 +154,7 @@ nonneg int Tokenizer::sizeOfType(const Token *type) const if (type->tokType() == Token::eString) return Token::getStrLength(type) + 1U; - const auto it = utils::as_const(mTypeSize).find(type->str()); + const auto it = mTypeSize.find(type->str()); if (it == mTypeSize.end()) { const Library::PodType* podtype = mSettings.library.podtype(type->str()); if (!podtype) @@ -4630,7 +4630,7 @@ void Tokenizer::setVarIdClassFunction(const std::string &classname, if (Token::Match(tok2, "%name% ::")) continue; - const auto it = utils::as_const(varlist).find(tok2->str()); + const auto it = varlist.find(tok2->str()); if (it != varlist.end()) { tok2->varId(it->second); setVarIdStructMembers(tok2, structMembers, varId_); @@ -7800,7 +7800,7 @@ bool Tokenizer::simplifyCAlternativeTokens() if (!tok->isName()) continue; - const auto cOpIt = utils::as_const(cAlternativeTokens).find(tok->str()); + const auto cOpIt = cAlternativeTokens.find(tok->str()); if (cOpIt != cAlternativeTokens.end()) { alt.push_back(tok); @@ -7842,7 +7842,7 @@ bool Tokenizer::simplifyCAlternativeTokens() return false; for (Token *tok: alt) { - const auto cOpIt = utils::as_const(cAlternativeTokens).find(tok->str()); + const auto cOpIt = cAlternativeTokens.find(tok->str()); if (cOpIt != cAlternativeTokens.end()) tok->str(cOpIt->second); else if (tok->str() == "not") @@ -10452,7 +10452,7 @@ void Tokenizer::simplifyMicrosoftStringFunctions() if (tok->strAt(1) != "(") continue; - const auto match = utils::as_const(apis).find(tok->str()); + const auto match = apis.find(tok->str()); if (match!=apis.end()) { tok->str(ansi ? match->second.mbcs : match->second.unicode); tok->originalName(match->first); diff --git a/lib/utils.h b/lib/utils.h index 5a6927a5d96..6f410af3dbc 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -418,6 +418,7 @@ namespace utils { template constexpr typename std::add_const::type & as_const(T& t) noexcept { + static_assert(!std::is_const::value, "object is already const"); // NOLINTNEXTLINE(bugprone-return-const-ref-from-parameter) - potential false positive return t; } From bb948d2368918fca257b07a69d0db56ad53a6d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 23 Mar 2026 11:15:43 +0100 Subject: [PATCH 253/675] TestTokenizer: reduced amount of `settingsBuilder().build()` calls (#8367) --- test/testtokenize.cpp | 155 ++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 82 deletions(-) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index dea8d08e57f..f78899820b2 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -47,10 +47,17 @@ class TestTokenizer : public TestFixture { private: const Settings settings0 = settingsBuilder().library("qt.cfg").build(); - const Settings settings1 = settingsBuilder().library("qt.cfg").library("std.cfg").debugwarnings().build(); + const Settings settings1 = settingsBuilder().library("std.cfg").library("qt.cfg").debugwarnings().build(); const Settings settings2 = settingsBuilder(settings1).cpp(Standards::CPP11).c(Standards::C11).build(); + const Settings settings2_win32a = settingsBuilder(settings2).platform(Platform::Type::Win32A).build(); + const Settings settings2_win32w = settingsBuilder(settings2).platform(Platform::Type::Win32W).build(); + const Settings settings2_win64 = settingsBuilder(settings2).platform(Platform::Type::Win64).build(); + const Settings settings2_unix32 = settingsBuilder(settings2).platform(Platform::Type::Unix32).build(); + const Settings settings2_unix64 = settingsBuilder(settings2).platform(Platform::Type::Unix64).build(); const Settings settings3 = settingsBuilder(settings0).c(Standards::C89).cpp(Standards::CPP03).build(); const Settings settings_windows = settingsBuilder().library("windows.cfg").debugwarnings().cpp(Standards::CPP11).build(); + const Settings settings_win32a = settingsBuilder(settings_windows).platform(Platform::Type::Win32A).build(); + const Settings settings_win32w = settingsBuilder(settings_windows).platform(Platform::Type::Win32W).build(); void run() override { mNewTemplate = true; @@ -535,19 +542,14 @@ class TestTokenizer : public TestFixture { struct TokenizeOptions { bool expand = true; - Platform::Type platform = Platform::Type::Native; bool cpp = true; - Standards::cppstd_t cppstd = Standards::CPP11; - Standards::cstd_t cstd = Standards::C11; }; #define tokenizeAndStringify(...) tokenizeAndStringify_(__FILE__, __LINE__, __VA_ARGS__) template std::string tokenizeAndStringify_(const char* file, int linenr, const char (&code)[size], const TokenizeOptions& opt = make_default_obj{}) { - const Settings settings = settingsBuilder(settings1).cpp(opt.cppstd).c(opt.cstd).platform(opt.platform).build(); - // tokenize.. - SimpleTokenizer tokenizer(settings, *this, opt.cpp); + SimpleTokenizer tokenizer(settings2, *this, opt.cpp); ASSERT_LOC(tokenizer.tokenize(code), file, linenr); if (tokenizer.tokens()) @@ -566,27 +568,13 @@ class TestTokenizer : public TestFixture { } template - std::string tokenizeAndStringify_(const char* file, int line, const char (&code)[size], const Settings &settings, bool cpp = true) { + std::string tokenizeAndStringify_(const char* file, int line, const char (&code)[size], const Settings &settings, bool cpp = true, bool expand = true) { // tokenize.. SimpleTokenizer tokenizer(settings, *this, cpp); ASSERT_LOC(tokenizer.tokenize(code), file, line); if (!tokenizer.tokens()) return ""; - return tokenizer.tokens()->stringifyList(false, true, false, true, false, nullptr, nullptr); - } - -#define tokenizeAndStringifyWindows(...) tokenizeAndStringifyWindows_(__FILE__, __LINE__, __VA_ARGS__) - template - std::string tokenizeAndStringifyWindows_(const char* file, int linenr, const char (&code)[size], Platform::Type platform = Platform::Type::Native) { - const Settings settings = settingsBuilder(settings_windows).platform(platform).build(); - - // tokenize.. - SimpleTokenizer tokenizer(settings, *this); - ASSERT_LOC(tokenizer.tokenize(code), file, linenr); - - if (tokenizer.tokens()) - return tokenizer.tokens()->stringifyList(false, true, false, true, false, nullptr, nullptr); - return ""; + return tokenizer.tokens()->stringifyList(false, expand, false, true, false, nullptr, nullptr); } #define tokenizeDebugListing(...) tokenizeDebugListing_(__FILE__, __LINE__, __VA_ARGS__) @@ -2032,7 +2020,7 @@ class TestTokenizer : public TestFixture { const char code[] = "struct foo {\n" " void operator delete(void *obj, size_t sz);\n" "}\n"; - const std::string actual(tokenizeAndStringify(code, dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + const std::string actual(tokenizeAndStringify(code, settings2_win32a)); const char expected[] = "struct foo {\n" "void operatordelete ( void * obj , unsigned long sz ) ;\n" @@ -2568,8 +2556,9 @@ class TestTokenizer : public TestFixture { } void vardecl14() { + const Settings s = settingsBuilder(settings1).cpp(Standards::CPP03).build(); const char code[] = "::std::tr1::shared_ptr pNum1, pNum2;\n"; - ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code, dinit(TokenizeOptions, $.expand = false, $.cppstd = Standards::CPP03))); + ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code, s, true, false)); } void vardecl15() { @@ -4820,16 +4809,16 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("struct A { long x ; } ;", tokenizeAndStringify(code5)); const char code6[] = "struct A { __int8 x : 3; };"; - ASSERT_EQUALS("struct A { char x ; } ;", tokenizeAndStringifyWindows(code6, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { char x ; } ;", tokenizeAndStringify(code6, settings_win32a)); const char code7[] = "struct A { __int16 x : 3; };"; - ASSERT_EQUALS("struct A { short x ; } ;", tokenizeAndStringifyWindows(code7, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { short x ; } ;", tokenizeAndStringify(code7,settings_win32a)); const char code8[] = "struct A { __int32 x : 3; };"; - ASSERT_EQUALS("struct A { int x ; } ;", tokenizeAndStringifyWindows(code8, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { int x ; } ;", tokenizeAndStringify(code8, settings_win32a)); const char code9[] = "struct A { __int64 x : 3; };"; - ASSERT_EQUALS("struct A { long long x ; } ;", tokenizeAndStringifyWindows(code9, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { long long x ; } ;", tokenizeAndStringify(code9, settings_win32a)); const char code10[] = "struct A { unsigned char x : 3; };"; ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringify(code10)); @@ -4844,16 +4833,16 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("struct A { unsigned long x ; } ;", tokenizeAndStringify(code13)); const char code14[] = "struct A { unsigned __int8 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringifyWindows(code14, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringify(code14, settings_win32a)); const char code15[] = "struct A { unsigned __int16 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned short x ; } ;", tokenizeAndStringifyWindows(code15, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { unsigned short x ; } ;", tokenizeAndStringify(code15, settings_win32a)); const char code16[] = "struct A { unsigned __int32 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned int x ; } ;", tokenizeAndStringifyWindows(code16, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { unsigned int x ; } ;", tokenizeAndStringify(code16, settings_win32a)); const char code17[] = "struct A { unsigned __int64 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned long long x ; } ;", tokenizeAndStringifyWindows(code17, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { unsigned long long x ; } ;", tokenizeAndStringify(code17, settings_win32a)); const char code18[] = "struct A { signed char x : 3; };"; ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringify(code18)); @@ -4865,19 +4854,19 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("struct A { signed int x ; } ;", tokenizeAndStringify(code20)); const char code21[] = "struct A { signed long x : 3; };"; - ASSERT_EQUALS("struct A { signed long x ; } ;", tokenizeAndStringifyWindows(code21)); + ASSERT_EQUALS("struct A { signed long x ; } ;", tokenizeAndStringify(code21, settings_windows)); const char code22[] = "struct A { signed __int8 x : 3; };"; - ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringifyWindows(code22, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringify(code22, settings_win32a)); const char code23[] = "struct A { signed __int16 x : 3; };"; - ASSERT_EQUALS("struct A { signed short x ; } ;", tokenizeAndStringifyWindows(code23, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { signed short x ; } ;", tokenizeAndStringify(code23, settings_win32a)); const char code24[] = "struct A { signed __int32 x : 3; };"; - ASSERT_EQUALS("struct A { signed int x ; } ;", tokenizeAndStringifyWindows(code24, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { signed int x ; } ;", tokenizeAndStringify(code24, settings_win32a)); const char code25[] = "struct A { signed __int64 x : 3; };"; - ASSERT_EQUALS("struct A { signed long long x ; } ;", tokenizeAndStringifyWindows(code25, Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { signed long long x ; } ;", tokenizeAndStringify(code25, settings_win32a)); } void bitfields2() { @@ -5301,72 +5290,72 @@ class TestTokenizer : public TestFixture { void microsoftMemory() { const char code1a[] = "void foo() { int a[10], b[10]; CopyMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1a,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1a,settings2_win32a)); const char code1b[] = "void foo() { int a[10], b[10]; RtlCopyMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1b,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1b,settings2_win32a)); const char code1c[] = "void foo() { int a[10], b[10]; RtlCopyBytes(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1c,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1c,settings2_win32a)); const char code2a[] = "void foo() { int a[10]; FillMemory(a, sizeof(a), 255); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2a,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2a,settings2_win32a)); const char code2b[] = "void foo() { int a[10]; RtlFillMemory(a, sizeof(a), 255); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2b,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2b,settings2_win32a)); const char code2c[] = "void foo() { int a[10]; RtlFillBytes(a, sizeof(a), 255); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2c,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2c,settings2_win32a)); const char code3a[] = "void foo() { int a[10], b[10]; MoveMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memmove ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code3a,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memmove ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code3a,settings2_win32a)); const char code3b[] = "void foo() { int a[10], b[10]; RtlMoveMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memmove ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code3b,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memmove ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code3b,settings2_win32a)); const char code4a[] = "void foo() { int a[10]; ZeroMemory(a, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4a,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4a,settings2_win32a)); const char code4b[] = "void foo() { int a[10]; RtlZeroMemory(a, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4b,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4b,settings2_win32a)); const char code4c[] = "void foo() { int a[10]; RtlZeroBytes(a, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4c,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4c,settings2_win32a)); const char code4d[] = "void foo() { int a[10]; RtlSecureZeroMemory(a, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4d,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4d,settings2_win32a)); const char code5[] = "void foo() { int a[10], b[10]; RtlCompareMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcmp ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code5,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcmp ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code5,settings2_win32a)); const char code6[] = "void foo() { ZeroMemory(f(1, g(a, b)), h(i, j(0, 1))); }"; - ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 0 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code6,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 0 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code6,settings2_win32a)); const char code7[] = "void foo() { FillMemory(f(1, g(a, b)), h(i, j(0, 1)), 255); }"; - ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 255 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code7,dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 255 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code7,settings2_win32a)); } void microsoftString() { const char code1a[] = "void foo() { _tprintf (_T(\"test\") _T(\"1\")); }"; - ASSERT_EQUALS("void foo ( ) { printf ( \"test1\" ) ; }", tokenizeAndStringify(code1a, dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { printf ( \"test1\" ) ; }", tokenizeAndStringify(code1a, settings2_win32a)); const char code1b[] = "void foo() { _tprintf (_TEXT(\"test\") _TEXT(\"2\")); }"; - ASSERT_EQUALS("void foo ( ) { printf ( \"test2\" ) ; }", tokenizeAndStringify(code1b, dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { printf ( \"test2\" ) ; }", tokenizeAndStringify(code1b, settings2_win32a)); const char code1c[] = "void foo() { _tprintf (TEXT(\"test\") TEXT(\"3\")); }"; - ASSERT_EQUALS("void foo ( ) { printf ( \"test3\" ) ; }", tokenizeAndStringify(code1c, dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + ASSERT_EQUALS("void foo ( ) { printf ( \"test3\" ) ; }", tokenizeAndStringify(code1c, settings2_win32a)); const char code2a[] = "void foo() { _tprintf (_T(\"test\") _T(\"1\")); }"; - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, dinit(TokenizeOptions, $.platform = Platform::Type::Win32W))); - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, dinit(TokenizeOptions, $.platform = Platform::Type::Win64))); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, settings2_win32w)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, settings2_win64)); const char code2b[] = "void foo() { _tprintf (_TEXT(\"test\") _TEXT(\"2\")); }"; - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, dinit(TokenizeOptions, $.platform = Platform::Type::Win32W))); - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, dinit(TokenizeOptions, $.platform = Platform::Type::Win64))); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, settings2_win32w)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, settings2_win64)); const char code2c[] = "void foo() { _tprintf (TEXT(\"test\") TEXT(\"3\")); }"; - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, dinit(TokenizeOptions, $.platform = Platform::Type::Win32W))); - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, dinit(TokenizeOptions, $.platform = Platform::Type::Win64))); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, settings2_win32w)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, settings2_win64)); } void borland() { // __closure ASSERT_EQUALS("int ( * a ) ( ) ;", // TODO VarId - tokenizeAndStringify("int (__closure *a)();", dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + tokenizeAndStringify("int (__closure *a)();", settings2_win32a)); // __property ASSERT_EQUALS("class Fred { ; __property ; } ;", - tokenizeAndStringify("class Fred { __property int x = { } };", dinit(TokenizeOptions, $.platform = Platform::Type::Win32A))); + tokenizeAndStringify("class Fred { __property int x = { } };", settings2_win32a)); } void simplifySQL() { @@ -6149,10 +6138,10 @@ class TestTokenizer : public TestFixture { "float * ptrToFloat ;"; // These types should be defined the same on all Windows platforms - const std::string win32A = tokenizeAndStringifyWindows(code, Platform::Type::Win32A); + const std::string win32A = tokenizeAndStringify(code, settings_win32a); ASSERT_EQUALS(expected, win32A); - ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, Platform::Type::Win32W)); - ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, Platform::Type::Win64)); + ASSERT_EQUALS(win32A, tokenizeAndStringify(code, settings_win32w)); + ASSERT_EQUALS(win32A, tokenizeAndStringify(code, settings_win32a)); } void platformWin32A() { @@ -6198,13 +6187,13 @@ class TestTokenizer : public TestFixture { "sscanf ( dst , \"%s\" , dst ) ; " "} " "unsigned char tbyte ;"; - ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, Platform::Type::Win32A)); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, settings_win32a)); const char code2[] = "LPCTSTR f(void* p) { return LPCTSTR(p); }\n" // #11430 "LPCTSTR g() { return LPCTSTR{}; }"; const char expected2[] = "const char * f ( void * p ) { return ( const char * ) ( p ) ; }\n" "const char * g ( ) { return ( const char * ) ( 0 ) ; }"; - ASSERT_EQUALS(expected2, tokenizeAndStringifyWindows(code2, Platform::Type::Win32A)); + ASSERT_EQUALS(expected2, tokenizeAndStringify(code2, settings_win32a)); } void platformWin32W() { @@ -6250,29 +6239,29 @@ class TestTokenizer : public TestFixture { "wscanf ( L\"%s\" , dst ) ; " "swscanf ( dst , L\"%s\" , dst ) ; " "}"; - ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, Platform::Type::Win32W)); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, settings_win32w)); } void platformWin32AStringCat() { //#5150 const char code[] = "TCHAR text[] = _T(\"123\") _T(\"456\") _T(\"789\");"; const char expected[] = "char text [ 10 ] = \"123456789\" ;"; - ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, Platform::Type::Win32A)); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, settings_win32a)); } void platformWin32WStringCat() { //#5150 const char code[] = "TCHAR text[] = _T(\"123\") _T(\"456\") _T(\"789\");"; const char expected[] = "wchar_t text [ 10 ] = L\"123456789\" ;"; - ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, Platform::Type::Win32W)); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, settings_win32w)); } void platformWinWithNamespace() { const char code1[] = "UINT32 a; ::UINT32 b; foo::UINT32 c;"; const char expected1[] = "unsigned int a ; unsigned int b ; foo :: UINT32 c ;"; - ASSERT_EQUALS(expected1, tokenizeAndStringifyWindows(code1, Platform::Type::Win32A)); + ASSERT_EQUALS(expected1, tokenizeAndStringify(code1, settings_win32a)); const char code2[] = "LPCVOID a; ::LPCVOID b; foo::LPCVOID c;"; const char expected2[] = "const void * a ; const void * b ; foo :: LPCVOID c ;"; - ASSERT_EQUALS(expected2, tokenizeAndStringifyWindows(code2, Platform::Type::Win32A)); + ASSERT_EQUALS(expected2, tokenizeAndStringify(code2, settings_win32w)); } void isOneNumber() const { @@ -6417,8 +6406,9 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("int func1 ( ) ;", tokenizeAndStringify("[[clang::optnone]] [[nodiscard]] int func1();")); + const Settings s = settingsBuilder(settings1).c(Standards::C23).build(); ASSERT_EQUALS("void f ( int i ) { exit ( i ) ; }", - tokenizeAndStringify("[[noreturn]] void f(int i) { exit(i); }", dinit(TokenizeOptions, $.cpp = false, $.cstd = Standards::C23))); + tokenizeAndStringify("[[noreturn]] void f(int i) { exit(i); }", s, false)); } void simplifyCaseRange() { @@ -7308,6 +7298,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("", errout_str()); // #11128 + const Settings s = settingsBuilder(settings1).cpp(Standards::CPP17).build(); ASSERT_NO_THROW(tokenizeAndStringify("template \n" "struct S;\n" "struct R;\n" @@ -7317,7 +7308,7 @@ class TestTokenizer : public TestFixture { " return y;\n" " else\n" " return z;\n" - "}\n", dinit(TokenizeOptions, $.cppstd = Standards::CPP17))); + "}\n", s)); ignore_errout(); // #10079 - createInnerAST bug.. @@ -8926,18 +8917,18 @@ class TestTokenizer : public TestFixture { void simplifyPlatformTypes() { { const char code[] = "size_t f();"; - ASSERT_EQUALS("unsigned long f ( ) ;", tokenizeAndStringify(code, dinit(TokenizeOptions, $.platform = Platform::Type::Unix32))); - ASSERT_EQUALS("unsigned long f ( ) ;", tokenizeAndStringify(code, dinit(TokenizeOptions, $.platform = Platform::Type::Unix64))); + ASSERT_EQUALS("unsigned long f ( ) ;", tokenizeAndStringify(code, settings2_unix32)); + ASSERT_EQUALS("unsigned long f ( ) ;", tokenizeAndStringify(code, settings2_unix64)); } { const char code[] = "ssize_t f();"; - ASSERT_EQUALS("long f ( ) ;", tokenizeAndStringify(code, dinit(TokenizeOptions, $.platform = Platform::Type::Unix32))); - ASSERT_EQUALS("long f ( ) ;", tokenizeAndStringify(code, dinit(TokenizeOptions, $.platform = Platform::Type::Unix64))); + ASSERT_EQUALS("long f ( ) ;", tokenizeAndStringify(code, settings2_unix32)); + ASSERT_EQUALS("long f ( ) ;", tokenizeAndStringify(code, settings2_unix64)); } { const char code[] = "std::ptrdiff_t f();"; - ASSERT_EQUALS("long f ( ) ;", tokenizeAndStringify(code, dinit(TokenizeOptions, $.platform = Platform::Type::Unix32))); - ASSERT_EQUALS("long f ( ) ;", tokenizeAndStringify(code, dinit(TokenizeOptions, $.platform = Platform::Type::Unix64))); + ASSERT_EQUALS("long f ( ) ;", tokenizeAndStringify(code, settings2_unix32)); + ASSERT_EQUALS("long f ( ) ;", tokenizeAndStringify(code, settings2_unix64)); } } From 5bec5624f677636d38803d3a9fc152bcc5923fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 23 Mar 2026 11:21:03 +0100 Subject: [PATCH 254/675] library.cpp: use `std::unordered_map` for some `Library::LibraryData` members (#8363) --- lib/library.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/library.cpp b/lib/library.cpp index bd4a62d0a42..efba862eb15 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -123,9 +123,9 @@ struct Library::LibraryData std::map mDealloc; // deallocation functions std::map mRealloc; // reallocation functions std::unordered_map mNoReturn; // is function noreturn? - std::map mReturnValue; - std::map mReturnValueType; - std::map mReturnValueContainer; + std::unordered_map mReturnValue; + std::unordered_map mReturnValueType; + std::unordered_map mReturnValueContainer; std::map> mUnknownReturnValues; std::map mReportErrors; std::map mProcessAfterCode; From f68416390189250aaa99e884b4994ab8e50c1c50 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 23 Mar 2026 11:41:27 +0100 Subject: [PATCH 255/675] Fix #12699 QDir functions missing from qt.cfg (#8349) Continuation of #6374 --------- Co-authored-by: Dominik Strasser Co-authored-by: chrchr-github --- cfg/qt.cfg | 119 +++++++++++++++++++++++++++++++++--- test/cfg/qt.cpp | 23 +++++++ tools/triage/mainwindow.cpp | 2 +- 3 files changed, 134 insertions(+), 10 deletions(-) diff --git a/cfg/qt.cfg b/cfg/qt.cfg index 00cb66c1909..5371e598568 100644 --- a/cfg/qt.cfg +++ b/cfg/qt.cfg @@ -2319,10 +2319,28 @@
+ + + + + false + + + + + + + + + + false + + + - + false @@ -2338,6 +2356,68 @@
+ + + false + + + + + + + + + + + false + + + + + + + + + + + false + + + + + + + + + + + false + + + + + + + + false + + + + + + + + + + + false + + + + + + + false @@ -2346,7 +2426,7 @@ - + false @@ -2356,13 +2436,6 @@
- - - false - - - - @@ -2375,6 +2448,34 @@
+ + + false + + + + + + + false + + + + + + + false + + + + + + + false + + + + diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index d508eeef487..4c6c881b752 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -32,6 +32,7 @@ #include #include #include +#include // TODO: this is actually avilable via Core5Compat but I could not get it to work with pkg-config #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) @@ -54,6 +55,28 @@ int ignoredReturnValue_QSize_width(const QSize &s) return s.width(); } + +void ignoredReturnValue_QDir(const QString& dirname) +{ + QDir dir(dirname); + + // cppcheck-suppress ignoredReturnValue + dir.exists("abc"); + + // cppcheck-suppress ignoredReturnErrorCode + dir.mkdir("abc"); + + // cppcheck-suppress ignoredReturnValue + dir.count(); + + // cppcheck-suppress ignoredReturnValue + dir.filePath("abc"); + + // cppcheck-suppress ignoredReturnValue + dir.entryList(); +} + + void unusedVariable_QTransform() { // cppcheck-suppress unusedVariable diff --git a/tools/triage/mainwindow.cpp b/tools/triage/mainwindow.cpp index 8e5e4d39020..564d6e1bcf2 100644 --- a/tools/triage/mainwindow.cpp +++ b/tools/triage/mainwindow.cpp @@ -81,7 +81,7 @@ MainWindow::MainWindow(QWidget *parent) : std::srand(static_cast(std::time(nullptr))); QDir workFolder(WORK_FOLDER); if (!workFolder.exists()) { - workFolder.mkdir(WORK_FOLDER); + (void)workFolder.mkdir(WORK_FOLDER); } ui->results->setContextMenuPolicy(Qt::CustomContextMenu); From 74e6823ca873473c743f2c43d1122622984b4952 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 23 Mar 2026 12:33:34 +0100 Subject: [PATCH 256/675] Fix #14613 Crash in compilePrecedence2() (function called requires) (#8361) Co-authored-by: chrchr-github --- lib/tokenlist.cpp | 8 +++++--- test/testtokenize.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 7f7ca25aa5c..55ca98c628c 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1058,10 +1058,12 @@ static void compilePrecedence2(Token *&tok, AST_state& state) else compileUnaryOp(tok, state, compileExpression); tok = tok2->link()->next(); - } else if (Token::simpleMatch(tok->previous(), "requires {") - || (Token::simpleMatch(tok->previous(), ")") + } else if ((Token::simpleMatch(tok->tokAt(-1), "requires {") && tok->tokAt(-1)->isKeyword()) + || (Token::simpleMatch(tok->tokAt(-1), ")") && tok->linkAt(-1) - && Token::simpleMatch(tok->linkAt(-1)->previous(), "requires ("))) { + && Token::simpleMatch(tok->linkAt(-1)->tokAt(-1), "requires (") && tok->linkAt(-1)->tokAt(-1)->isKeyword())) { + if (!tok->link()) + throw InternalError(tok, "Syntax error, token has no link.", InternalError::AST); tok->astOperand1(state.op.top()); state.op.pop(); state.op.push(tok); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index f78899820b2..7a33f757737 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8332,6 +8332,12 @@ class TestTokenizer : public TestFixture { void cppKeywordInCSource() { ASSERT_NO_THROW(tokenizeAndStringify("int throw() {}", dinit(TokenizeOptions, $.cpp = false))); + + const char code[] = "void requires(const char*);\n" // #14613 + "void f() { requires(\"abc\"); }\n"; + ASSERT_NO_THROW(tokenizeAndStringify(code, dinit(TokenizeOptions, $.cpp = false))); + ASSERT_NO_THROW(tokenizeAndStringify(code, dinit(TokenizeOptions, $.cpp = true, $.cppstd = Standards::CPP17))); + ASSERT_THROW_INTERNAL(tokenizeAndStringify(code, dinit(TokenizeOptions, $.cpp = true, $.cppstd = Standards::CPP20)), AST); } void cppcast() { From 7108f9fda4398c5a53319b3bb78c750c17614380 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 23 Mar 2026 13:09:25 +0100 Subject: [PATCH 257/675] Revert "Fix #14613 Crash in compilePrecedence2() (function called requires)" (broken build) (#8370) Reverts danmar/cppcheck#8361 --- lib/tokenlist.cpp | 8 +++----- test/testtokenize.cpp | 6 ------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 55ca98c628c..7f7ca25aa5c 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1058,12 +1058,10 @@ static void compilePrecedence2(Token *&tok, AST_state& state) else compileUnaryOp(tok, state, compileExpression); tok = tok2->link()->next(); - } else if ((Token::simpleMatch(tok->tokAt(-1), "requires {") && tok->tokAt(-1)->isKeyword()) - || (Token::simpleMatch(tok->tokAt(-1), ")") + } else if (Token::simpleMatch(tok->previous(), "requires {") + || (Token::simpleMatch(tok->previous(), ")") && tok->linkAt(-1) - && Token::simpleMatch(tok->linkAt(-1)->tokAt(-1), "requires (") && tok->linkAt(-1)->tokAt(-1)->isKeyword())) { - if (!tok->link()) - throw InternalError(tok, "Syntax error, token has no link.", InternalError::AST); + && Token::simpleMatch(tok->linkAt(-1)->previous(), "requires ("))) { tok->astOperand1(state.op.top()); state.op.pop(); state.op.push(tok); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7a33f757737..f78899820b2 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8332,12 +8332,6 @@ class TestTokenizer : public TestFixture { void cppKeywordInCSource() { ASSERT_NO_THROW(tokenizeAndStringify("int throw() {}", dinit(TokenizeOptions, $.cpp = false))); - - const char code[] = "void requires(const char*);\n" // #14613 - "void f() { requires(\"abc\"); }\n"; - ASSERT_NO_THROW(tokenizeAndStringify(code, dinit(TokenizeOptions, $.cpp = false))); - ASSERT_NO_THROW(tokenizeAndStringify(code, dinit(TokenizeOptions, $.cpp = true, $.cppstd = Standards::CPP17))); - ASSERT_THROW_INTERNAL(tokenizeAndStringify(code, dinit(TokenizeOptions, $.cpp = true, $.cppstd = Standards::CPP20)), AST); } void cppcast() { From ee1afe9490f6e6812a682dd1b1a808cb15fcc330 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 24 Mar 2026 00:41:40 +0100 Subject: [PATCH 258/675] Remove unnecessary loading of qt.cfg in testtokenize.cpp (#8372) Co-authored-by: chrchr-github --- test/testtokenize.cpp | 159 +++++++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 80 deletions(-) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index f78899820b2..8ea3ca7d9ac 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -46,15 +46,14 @@ class TestTokenizer : public TestFixture { TestTokenizer() : TestFixture("TestTokenizer") {} private: - const Settings settings0 = settingsBuilder().library("qt.cfg").build(); - const Settings settings1 = settingsBuilder().library("std.cfg").library("qt.cfg").debugwarnings().build(); + const Settings settings1 = settingsBuilder().library("std.cfg").debugwarnings().build(); const Settings settings2 = settingsBuilder(settings1).cpp(Standards::CPP11).c(Standards::C11).build(); const Settings settings2_win32a = settingsBuilder(settings2).platform(Platform::Type::Win32A).build(); const Settings settings2_win32w = settingsBuilder(settings2).platform(Platform::Type::Win32W).build(); const Settings settings2_win64 = settingsBuilder(settings2).platform(Platform::Type::Win64).build(); const Settings settings2_unix32 = settingsBuilder(settings2).platform(Platform::Type::Unix32).build(); const Settings settings2_unix64 = settingsBuilder(settings2).platform(Platform::Type::Unix64).build(); - const Settings settings3 = settingsBuilder(settings0).c(Standards::C89).cpp(Standards::CPP03).build(); + const Settings settings3 = settingsBuilder().c(Standards::C89).cpp(Standards::CPP03).build(); const Settings settings_windows = settingsBuilder().library("windows.cfg").debugwarnings().cpp(Standards::CPP11).build(); const Settings settings_win32a = settingsBuilder(settings_windows).platform(Platform::Type::Win32A).build(); const Settings settings_win32w = settingsBuilder(settings_windows).platform(Platform::Type::Win32W).build(); @@ -1734,7 +1733,7 @@ class TestTokenizer : public TestFixture { { const char code[] = "extern \"C\" int foo();"; // tokenize.. - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); // Expected result.. ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); @@ -1743,7 +1742,7 @@ class TestTokenizer : public TestFixture { { const char code[] = "extern \"C\" { int foo(); }"; // tokenize.. - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); // Expected result.. ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); @@ -1752,7 +1751,7 @@ class TestTokenizer : public TestFixture { { const char code[] = "extern \"C++\" int foo();"; // tokenize.. - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); // Expected result.. ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); @@ -1761,7 +1760,7 @@ class TestTokenizer : public TestFixture { { const char code[] = "extern \"C++\" { int foo(); }"; // tokenize.. - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); // Expected result.. ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); @@ -3188,7 +3187,7 @@ class TestTokenizer : public TestFixture { const char code[] = "class A{\n" " void f() {}\n" "};"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // A body {} @@ -3211,7 +3210,7 @@ class TestTokenizer : public TestFixture { " char a[10];\n" " char *b ; b = new char[a[0]];\n" "};"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // a[10] @@ -3233,7 +3232,7 @@ class TestTokenizer : public TestFixture { const char code[] = "void f(){\n" " foo(g());\n" "};"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // foo( @@ -3251,7 +3250,7 @@ class TestTokenizer : public TestFixture { const char code[] = "bool foo(C a, bar>& f, int b) {\n" " return(af);\n" "}"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); // template< @@ -3277,7 +3276,7 @@ class TestTokenizer : public TestFixture { const char code[] = "void foo() {\n" " return static_cast(a);\n" "}"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3292,7 +3291,7 @@ class TestTokenizer : public TestFixture { const char code[] = "void foo() {\n" " nvwa<(x > y)> ERROR_nnn;\n" "}"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3306,7 +3305,7 @@ class TestTokenizer : public TestFixture { { // #4860 const char code[] = "class A : public B {};"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3320,7 +3319,7 @@ class TestTokenizer : public TestFixture { { // #4860 const char code[] = "Bar>>>::set(1, 2, 3);"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3335,7 +3334,7 @@ class TestTokenizer : public TestFixture { { // #5627 const char code[] = "new Foo[10];"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3349,7 +3348,7 @@ class TestTokenizer : public TestFixture { { // #6242 const char code[] = "func = integral_;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3362,7 +3361,7 @@ class TestTokenizer : public TestFixture { { // if (a < b || c > d) { } const char code[] = "{ if (a < b || c > d); }"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3372,7 +3371,7 @@ class TestTokenizer : public TestFixture { { // bool f = a < b || c > d const char code[] = "bool f = a < b || c > d;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3382,7 +3381,7 @@ class TestTokenizer : public TestFixture { { // template const char code[] = "a < b || c > d;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3392,7 +3391,7 @@ class TestTokenizer : public TestFixture { { // if (a < ... > d) { } const char code[] = "{ if (a < b || c == 3 || d > e); }"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3402,7 +3401,7 @@ class TestTokenizer : public TestFixture { { // template const char code[] = "a d;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(7)); @@ -3411,7 +3410,7 @@ class TestTokenizer : public TestFixture { { // template const char code[] = "a d;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(7)); @@ -3419,7 +3418,7 @@ class TestTokenizer : public TestFixture { { const char code[] = "template < f = b || c > struct S;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(7)); @@ -3428,7 +3427,7 @@ class TestTokenizer : public TestFixture { { const char code[] = "struct A : B {};"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(4) == tok->tokAt(8)); @@ -3437,7 +3436,7 @@ class TestTokenizer : public TestFixture { { const char code[] = "Data;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); ASSERT_EQUALS(true, tok->linkAt(1) == tok->tokAt(4)); @@ -3447,7 +3446,7 @@ class TestTokenizer : public TestFixture { { // #6601 const char code[] = "template struct FuncType : FuncType { };"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = tokenizer.tokens(); @@ -3465,7 +3464,7 @@ class TestTokenizer : public TestFixture { { // #7158 const char code[] = "enum { value = boost::mpl::at_c };"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok = Token::findsimplematch(tokenizer.tokens(), "<"); ASSERT_EQUALS(true, tok->link() == tok->tokAt(4)); @@ -3477,7 +3476,7 @@ class TestTokenizer : public TestFixture { const char code[] = "template \n" "struct CheckedDivOp< T, U, typename std::enable_if::value || std::is_floating_point::value>::type> {\n" "};\n"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "struct")->tokAt(2); const Token *tok2 = Token::findsimplematch(tokenizer.tokens(), "{")->previous(); @@ -3488,7 +3487,7 @@ class TestTokenizer : public TestFixture { { // #7975 const char code[] = "template X copy() {};\n"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "< Y"); const Token *tok2 = Token::findsimplematch(tok1, "> copy"); @@ -3499,7 +3498,7 @@ class TestTokenizer : public TestFixture { { // #8006 const char code[] = "C && a = b;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok1 = tokenizer.tokens()->next(); const Token *tok2 = tok1->tokAt(2); @@ -3510,7 +3509,7 @@ class TestTokenizer : public TestFixture { { // #8115 const char code[] = "void Test(C && c);"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "<"); const Token *tok2 = tok1->tokAt(2); @@ -3521,7 +3520,7 @@ class TestTokenizer : public TestFixture { // #8654 const char code[] = "template struct A {}; " "template struct foo : A... {};"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *A = Token::findsimplematch(tokenizer.tokens(), "A <"); ASSERT_EQUALS(true, A->linkAt(1) == A->tokAt(3)); @@ -3530,7 +3529,7 @@ class TestTokenizer : public TestFixture { // #8851 const char code[] = "template::type>" "void basic_json() {}"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT_EQUALS(true, Token::simpleMatch(tokenizer.tokens()->linkAt(1), "> void")); } @@ -3538,7 +3537,7 @@ class TestTokenizer : public TestFixture { { // #9094 - template usage or comparison? const char code[] = "a = f(x%x<--a==x>x);"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr == Token::findsimplematch(tokenizer.tokens(), "<")->link()); } @@ -3548,7 +3547,7 @@ class TestTokenizer : public TestFixture { const char code[] = "using std::same_as;\n" "template T>\n" "void f();"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "template <"); const Token *tok2 = Token ::findsimplematch(tokenizer.tokens(), "same_as <"); @@ -3559,7 +3558,7 @@ class TestTokenizer : public TestFixture { { // #9131 - template usage or comparison? const char code[] = "using std::list; list l;"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "<")->link()); } @@ -3570,7 +3569,7 @@ class TestTokenizer : public TestFixture { "{\n" " for (set::iterator i = sources.begin(); i != sources.end(); ++i) {}\n" "}"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "<")->link()); } @@ -3581,7 +3580,7 @@ class TestTokenizer : public TestFixture { " a<> b;\n" " b.a<>::c();\n" "}\n"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ::")->link()); } @@ -3592,7 +3591,7 @@ class TestTokenizer : public TestFixture { "template struct c {\n" " void d() { a[0]; }\n" "};\n"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> [")->link()); } @@ -3604,7 +3603,7 @@ class TestTokenizer : public TestFixture { "template using f = c;\n" "template > struct g {};\n" "template using baz = g;\n"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ;")->link()); } @@ -3618,7 +3617,7 @@ class TestTokenizer : public TestFixture { "template using c = a;\n" "template c e;\n" "auto f = -e<1> == 0;\n"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> ==")->link()); } @@ -3636,7 +3635,7 @@ class TestTokenizer : public TestFixture { "constexpr void b::operator()(c &&) const {\n" " i<3>.f([] {});\n" "}\n"; - SimpleTokenizer tokenizer(settings0, *this); + SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT(tokenizer.tokenize(code)); ASSERT(nullptr != Token::findsimplematch(tokenizer.tokens(), "> . f (")->link()); } @@ -3644,7 +3643,7 @@ class TestTokenizer : public TestFixture { { // #10491 const char code[] = "template