MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / isStdMoveOrStdForwarded

Function isStdMoveOrStdForwarded

lib/valueflow.cpp:3164–3192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3162}
3163
3164static bool isStdMoveOrStdForwarded(Token * tok, ValueFlow::Value::MoveKind * moveKind, Token ** varTok = nullptr)
3165{
3166 if (tok->str() != "std")
3167 return false;
3168 ValueFlow::Value::MoveKind kind = ValueFlow::Value::MoveKind::NonMovedVariable;
3169 Token * variableToken = nullptr;
3170 if (Token::Match(tok, "std :: move ( %var% )")) {
3171 variableToken = tok->tokAt(4);
3172 kind = ValueFlow::Value::MoveKind::MovedVariable;
3173 } else if (Token::simpleMatch(tok, "std :: forward <")) {
3174 Token * const leftAngle = tok->tokAt(3);
3175 Token * rightAngle = leftAngle->link();
3176 if (Token::Match(rightAngle, "> ( %var% )")) {
3177 variableToken = rightAngle->tokAt(2);
3178 kind = ValueFlow::Value::MoveKind::ForwardedVariable;
3179 }
3180 }
3181 if (!variableToken)
3182 return false;
3183 if (variableToken->strAt(2) == ".") // Only partially moved
3184 return false;
3185 if (variableToken->valueType() && variableToken->valueType()->type >= ValueType::Type::VOID)
3186 return false;
3187 if (moveKind != nullptr)
3188 *moveKind = kind;
3189 if (varTok != nullptr)
3190 *varTok = variableToken;
3191 return true;
3192}
3193
3194static bool isOpenParenthesisMemberFunctionCallOfVarId(const Token * openParenthesisToken, nonneg int varId)
3195{

Callers 1

valueFlowAfterMoveFunction · 0.85

Calls 3

simpleMatchFunction · 0.70
strMethod · 0.45
tokAtMethod · 0.45

Tested by

no test coverage detected