From fe23d017f3b2d3561c5333b8b848eaef1c503a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 21 Dec 2019 07:39:14 +0100 Subject: [PATCH] Fixed #8419 (False positive accessMoved on int) --- lib/valueflow.cpp | 3 ++- test/testvalueflow.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 75624c3f8..06cb595b5 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3923,7 +3923,8 @@ static bool isStdMoveOrStdForwarded(Token * tok, ValueFlow::Value::MoveKind * mo return false; if (variableToken->strAt(2) == ".") // Only partially moved return false; - + if (variableToken->valueType() && variableToken->valueType()->type >= ValueType::Type::VOID) + return false; if (moveKind != nullptr) *moveKind = kind; if (varTok != nullptr) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 7d1f238fa..73e5a88af 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -561,6 +561,12 @@ private: " X y=x;\n" "}"; ASSERT_EQUALS(true, testValueOfX(code, 11U, ValueFlow::Value::MoveKind::MovedVariable)); + + code = "void f(int x) {\n" + " g(std::move(x));\n" + " y=x;\n" + "}"; + ASSERT_EQUALS(false, testValueOfX(code, 3U, ValueFlow::Value::MoveKind::MovedVariable)); } void valueFlowCalculations() {