Skip to content

Commit

Permalink
apply DISABLE_VALUEFLOW via ValueFlowOptions::enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed May 1, 2024
1 parent 45dee67 commit d65f697
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ void Settings::loadSummaries()

void Settings::setCheckLevel(CheckLevel level)
{
// TODO: requires regular settings creation to be applied
const char * const disableValueflowEnv = std::getenv("DISABLE_VALUEFLOW");
vfOptions.enabled = !disableValueflowEnv || (std::strcmp(disableValueflowEnv, "1") != 0);

if (level == CheckLevel::normal) {
// Checking should finish in reasonable time.
checkLevel = level;
Expand Down
3 changes: 3 additions & 0 deletions lib/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ class CPPCHECKLIB WARN_UNUSED Settings {

struct ValueFlowOptions
{
/** @brief Control if ValueFlow is performed in Tokenizer::simplifyTokens1() */
bool enabled = true;

/** @brief the maximum iterations to execute */
std::size_t maxIterations = 4;

Expand Down
7 changes: 2 additions & 5 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3421,10 +3421,7 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
Summaries::create(*this, configuration);

// TODO: do not run valueflow if no checks are being performed at all - e.g. unusedFunctions only
const char* disableValueflowEnv = std::getenv("DISABLE_VALUEFLOW");
const bool doValueFlow = !disableValueflowEnv || (std::strcmp(disableValueflowEnv, "1") != 0);

if (doValueFlow) {
if (mSettings.vfOptions.enabled) {
if (mTimerResults) {
Timer t("Tokenizer::simplifyTokens1::ValueFlow", mSettings.showtime, mTimerResults);
ValueFlow::setValues(list, *mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
Expand All @@ -3448,7 +3445,7 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
}
}

if (doValueFlow) {
if (mSettings.vfOptions.enabled) {
mSymbolDatabase->setArrayDimensionsUsingValueFlow();
}

Expand Down

0 comments on commit d65f697

Please sign in to comment.