From 3f15b8e892e35b09bbea046b4ac53ef6417da812 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Apr 2026 12:34:44 +0200 Subject: [PATCH 1/4] Update vf_analyzers.cpp --- lib/vf_analyzers.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index 58fbe0b6d61..5594eefc868 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -675,8 +675,6 @@ struct ValueFlowAnalyzer : Analyzer { template std::vector evaluateInt(const Token* tok, F getProgramMemory) const { - if (const ValueFlow::Value* v = tok->getKnownValue(ValueFlow::Value::ValueType::INT)) - return {static_cast(v->intvalue)}; std::vector result; ProgramMemory pm = getProgramMemory(); if (Token::Match(tok, "&&|%oror%")) { From 45692951056edabbad6380610a5759ca61c593b3 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Apr 2026 13:34:10 +0200 Subject: [PATCH 2/4] Update vf_analyzers.cpp --- lib/vf_analyzers.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index 5594eefc868..75db84b00e6 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -675,6 +675,8 @@ struct ValueFlowAnalyzer : Analyzer { template std::vector evaluateInt(const Token* tok, F getProgramMemory) const { + if (const ValueFlow::Value* v = tok->getKnownValue(ValueFlow::Value::ValueType::INT)) + return {v->intvalue}; std::vector result; ProgramMemory pm = getProgramMemory(); if (Token::Match(tok, "&&|%oror%")) { From 35e94c27cc8307d791dcb7c896c9d50e277a060f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Apr 2026 15:10:09 +0200 Subject: [PATCH 3/4] Update testvalueflow.cpp --- test/testvalueflow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 9586e4fdca2..b8b31e8d248 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -320,7 +320,7 @@ class TestValueFlow : public TestFixture { } #define testValueOfX(...) testValueOfX_(__FILE__, __LINE__, __VA_ARGS__) - bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, int value, const Settings *s = nullptr) { + bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, MathLib::bigint value, const Settings *s = nullptr) { const Settings *settings1 = s ? s : &settings; // Tokenize.. @@ -3973,6 +3973,14 @@ class TestValueFlow : public TestFixture { " return x;\n" "}"; ASSERT_EQUALS(true, testValueOfX(code, 4U, 246)); + + code = "int64_t f() {\n" + " const int64_t val = 1LL << 33;\n" + " int64_t x = val;\n" + " x += val;\n" + " return x;\n" + "}"; + ASSERT_EQUALS(true, testValueOfX(code, 5U, 1LL << 34)); } void valueFlowForwardCorrelatedVariables() { From 6ff10a27ab4a5f2041b46367b776770d57874561 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 23 Apr 2026 16:56:17 +0200 Subject: [PATCH 4/4] Update vf_analyzers.cpp --- lib/vf_analyzers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index 75db84b00e6..24b1fea3274 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -717,7 +717,7 @@ struct ValueFlowAnalyzer : Analyzer { ProgramMemory pm = pms.get(tok, ctx, getProgramState()); MathLib::bigint out = 0; if (pm.getContainerEmptyValue(tok->exprId(), out)) - return {static_cast(out)}; + return {out}; return {}; } return {};