From 81dc8d5a0d6be3e8a97208cd98268dd296ea2fbb Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 29 Sep 2026 16:46:27 +0200 Subject: [PATCH 1/5] Update valueflow.cpp --- lib/valueflow.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index aa0b2c91c29..5732085b652 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -696,19 +696,6 @@ static bool isNonZero(const Token* tok) return tok && (!tok->hasKnownIntValue() || tok->getKnownIntValue() != 0); } -static const Token* getOtherOperand(const Token* tok) -{ - if (!tok) - return nullptr; - if (!tok->astParent()) - return nullptr; - if (tok->astParent()->astOperand1() != tok) - return tok->astParent()->astOperand1(); - if (tok->astParent()->astOperand2() != tok) - return tok->astParent()->astOperand2(); - return nullptr; -} - static void valueFlowArrayBool(TokenList& tokenlist, const Settings& settings) { for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { @@ -729,7 +716,7 @@ static void valueFlowArrayBool(TokenList& tokenlist, const Settings& settings) continue; if (!var->isArray() || var->isArgument() || var->isStlType()) continue; - if (isNonZero(getOtherOperand(tok)) && Token::Match(tok->astParent(), "%comp%")) + if (isNonZero(tok->astSibling()) && Token::Match(tok->astParent(), "%comp%")) continue; // TODO: Check for function argument if ((astIsBool(tok->astParent()) && !Token::Match(tok->astParent(), "(|%name%")) || From 36de9b440925f4eb3f1492bd5a2d01318fba9854 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 29 Sep 2026 16:53:24 +0200 Subject: [PATCH 2/5] Update valueflow.cpp --- lib/valueflow.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 5732085b652..0ddd35d7fab 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -691,44 +691,6 @@ static void valueFlowArray(TokenList& tokenlist, const Settings& settings) } } -static bool isNonZero(const Token* tok) -{ - return tok && (!tok->hasKnownIntValue() || tok->getKnownIntValue() != 0); -} - -static void valueFlowArrayBool(TokenList& tokenlist, const Settings& settings) -{ - for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { - if (tok->hasKnownIntValue()) - continue; - const Variable* var = nullptr; - bool known = false; - const auto val = - std::find_if(tok->values().cbegin(), tok->values().cend(), std::mem_fn(&ValueFlow::Value::isTokValue)); - if (val == tok->values().end()) { - var = tok->variable(); - known = true; - } else { - var = val->tokvalue->variable(); - known = val->isKnown(); - } - if (!var) - continue; - if (!var->isArray() || var->isArgument() || var->isStlType()) - continue; - if (isNonZero(tok->astSibling()) && Token::Match(tok->astParent(), "%comp%")) - continue; - // TODO: Check for function argument - if ((astIsBool(tok->astParent()) && !Token::Match(tok->astParent(), "(|%name%")) || - (tok->astParent() && Token::Match(tok->astParent()->previous(), "if|while|for ("))) { - ValueFlow::Value value{1}; - if (known) - value.setKnown(); - setTokenValue(tok, std::move(value), settings); - } - } -} - static void valueFlowArrayElement(TokenList& tokenlist, const Settings& settings) { for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { From a0f3deb964ffcac57cef72e93dce86453d84f49c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 29 Sep 2026 17:08:53 +0200 Subject: [PATCH 3/5] Update valueflow.cpp --- lib/valueflow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 0ddd35d7fab..e9ab95d9b7f 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -7485,7 +7485,6 @@ void ValueFlow::setValues(TokenList& tokenlist, VFA(valueFlowSymbolicOperators(symboldatabase, settings)), VFA(valueFlowCondition(SymbolicConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions)), VFA(valueFlowSymbolicInfer(symboldatabase, settings)), - VFA(valueFlowArrayBool(tokenlist, settings)), VFA(valueFlowArrayElement(tokenlist, settings)), VFA(valueFlowRightShift(tokenlist, settings)), VFA_CPP( From d1227670a576c4596a396e112b2dc5f0792ada9d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 29 Sep 2026 17:22:19 +0200 Subject: [PATCH 4/5] Update other_test.py --- test/cli/other_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/cli/other_test.py b/test/cli/other_test.py index aad4fec264e..4eac2d8797b 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -190,8 +190,6 @@ def test_progress(tmpdir): "progress: ValueFlow::valueFlowCondition(SymbolicConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions) 1 100%\n" "progress: ValueFlow::valueFlowSymbolicInfer(symboldatabase, settings) 1 0%\n" "progress: ValueFlow::valueFlowSymbolicInfer(symboldatabase, settings) 1 100%\n" - "progress: ValueFlow::valueFlowArrayBool(tokenlist, settings) 1 0%\n" - "progress: ValueFlow::valueFlowArrayBool(tokenlist, settings) 1 100%\n" "progress: ValueFlow::valueFlowArrayElement(tokenlist, settings) 1 0%\n" "progress: ValueFlow::valueFlowArrayElement(tokenlist, settings) 1 100%\n" "progress: ValueFlow::valueFlowRightShift(tokenlist, settings) 1 0%\n" From 6d16a57808e51dbf68016127ead92da43aa416d4 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Tue, 29 Sep 2026 18:59:04 +0200 Subject: [PATCH 5/5] Fix --- test/cli/other_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 4eac2d8797b..7b68aab374e 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -1067,7 +1067,7 @@ def test_showtime_top5_summary_compdb(tmp_path): def __test_showtime_file(tmp_path, use_compdb=False, use_addons=False, use_clang_tidy=False): - exp_res = 79 + exp_res = 78 # project analysis does not call Preprocessor::getConfig() if use_compdb: exp_res -= 1 @@ -1101,7 +1101,7 @@ def test_showtime_file_clang_tidy_compdb(tmp_path): def __test_showtime_summary(tmp_path, use_compdb=False, use_addons=False, use_clang_tidy=False): - exp_res = 79 + exp_res = 78 # project analysis does not call Preprocessor::getConfig() if use_compdb: exp_res -= 1