From 9325deb1d8ac47b91570885b746d4c66461f3cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 7 Jun 2024 21:07:49 +0200 Subject: [PATCH] valueflow-fast: Added a --check-level=fast option. --- cli/cmdlineparser.cpp | 14 +++++++++++--- lib/settings.cpp | 11 ++++++++++- lib/settings.h | 3 ++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 5da5b898e4c..3c7059ff720 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -475,7 +475,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a else if (std::strncmp(argv[i], "--check-level=", 14) == 0) { Settings::CheckLevel level = Settings::CheckLevel::normal; const std::string level_s(argv[i] + 14); - if (level_s == "normal") + if (level_s == "reduced") + level = Settings::CheckLevel::reduced; + else if (level_s == "normal") level = Settings::CheckLevel::normal; else if (level_s == "exhaustive") level = Settings::CheckLevel::exhaustive; @@ -915,6 +917,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a return Result::Fail; } + else if (std::strncmp(argv[i], "--performance-valueflow-max-iterations=", 39) == 0) { + if (!parseNumberArg(argv[i], 39, mSettings.vfOptions.maxIterations, true)) + return Result::Fail; + } + // Specify platform else if (std::strncmp(argv[i], "--platform=", 11) == 0) { const std::string platform(11+argv[i]); @@ -1475,8 +1482,9 @@ void CmdLineParser::printHelp() const " --check-config Check cppcheck configuration. The normal code\n" " analysis is disabled by this flag.\n" " --check-level=\n" - " Configure how much checking you want:\n" - " * normal: Cppcheck uses some compromises in the checking so\n" + " Configure how much valueflow analysis you want:\n" + " * reduced: Reduce valueflow to finish checking quickly.\n" + " * normal: Cppcheck uses some compromises in the analysis so\n" " the checking will finish in reasonable time.\n" " * exhaustive: deeper analysis that you choose when you can\n" " wait.\n" diff --git a/lib/settings.cpp b/lib/settings.cpp index 5a06beaef55..22047e098ae 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -287,7 +287,16 @@ void Settings::loadSummaries() void Settings::setCheckLevel(CheckLevel level) { - if (level == CheckLevel::normal) { + if (level == CheckLevel::reduced) { + // Checking should finish quickly. + checkLevel = level; + vfOptions.maxSubFunctionArgs = 8; + vfOptions.maxIfCount = 100; + vfOptions.doConditionExpressionAnalysis = false; + vfOptions.maxForwardBranches = 4; + vfOptions.maxIterations = 1; + } + else if (level == CheckLevel::normal) { // Checking should finish in reasonable time. checkLevel = level; vfOptions.maxSubFunctionArgs = 8; diff --git a/lib/settings.h b/lib/settings.h index 7fa2918a15f..4751cd50051 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -489,7 +489,8 @@ class CPPCHECKLIB WARN_UNUSED Settings { return jobs == 1; } - enum class CheckLevel : std::uint8_t { + enum class CheckLevel: std::uint8_t { + reduced, normal, exhaustive };