diff --git a/CMakeLists.txt b/CMakeLists.txt index e41d81029ae..a6ec16f6d2f 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.0 LANGUAGES CXX) include(cmake/options.cmake) diff --git a/Makefile b/Makefile index 37156d357af..f59f4df08e5 100644 --- a/Makefile +++ b/Makefile @@ -132,9 +132,11 @@ ifeq (clang++, $(findstring clang++,$(CXX))) CPPCHK_GLIBCXX_DEBUG= endif ifndef CXXFLAGS - CXXFLAGS=-pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-sign-compare -Wno-multichar -Woverloaded-virtual -g + CXXFLAGS=-O2 -Wall -Wno-sign-compare -Wno-multichar endif +override CPPFLAGS += -DNDEBUG + ifeq (g++, $(findstring g++,$(CXX))) override CXXFLAGS += -pipe endif @@ -294,6 +296,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 \ @@ -385,7 +388,7 @@ dmake: tools/dmake/dmake.o cli/filelister.o $(libcppdir)/pathmatch.o $(libcppdir $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) run-dmake: dmake - ./dmake + ./dmake --release clean: rm -f build/*.cpp build/*.o lib/*.o cli/*.o frontend/*.o test/*.o tools/dmake/*.o externals/*/*.o testrunner dmake cppcheck cppcheck.exe cppcheck.1 @@ -757,6 +760,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/cli/main.cpp b/cli/main.cpp index 1c39ab14544..2749c098455 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -20,7 +20,7 @@ /** * * @mainpage Cppcheck - * @version 2.18.99 + * @version 2.20.0 * * @section overview_sec Overview * Cppcheck is a simple tool for static analysis of C/C++ code. diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index 81471638e62..9ffef5b16b6 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); 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/lib/version.h b/lib/version.h index 4828a568104..05ab3200348 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.20.0" +#define CPPCHECK_VERSION 2,20,0,0 #define LEGALCOPYRIGHT L"Copyright (C) 2007-2026 Cppcheck team." diff --git a/man/manual.md b/man/manual.md index 1a4e4002f10..d5504286553 100644 --- a/man/manual.md +++ b/man/manual.md @@ -1,6 +1,6 @@ --- title: Cppcheck manual -subtitle: Version 2.19 dev +subtitle: Version 2.20.0 author: Cppcheck team lang: en documentclass: report diff --git a/man/reference-cfg-format.md b/man/reference-cfg-format.md index 7a9e3b6dee7..2722fd4c3b8 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.20.0 author: Cppcheck team lang: en documentclass: report diff --git a/man/writing-addons.md b/man/writing-addons.md index da21ea513ad..4f1cd406e33 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.20.0 author: Cppcheck team lang: en documentclass: report diff --git a/releasenotes.txt b/releasenotes.txt index fe530b2121e..67a907a9382 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -1,27 +1,17 @@ Release Notes for Cppcheck 2.20 -Major bug fixes & crashes: -- - -New checks: -- - -C/C++ support: -- - GUI: -- +- Fix: The Misra C checkbox in "Edit Project" dialog is unchecked after reloading project. +- Fix: In the Misra Report, use proper icons according to misra classifications +- Fix: The platform files are not shown in the dropdown in ProjectFileDialog +- Troubleshooting: detailed progress view that shows what files the threads are working on 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 -- +- Support inline polyspace suppressions 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 @@ + diff --git a/win_installer/productInfo.wxi b/win_installer/productInfo.wxi index d07ce1136c9..283c64016d5 100644 --- a/win_installer/productInfo.wxi +++ b/win_installer/productInfo.wxi @@ -1,8 +1,8 @@ - + - +