Skip to content

Commit

Permalink
valueflow-fast: Added a --check-level=fast option.
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Jun 23, 2024
1 parent da6b55e commit 9325deb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
14 changes: 11 additions & 3 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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=<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"
Expand Down
11 changes: 10 additions & 1 deletion lib/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down

0 comments on commit 9325deb

Please sign in to comment.