diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 33261c295..1297658cf 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -2106,6 +2106,10 @@ static bool evalAssignment(ValueFlow::Value &lhsValue, const std::string &assign lhsValue.intvalue |= rhsValue.intvalue; else if (assign == "^=") lhsValue.intvalue ^= rhsValue.intvalue; + else if (assign == "<<=") + lhsValue.intvalue <<= rhsValue.intvalue; + else if (assign == ">>=") + lhsValue.intvalue >>= rhsValue.intvalue; else return false; } else if (lhsValue.isFloatValue()) { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index ecdba1536..43dd7111d 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -2530,6 +2530,20 @@ private: " return x;\n" "}"; ASSERT_EQUALS(true, testValueOfX(code, 4U, 123.45F + 67, 0.01F)); + + code = "void f() {\n" + " int x = 123;\n" + " x >>= 1;\n" + " return x;\n" + "}"; + ASSERT_EQUALS(true, testValueOfX(code, 4U, 61)); + + code = "void f() {\n" + " int x = 123;\n" + " x <<= 1;\n" + " return x;\n" + "}"; + ASSERT_EQUALS(true, testValueOfX(code, 4U, 246)); } void valueFlowForwardCorrelatedVariables() {