@@ -2338,14 +2338,14 @@ bool isWithinScope(const Token* tok, const Variable* var, ScopeType type)
23382338 return false ;
23392339}
23402340
2341- bool isVariableChangedByFunctionCall (const Token *tok, int indirect, nonneg int varid, const Settings &settings , bool *inconclusive)
2341+ bool isVariableChangedByFunctionCall (const Token *tok, int indirect, nonneg int varid, const Library &library , bool *inconclusive)
23422342{
23432343 if (!tok)
23442344 return false ;
23452345 if (tok->varId () == varid)
2346- return isVariableChangedByFunctionCall (tok, indirect, settings , inconclusive);
2347- return isVariableChangedByFunctionCall (tok->astOperand1 (), indirect, varid, settings , inconclusive) ||
2348- isVariableChangedByFunctionCall (tok->astOperand2 (), indirect, varid, settings , inconclusive);
2346+ return isVariableChangedByFunctionCall (tok, indirect, library , inconclusive);
2347+ return isVariableChangedByFunctionCall (tok->astOperand1 (), indirect, varid, library , inconclusive) ||
2348+ isVariableChangedByFunctionCall (tok->astOperand2 (), indirect, varid, library , inconclusive);
23492349}
23502350
23512351bool isScopeBracket (const Token* tok)
@@ -2526,7 +2526,7 @@ bool isMutableExpression(const Token* tok)
25262526 return true ;
25272527}
25282528
2529- bool isVariableChangedByFunctionCall (const Token *tok, int indirect, const Settings &settings , bool *inconclusive)
2529+ bool isVariableChangedByFunctionCall (const Token *tok, int indirect, const Library &library , bool *inconclusive)
25302530{
25312531 if (!tok)
25322532 return false ;
@@ -2566,13 +2566,13 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Setti
25662566
25672567 if (!tok->function () && !tok->variable () && tok->isName ()) {
25682568 // Check if direction (in, out, inout) is specified in the library configuration and use that
2569- const Library::ArgumentChecks::Direction argDirection = settings. library .getArgDirection (tok, 1 + argnr, indirect);
2569+ const Library::ArgumentChecks::Direction argDirection = library.getArgDirection (tok, 1 + argnr, indirect);
25702570 if (argDirection == Library::ArgumentChecks::Direction::DIR_IN )
25712571 return false ;
25722572 if (argDirection == Library::ArgumentChecks::Direction::DIR_OUT || argDirection == Library::ArgumentChecks::Direction::DIR_INOUT )
25732573 return true ;
25742574
2575- const bool requireNonNull = settings. library .isnullargbad (tok, 1 + argnr);
2575+ const bool requireNonNull = library.isnullargbad (tok, 1 + argnr);
25762576 if (Token::simpleMatch (tok->tokAt (-2 ), " std :: tie" ))
25772577 return true ;
25782578 // if the library says 0 is invalid
@@ -2798,7 +2798,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings &settings,
27982798 if (indirect == 0 && astIsLHS (tok2) && Token::Match (ptok, " . %var%" ) && astIsPointer (ptok->next ()))
27992799 pindirect = 1 ;
28002800 bool inconclusive = false ;
2801- bool isChanged = isVariableChangedByFunctionCall (ptok, pindirect, settings, &inconclusive);
2801+ bool isChanged = isVariableChangedByFunctionCall (ptok, pindirect, settings. library , &inconclusive);
28022802 isChanged |= inconclusive;
28032803 if (isChanged)
28042804 return true ;
@@ -3423,7 +3423,7 @@ bool isConstVarExpression(const Token *tok, const std::function<bool(const Token
34233423 return false ;
34243424}
34253425
3426- static ExprUsage getFunctionUsage (const Token* tok, int indirect, const Settings& settings )
3426+ static ExprUsage getFunctionUsage (const Token* tok, int indirect, const Library& library )
34273427{
34283428 const bool addressOf = tok->astParent () && tok->astParent ()->isUnaryOp (" &" );
34293429
@@ -3485,14 +3485,14 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Settings
34853485 } else if (ftok->str () == " {" ) {
34863486 return indirect == 0 ? ExprUsage::Used : ExprUsage::Inconclusive;
34873487 } else {
3488- const bool isnullbad = settings. library .isnullargbad (ftok, argnr + 1 );
3488+ const bool isnullbad = library.isnullargbad (ftok, argnr + 1 );
34893489 if (indirect == 0 && astIsPointer (tok) && !addressOf && isnullbad)
34903490 return ExprUsage::Used;
34913491 bool hasIndirect = false ;
3492- const bool isuninitbad = settings. library .isuninitargbad (ftok, argnr + 1 , indirect, &hasIndirect);
3492+ const bool isuninitbad = library.isuninitargbad (ftok, argnr + 1 , indirect, &hasIndirect);
34933493 if (isuninitbad && (!addressOf || isnullbad))
34943494 return ExprUsage::Used;
3495- const Library::ArgumentChecks::Direction argDirection = settings. library .getArgDirection (ftok, argnr + 1 , indirect);
3495+ const Library::ArgumentChecks::Direction argDirection = library.getArgDirection (ftok, argnr + 1 , indirect);
34963496 if (argDirection == Library::ArgumentChecks::Direction::DIR_IN ) // TODO: DIR_INOUT?
34973497 return ExprUsage::Used;
34983498 if (argDirection == Library::ArgumentChecks::Direction::DIR_OUT )
@@ -3562,7 +3562,7 @@ ExprUsage getExprUsage(const Token* tok, int indirect, const Settings& settings)
35623562 (astIsLHS (tok) || Token::simpleMatch (parent, " ( )" )))
35633563 return ExprUsage::Used;
35643564 }
3565- return getFunctionUsage (tok, indirect, settings);
3565+ return getFunctionUsage (tok, indirect, settings. library );
35663566}
35673567
35683568static void getLHSVariablesRecursive (std::vector<const Variable*>& vars, const Token* tok)
0 commit comments