@@ -115,27 +115,6 @@ static void changeKnownToPossible(std::list<ValueFlow::Value> &values)
115115 it->changeKnownToPossible ();
116116}
117117
118- static bool mightBeNonConstPointerFunctionArg (const Token *tok)
119- {
120- // TODO: check if argument might be non-const pointer
121- const Token *parent = tok->astParent ();
122- while (parent && parent->str () == " ," )
123- parent = parent->astParent ();
124- return (parent && Token::Match (parent->previous (), " %name% (" ));
125- }
126-
127- static const Token *findVariableInAST (const Token *tok, unsigned int varid)
128- {
129- if (!tok)
130- return nullptr ;
131- if (tok->varId () == varid)
132- return tok;
133- const Token *ret1 = findVariableInAST (tok->astOperand1 (), varid);
134- if (ret1)
135- return ret1;
136- return findVariableInAST (tok->astOperand2 (), varid);
137- }
138-
139118/* *
140119 * Is condition always false when variable has given value?
141120 * \param condition top ast token in condition
@@ -1858,7 +1837,7 @@ static bool valueFlowForward(Token * const startToken,
18581837 std::list<ValueFlow::Value>::const_iterator it;
18591838 for (it = values.begin (); it != values.end (); ++it)
18601839 valueFlowAST (const_cast <Token*>(expr), varid, *it, settings);
1861- if ((expr-> valueType () && expr-> valueType ()-> pointer ) && mightBeNonConstPointerFunctionArg (tok2) && findVariableInAST (expr,varid ))
1840+ if (isVariableChangedByFunctionCall (expr, varid, settings, nullptr ))
18621841 changeKnownToPossible (values);
18631842 } else {
18641843 std::list<ValueFlow::Value>::const_iterator it;
@@ -1871,8 +1850,7 @@ static bool valueFlowForward(Token * const startToken,
18711850 else
18721851 valueFlowAST (const_cast <Token*>(op2), varid, *it, settings);
18731852 }
1874-
1875- if (mightBeNonConstPointerFunctionArg (tok2) && findVariableInAST (op2,varid))
1853+ if (isVariableChangedByFunctionCall (op2, varid, settings, nullptr ))
18761854 changeKnownToPossible (values);
18771855 }
18781856
0 commit comments