Skip to content

Commit 737bab3

Browse files
committed
Fix #13374 (Add --check-level=reduced option)
1 parent f7d0c25 commit 737bab3

6 files changed

+230
-216
lines changed

cli/cmdlineparser.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
471471
else if (std::strncmp(argv[i], "--check-level=", 14) == 0) {
472472
Settings::CheckLevel level = Settings::CheckLevel::normal;
473473
const std::string level_s(argv[i] + 14);
474-
if (level_s == "normal")
474+
if (level_s == "reduced")
475+
level = Settings::CheckLevel::reduced;
476+
else if (level_s == "normal")
475477
level = Settings::CheckLevel::normal;
476478
else if (level_s == "exhaustive")
477479
level = Settings::CheckLevel::exhaustive;
@@ -952,6 +954,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
952954
return Result::Fail;
953955
}
954956

957+
else if (std::strncmp(argv[i], "--performance-valueflow-max-iterations=", 39) == 0) {
958+
if (!parseNumberArg(argv[i], 39, mSettings.vfOptions.maxIterations, true))
959+
return Result::Fail;
960+
}
961+
955962
// Specify platform
956963
else if (std::strncmp(argv[i], "--platform=", 11) == 0) {
957964
const std::string platform(11+argv[i]);
@@ -1528,8 +1535,9 @@ void CmdLineParser::printHelp() const
15281535
" --check-config Check cppcheck configuration. The normal code\n"
15291536
" analysis is disabled by this flag.\n"
15301537
" --check-level=<level>\n"
1531-
" Configure how much checking you want:\n"
1532-
" * normal: Cppcheck uses some compromises in the checking so\n"
1538+
" Configure how much valueflow analysis you want:\n"
1539+
" * reduced: Reduce valueflow to finish checking quickly.\n"
1540+
" * normal: Cppcheck uses some compromises in the analysis so\n"
15331541
" the checking will finish in reasonable time.\n"
15341542
" * exhaustive: deeper analysis that you choose when you can\n"
15351543
" wait.\n"

lib/settings.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,16 @@ void Settings::loadSummaries()
299299

300300
void Settings::setCheckLevel(CheckLevel level)
301301
{
302-
if (level == CheckLevel::normal) {
302+
if (level == CheckLevel::reduced) {
303+
// Checking should finish quickly.
304+
checkLevel = level;
305+
vfOptions.maxSubFunctionArgs = 8;
306+
vfOptions.maxIfCount = 100;
307+
vfOptions.doConditionExpressionAnalysis = false;
308+
vfOptions.maxForwardBranches = 4;
309+
vfOptions.maxIterations = 1;
310+
}
311+
else if (level == CheckLevel::normal) {
303312
// Checking should finish in reasonable time.
304313
checkLevel = level;
305314
vfOptions.maxSubFunctionArgs = 8;

lib/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ class CPPCHECKLIB WARN_UNUSED Settings {
512512
}
513513

514514
enum class CheckLevel : std::uint8_t {
515+
reduced,
515516
normal,
516517
exhaustive
517518
};

tools/compare-normal-exhaustive.py

Lines changed: 0 additions & 211 deletions
This file was deleted.

0 commit comments

Comments
 (0)