Skip to content

Commit 9325deb

Browse files
committed
valueflow-fast: Added a --check-level=fast option.
1 parent da6b55e commit 9325deb

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Diff for: cli/cmdlineparser.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
475475
else if (std::strncmp(argv[i], "--check-level=", 14) == 0) {
476476
Settings::CheckLevel level = Settings::CheckLevel::normal;
477477
const std::string level_s(argv[i] + 14);
478-
if (level_s == "normal")
478+
if (level_s == "reduced")
479+
level = Settings::CheckLevel::reduced;
480+
else if (level_s == "normal")
479481
level = Settings::CheckLevel::normal;
480482
else if (level_s == "exhaustive")
481483
level = Settings::CheckLevel::exhaustive;
@@ -915,6 +917,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
915917
return Result::Fail;
916918
}
917919

920+
else if (std::strncmp(argv[i], "--performance-valueflow-max-iterations=", 39) == 0) {
921+
if (!parseNumberArg(argv[i], 39, mSettings.vfOptions.maxIterations, true))
922+
return Result::Fail;
923+
}
924+
918925
// Specify platform
919926
else if (std::strncmp(argv[i], "--platform=", 11) == 0) {
920927
const std::string platform(11+argv[i]);
@@ -1475,8 +1482,9 @@ void CmdLineParser::printHelp() const
14751482
" --check-config Check cppcheck configuration. The normal code\n"
14761483
" analysis is disabled by this flag.\n"
14771484
" --check-level=<level>\n"
1478-
" Configure how much checking you want:\n"
1479-
" * normal: Cppcheck uses some compromises in the checking so\n"
1485+
" Configure how much valueflow analysis you want:\n"
1486+
" * reduced: Reduce valueflow to finish checking quickly.\n"
1487+
" * normal: Cppcheck uses some compromises in the analysis so\n"
14801488
" the checking will finish in reasonable time.\n"
14811489
" * exhaustive: deeper analysis that you choose when you can\n"
14821490
" wait.\n"

Diff for: lib/settings.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,16 @@ void Settings::loadSummaries()
287287

288288
void Settings::setCheckLevel(CheckLevel level)
289289
{
290-
if (level == CheckLevel::normal) {
290+
if (level == CheckLevel::reduced) {
291+
// Checking should finish quickly.
292+
checkLevel = level;
293+
vfOptions.maxSubFunctionArgs = 8;
294+
vfOptions.maxIfCount = 100;
295+
vfOptions.doConditionExpressionAnalysis = false;
296+
vfOptions.maxForwardBranches = 4;
297+
vfOptions.maxIterations = 1;
298+
}
299+
else if (level == CheckLevel::normal) {
291300
// Checking should finish in reasonable time.
292301
checkLevel = level;
293302
vfOptions.maxSubFunctionArgs = 8;

Diff for: lib/settings.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ class CPPCHECKLIB WARN_UNUSED Settings {
489489
return jobs == 1;
490490
}
491491

492-
enum class CheckLevel : std::uint8_t {
492+
enum class CheckLevel: std::uint8_t {
493+
reduced,
493494
normal,
494495
exhaustive
495496
};

0 commit comments

Comments
 (0)