From 6bd5f7945157574d94ac87b95878911faa9dee29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 10 Oct 2021 21:21:21 +0200 Subject: [PATCH] Revert "Fix 8629: false negative: (style) Condition '...' is always true (#3492)" This reverts commit b9be38aaecaf39f2c9fc7ae6786c6b1eaa40f4e5. --- lib/valueflow.cpp | 8 ++++---- test/testcondition.cpp | 10 ---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 7754ad70d..3b80b934f 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -803,11 +803,11 @@ static void setTokenValue(Token* tok, ValueFlow::Value value, const Settings* se // increment else if (parent->str() == "++") { for (const ValueFlow::Value &val : tok->values()) { - if (!val.isIntValue() && !val.isFloatValue() && !val.isSymbolicValue()) + if (!val.isIntValue() && !val.isFloatValue()) continue; ValueFlow::Value v(val); if (parent == tok->previous()) { - if (v.isIntValue() || v.isSymbolicValue()) + if (v.isIntValue()) v.intvalue = v.intvalue + 1; else v.floatValue = v.floatValue + 1.0; @@ -819,11 +819,11 @@ static void setTokenValue(Token* tok, ValueFlow::Value value, const Settings* se // decrement else if (parent->str() == "--") { for (const ValueFlow::Value &val : tok->values()) { - if (!val.isIntValue() && !val.isFloatValue() && !val.isSymbolicValue()) + if (!val.isIntValue() && !val.isFloatValue()) continue; ValueFlow::Value v(val); if (parent == tok->previous()) { - if (v.isIntValue() || v.isSymbolicValue()) + if (v.isIntValue()) v.intvalue = v.intvalue - 1; else v.floatValue = v.floatValue - 1.0; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index a9c3e576d..4c1843f79 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3826,16 +3826,6 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (style) Condition 'z<1' is always false\n", errout.str()); - check("bool f(int &index, const int s, const double * const array, double & x) {\n" - " if (index >= s)\n" - " return false;\n" - " else {\n" - " x = array[index];\n" - " return (index++) >= s;\n" - " }\n" - "}\n"); - ASSERT_EQUALS("[test.cpp:6]: (style) Condition '(index++)>=s' is always false\n", errout.str()); - check("struct a {\n" " a *b() const;\n" "} c;\n"