Skip to content

Commit b94ba63

Browse files
committed
Fix #13374 (Add --check-level=reduced option)
1 parent fc6e9d3 commit b94ba63

6 files changed

+230
-216
lines changed

Diff for: cli/cmdlineparser.cpp

+11-3
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;
@@ -947,6 +949,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
947949
return Result::Fail;
948950
}
949951

952+
else if (std::strncmp(argv[i], "--performance-valueflow-max-iterations=", 39) == 0) {
953+
if (!parseNumberArg(argv[i], 39, mSettings.vfOptions.maxIterations, true))
954+
return Result::Fail;
955+
}
956+
950957
// Specify platform
951958
else if (std::strncmp(argv[i], "--platform=", 11) == 0) {
952959
const std::string platform(11+argv[i]);
@@ -1518,8 +1525,9 @@ void CmdLineParser::printHelp() const
15181525
" --check-config Check cppcheck configuration. The normal code\n"
15191526
" analysis is disabled by this flag.\n"
15201527
" --check-level=<level>\n"
1521-
" Configure how much checking you want:\n"
1522-
" * normal: Cppcheck uses some compromises in the checking so\n"
1528+
" Configure how much valueflow analysis you want:\n"
1529+
" * reduced: Reduce valueflow to finish checking quickly.\n"
1530+
" * normal: Cppcheck uses some compromises in the analysis so\n"
15231531
" the checking will finish in reasonable time.\n"
15241532
" * exhaustive: deeper analysis that you choose when you can\n"
15251533
" wait.\n"

Diff for: lib/settings.cpp

+10-1
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;

Diff for: lib/settings.h

+1
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
};

Diff for: tools/compare-normal-exhaustive.py

-211
This file was deleted.

0 commit comments

Comments
 (0)