@@ -1742,6 +1742,40 @@ static bool isOpenParenthesisMemberFunctionCallOfVarId(const Token * openParenth
17421742 openParenthesisToken->tokAt (-2 )->originalName () == emptyString;
17431743}
17441744
1745+ static const Token * nextAfterAstRightmostLeaf (Token const * tok)
1746+ {
1747+ const Token * rightmostLeaf = tok;
1748+ if (!rightmostLeaf || !rightmostLeaf->astOperand1 ())
1749+ return nullptr ;
1750+ do {
1751+ if (rightmostLeaf->astOperand2 ())
1752+ rightmostLeaf = rightmostLeaf->astOperand2 ();
1753+ else
1754+ rightmostLeaf = rightmostLeaf->astOperand1 ();
1755+ } while (rightmostLeaf->astOperand1 ());
1756+ return rightmostLeaf->next ();
1757+ }
1758+
1759+ static const Token * findOpenParentesisOfMove (const Token * moveVarTok)
1760+ {
1761+ const Token * tok = moveVarTok;
1762+ while (tok && tok->str () != " (" )
1763+ tok = tok->previous ();
1764+ return tok;
1765+ }
1766+
1767+ static const Token * findEndOfFunctionCallForParameter (const Token * parameterToken)
1768+ {
1769+ if (!parameterToken)
1770+ return nullptr ;
1771+ const Token * parent = parameterToken->astParent ();
1772+ while (parent && !parent->isOp () && parent->str () != " (" )
1773+ parent = parent->astParent ();
1774+ if (!parent)
1775+ return nullptr ;
1776+ return nextAfterAstRightmostLeaf (parent);
1777+ }
1778+
17451779static void valueFlowAfterMove (TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
17461780{
17471781 if (!tokenlist->isCPP () || settings->standards .cpp < Standards::CPP11)
@@ -1804,26 +1838,14 @@ static void valueFlowAfterMove(TokenList *tokenlist, SymbolDatabase* symboldatab
18041838 value.setKnown ();
18051839 std::list<ValueFlow::Value> values;
18061840 values.push_back (value);
1807-
1808- valueFlowForward (varTok->next (), endOfVarScope, var, varId, values, false , tokenlist, errorLogger, settings);
1841+ const Token * openParentesisOfMove = findOpenParentesisOfMove (varTok);
1842+ const Token * endOfFunctionCall = findEndOfFunctionCallForParameter (openParentesisOfMove);
1843+ if (endOfFunctionCall)
1844+ valueFlowForward (const_cast <Token *>(endOfFunctionCall), endOfVarScope, var, varId, values, false , tokenlist, errorLogger, settings);
18091845 }
18101846 }
18111847}
18121848
1813- static const Token * nextAfterAstRightmostLeaf (Token const * tok)
1814- {
1815- const Token * rightmostLeaf = tok;
1816- if (!rightmostLeaf || !rightmostLeaf->astOperand1 ())
1817- return nullptr ;
1818- do {
1819- if (rightmostLeaf->astOperand2 ())
1820- rightmostLeaf = rightmostLeaf->astOperand2 ();
1821- else
1822- rightmostLeaf = rightmostLeaf->astOperand1 ();
1823- } while (rightmostLeaf->astOperand1 ());
1824- return rightmostLeaf->next ();
1825- }
1826-
18271849static void valueFlowAfterAssign (TokenList *tokenlist, SymbolDatabase* symboldatabase, ErrorLogger *errorLogger, const Settings *settings)
18281850{
18291851 const std::size_t functions = symboldatabase->functionScopes .size ();
0 commit comments