@@ -2230,6 +2230,8 @@ bool isEscapeFunction(const Token* ftok, const Library& library)
22302230{
22312231 if (!Token::Match (ftok, " %name% (" ))
22322232 return false ;
2233+ if (Token::Match (ftok, " exit|abort" ))
2234+ return true ;
22332235 const Function* function = ftok->function ();
22342236 if (function) {
22352237 if (function->isEscapeFunction ())
@@ -2334,14 +2336,14 @@ bool isWithinScope(const Token* tok, const Variable* var, ScopeType type)
23342336 return false ;
23352337}
23362338
2337- bool isVariableChangedByFunctionCall (const Token *tok, int indirect, nonneg int varid, const Settings &settings , bool *inconclusive)
2339+ bool isVariableChangedByFunctionCall (const Token *tok, int indirect, nonneg int varid, const Library &library , bool *inconclusive)
23382340{
23392341 if (!tok)
23402342 return false ;
23412343 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);
2344+ return isVariableChangedByFunctionCall (tok, indirect, library , inconclusive);
2345+ return isVariableChangedByFunctionCall (tok->astOperand1 (), indirect, varid, library , inconclusive) ||
2346+ isVariableChangedByFunctionCall (tok->astOperand2 (), indirect, varid, library , inconclusive);
23452347}
23462348
23472349bool isScopeBracket (const Token* tok)
@@ -2522,7 +2524,7 @@ bool isMutableExpression(const Token* tok)
25222524 return true ;
25232525}
25242526
2525- bool isVariableChangedByFunctionCall (const Token *tok, int indirect, const Settings &settings , bool *inconclusive)
2527+ bool isVariableChangedByFunctionCall (const Token *tok, int indirect, const Library &library , bool *inconclusive)
25262528{
25272529 if (!tok)
25282530 return false ;
@@ -2562,13 +2564,13 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Setti
25622564
25632565 if (!tok->function () && !tok->variable () && tok->isName ()) {
25642566 // 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);
2567+ const Library::ArgumentChecks::Direction argDirection = library.getArgDirection (tok, 1 + argnr, indirect);
25662568 if (argDirection == Library::ArgumentChecks::Direction::DIR_IN )
25672569 return false ;
25682570 if (argDirection == Library::ArgumentChecks::Direction::DIR_OUT || argDirection == Library::ArgumentChecks::Direction::DIR_INOUT )
25692571 return true ;
25702572
2571- const bool requireNonNull = settings. library .isnullargbad (tok, 1 + argnr);
2573+ const bool requireNonNull = library.isnullargbad (tok, 1 + argnr);
25722574 if (Token::simpleMatch (tok->tokAt (-2 ), " std :: tie" ))
25732575 return true ;
25742576 // if the library says 0 is invalid
@@ -2796,7 +2798,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings &settings,
27962798 if (indirect == 0 && astIsLHS (tok2) && Token::Match (ptok, " . %var%" ) && astIsPointer (ptok->next ()))
27972799 pindirect = 1 ;
27982800 bool inconclusive = false ;
2799- bool isChanged = isVariableChangedByFunctionCall (ptok, pindirect, settings, &inconclusive);
2801+ bool isChanged = isVariableChangedByFunctionCall (ptok, pindirect, settings. library , &inconclusive);
28002802 isChanged |= inconclusive;
28012803 if (isChanged)
28022804 return true ;
@@ -3421,7 +3423,7 @@ bool isConstVarExpression(const Token *tok, const std::function<bool(const Token
34213423 return false ;
34223424}
34233425
3424- static ExprUsage getFunctionUsage (const Token* tok, int indirect, const Settings& settings )
3426+ static ExprUsage getFunctionUsage (const Token* tok, int indirect, const Library& library )
34253427{
34263428 const bool addressOf = tok->astParent () && tok->astParent ()->isUnaryOp (" &" );
34273429
@@ -3483,14 +3485,14 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Settings
34833485 } else if (ftok->str () == " {" ) {
34843486 return indirect == 0 ? ExprUsage::Used : ExprUsage::Inconclusive;
34853487 } else {
3486- const bool isnullbad = settings. library .isnullargbad (ftok, argnr + 1 );
3488+ const bool isnullbad = library.isnullargbad (ftok, argnr + 1 );
34873489 if (indirect == 0 && astIsPointer (tok) && !addressOf && isnullbad)
34883490 return ExprUsage::Used;
34893491 bool hasIndirect = false ;
3490- const bool isuninitbad = settings. library .isuninitargbad (ftok, argnr + 1 , indirect, &hasIndirect);
3492+ const bool isuninitbad = library.isuninitargbad (ftok, argnr + 1 , indirect, &hasIndirect);
34913493 if (isuninitbad && (!addressOf || isnullbad))
34923494 return ExprUsage::Used;
3493- const Library::ArgumentChecks::Direction argDirection = settings. library .getArgDirection (ftok, argnr + 1 , indirect);
3495+ const Library::ArgumentChecks::Direction argDirection = library.getArgDirection (ftok, argnr + 1 , indirect);
34943496 if (argDirection == Library::ArgumentChecks::Direction::DIR_IN ) // TODO: DIR_INOUT?
34953497 return ExprUsage::Used;
34963498 if (argDirection == Library::ArgumentChecks::Direction::DIR_OUT )
@@ -3560,7 +3562,7 @@ ExprUsage getExprUsage(const Token* tok, int indirect, const Settings& settings)
35603562 (astIsLHS (tok) || Token::simpleMatch (parent, " ( )" )))
35613563 return ExprUsage::Used;
35623564 }
3563- return getFunctionUsage (tok, indirect, settings);
3565+ return getFunctionUsage (tok, indirect, settings. library );
35643566}
35653567
35663568static void getLHSVariablesRecursive (std::vector<const Variable*>& vars, const Token* tok)
0 commit comments