Fixed #8419 (False positive accessMoved on int)

This commit is contained in:
Daniel Marjamäki 2019-12-21 07:39:14 +01:00
parent 3b3016f49e
commit fe23d017f3
2 changed files with 8 additions and 1 deletions

View File

@ -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)

View File

@ -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() {