@@ -2334,14 +2334,14 @@ bool isWithinScope(const Token* tok, const Variable* var, ScopeType type)
23342334 return false ;
23352335}
23362336
2337- bool isVariableChangedByFunctionCall (const Token *tok, int indirect, nonneg int varid, const Settings &settings , bool *inconclusive)
2337+ bool isVariableChangedByFunctionCall (const Token *tok, int indirect, nonneg int varid, const Library &library , bool *inconclusive)
23382338{
23392339 if (!tok)
23402340 return false ;
23412341 if (tok->varId () == varid)
2342- return isVariableChangedByFunctionCall (tok, indirect, settings , inconclusive);
2343- return isVariableChangedByFunctionCall (tok->astOperand1 (), indirect, varid, settings , inconclusive) ||
2344- isVariableChangedByFunctionCall (tok->astOperand2 (), indirect, varid, settings , inconclusive);
2342+ return isVariableChangedByFunctionCall (tok, indirect, library , inconclusive);
2343+ return isVariableChangedByFunctionCall (tok->astOperand1 (), indirect, varid, library , inconclusive) ||
2344+ isVariableChangedByFunctionCall (tok->astOperand2 (), indirect, varid, library , inconclusive);
23452345}
23462346
23472347bool isScopeBracket (const Token* tok)
@@ -2522,7 +2522,7 @@ bool isMutableExpression(const Token* tok)
25222522 return true ;
25232523}
25242524
2525- bool isVariableChangedByFunctionCall (const Token *tok, int indirect, const Settings &settings , bool *inconclusive)
2525+ bool isVariableChangedByFunctionCall (const Token *tok, int indirect, const Library &library , bool *inconclusive)
25262526{
25272527 if (!tok)
25282528 return false ;
@@ -2562,13 +2562,13 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Setti
25622562
25632563 if (!tok->function () && !tok->variable () && tok->isName ()) {
25642564 // Check if direction (in, out, inout) is specified in the library configuration and use that
2565- const Library::ArgumentChecks::Direction argDirection = settings. library .getArgDirection (tok, 1 + argnr, indirect);
2565+ const Library::ArgumentChecks::Direction argDirection = library.getArgDirection (tok, 1 + argnr, indirect);
25662566 if (argDirection == Library::ArgumentChecks::Direction::DIR_IN )
25672567 return false ;
25682568 if (argDirection == Library::ArgumentChecks::Direction::DIR_OUT || argDirection == Library::ArgumentChecks::Direction::DIR_INOUT )
25692569 return true ;
25702570
2571- const bool requireNonNull = settings. library .isnullargbad (tok, 1 + argnr);
2571+ const bool requireNonNull = library.isnullargbad (tok, 1 + argnr);
25722572 if (Token::simpleMatch (tok->tokAt (-2 ), " std :: tie" ))
25732573 return true ;
25742574 // if the library says 0 is invalid
@@ -2796,7 +2796,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings &settings,
27962796 if (indirect == 0 && astIsLHS (tok2) && Token::Match (ptok, " . %var%" ) && astIsPointer (ptok->next ()))
27972797 pindirect = 1 ;
27982798 bool inconclusive = false ;
2799- bool isChanged = isVariableChangedByFunctionCall (ptok, pindirect, settings, &inconclusive);
2799+ bool isChanged = isVariableChangedByFunctionCall (ptok, pindirect, settings. library , &inconclusive);
28002800 isChanged |= inconclusive;
28012801 if (isChanged)
28022802 return true ;
@@ -3421,7 +3421,7 @@ bool isConstVarExpression(const Token *tok, const std::function<bool(const Token
34213421 return false ;
34223422}
34233423
3424- static ExprUsage getFunctionUsage (const Token* tok, int indirect, const Settings& settings )
3424+ static ExprUsage getFunctionUsage (const Token* tok, int indirect, const Library& library )
34253425{
34263426 const bool addressOf = tok->astParent () && tok->astParent ()->isUnaryOp (" &" );
34273427
@@ -3483,14 +3483,14 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Settings
34833483 } else if (ftok->str () == " {" ) {
34843484 return indirect == 0 ? ExprUsage::Used : ExprUsage::Inconclusive;
34853485 } else {
3486- const bool isnullbad = settings. library .isnullargbad (ftok, argnr + 1 );
3486+ const bool isnullbad = library.isnullargbad (ftok, argnr + 1 );
34873487 if (indirect == 0 && astIsPointer (tok) && !addressOf && isnullbad)
34883488 return ExprUsage::Used;
34893489 bool hasIndirect = false ;
3490- const bool isuninitbad = settings. library .isuninitargbad (ftok, argnr + 1 , indirect, &hasIndirect);
3490+ const bool isuninitbad = library.isuninitargbad (ftok, argnr + 1 , indirect, &hasIndirect);
34913491 if (isuninitbad && (!addressOf || isnullbad))
34923492 return ExprUsage::Used;
3493- const Library::ArgumentChecks::Direction argDirection = settings. library .getArgDirection (ftok, argnr + 1 , indirect);
3493+ const Library::ArgumentChecks::Direction argDirection = library.getArgDirection (ftok, argnr + 1 , indirect);
34943494 if (argDirection == Library::ArgumentChecks::Direction::DIR_IN ) // TODO: DIR_INOUT?
34953495 return ExprUsage::Used;
34963496 if (argDirection == Library::ArgumentChecks::Direction::DIR_OUT )
@@ -3560,7 +3560,7 @@ ExprUsage getExprUsage(const Token* tok, int indirect, const Settings& settings)
35603560 (astIsLHS (tok) || Token::simpleMatch (parent, " ( )" )))
35613561 return ExprUsage::Used;
35623562 }
3563- return getFunctionUsage (tok, indirect, settings);
3563+ return getFunctionUsage (tok, indirect, settings. library );
35643564}
35653565
35663566static void getLHSVariablesRecursive (std::vector<const Variable*>& vars, const Token* tok)
0 commit comments