From d3bdb84650c10a83cf9613fa2dce7a31c43a52c4 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 4 May 2023 11:59:03 +0200 Subject: [PATCH] Fix #11701 performance regression (hang) in 2.11dev (#5032) --- lib/valueflow.cpp | 1 + test/testvalueflow.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ff6f14000..3ef0133d0 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -9218,6 +9218,7 @@ struct ValueFlowPassRunner { return run(pass); })) return true; + --n; } if (state.settings->debugwarnings) { if (n == 0 && values != getTotalValues()) { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index c4b7542fe..02d72a0c4 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -7189,6 +7189,23 @@ private: " }\n" "}\n"; valueOfTok(code, "i"); + + code = "void f() {\n" // #11701 + " std::vector v(500);\n" + " for (int i = 0; i < 500; i++) {\n" + " if (i < 122)\n" + " v[i] = 255;\n" + " else if (i == 122)\n" + " v[i] = 220;\n" + " else if (i < 386)\n" + " v[i] = 196;\n" + " else if (i == 386)\n" + " v[i] = 118;\n" + " else\n" + " v[i] = 0;\n" + " }\n" + "}\n"; + valueOfTok(code, "i"); } void valueFlowCrashConstructorInitialization() { // #9577