@@ -204,9 +204,9 @@ static bool variableIsUsedInScope(const Token* start, nonneg int varId, const Sc
204204
205205void CheckAutoVariablesImpl::assignFunctionArg ()
206206{
207- const bool printStyle = mSettings -> severity .isEnabled (Severity::style);
208- const bool printWarning = mSettings -> severity .isEnabled (Severity::warning);
209- if (!printStyle && !printWarning && !mSettings -> isPremiumEnabled (" uselessAssignmentPtrArg" ))
207+ const bool printStyle = mSettings . severity .isEnabled (Severity::style);
208+ const bool printWarning = mSettings . severity .isEnabled (Severity::warning);
209+ if (!printStyle && !printWarning && !mSettings . isPremiumEnabled (" uselessAssignmentPtrArg" ))
210210 return ;
211211
212212 logChecker (" CheckAutoVariables::assignFunctionArg" ); // style,warning
@@ -284,7 +284,7 @@ void CheckAutoVariablesImpl::autoVariables()
284284{
285285 logChecker (" CheckAutoVariables::autoVariables" );
286286
287- const bool printInconclusive = mSettings -> certainty .isEnabled (Certainty::inconclusive);
287+ const bool printInconclusive = mSettings . certainty .isEnabled (Certainty::inconclusive);
288288 const SymbolDatabase *symbolDatabase = mTokenizer ->getSymbolDatabase ();
289289 for (const Scope * scope : symbolDatabase->functionScopes ) {
290290 for (const Token *tok = scope->bodyStart ; tok && tok != scope->bodyEnd ; tok = tok->next ()) {
@@ -295,27 +295,27 @@ void CheckAutoVariablesImpl::autoVariables()
295295 }
296296 // Critical assignment
297297 const Token* rhs{};
298- if (Token::Match (tok, " [;{}] %var% =" ) && isRefPtrArg (tok->next ()) && isAutoVariableRHS (tok->tokAt (2 )->astOperand2 (), * mSettings )) {
298+ if (Token::Match (tok, " [;{}] %var% =" ) && isRefPtrArg (tok->next ()) && isAutoVariableRHS (tok->tokAt (2 )->astOperand2 (), mSettings )) {
299299 checkAutoVariableAssignment (tok->next (), false );
300- } else if (Token::Match (tok, " [;{}] * %var% =" ) && isPtrArg (tok->tokAt (2 )) && isAutoVariableRHS (tok->tokAt (3 )->astOperand2 (), * mSettings )) {
300+ } else if (Token::Match (tok, " [;{}] * %var% =" ) && isPtrArg (tok->tokAt (2 )) && isAutoVariableRHS (tok->tokAt (3 )->astOperand2 (), mSettings )) {
301301 const Token* lhs = tok->tokAt (2 );
302302 bool inconclusive = false ;
303303 if (!hasOverloadedAssignment (lhs, inconclusive) || (printInconclusive && inconclusive))
304304 checkAutoVariableAssignment (tok->next (), inconclusive);
305305 tok = tok->tokAt (4 );
306- } else if (isMemberAssignment (tok, rhs, * mSettings )) {
306+ } else if (isMemberAssignment (tok, rhs, mSettings )) {
307307 const Token* lhs = tok->tokAt (3 );
308308 bool inconclusive = false ;
309309 if (!hasOverloadedAssignment (lhs, inconclusive) || (printInconclusive && inconclusive))
310310 checkAutoVariableAssignment (tok->next (), inconclusive);
311311 tok = rhs;
312312 } else if (Token::Match (tok, " [;{}] %var% [" ) && Token::simpleMatch (tok->linkAt (2 ), " ] =" ) &&
313- (isPtrArg (tok->next ()) || isArrayArg (tok->next (), * mSettings )) &&
314- isAutoVariableRHS (tok->linkAt (2 )->next ()->astOperand2 (), * mSettings )) {
313+ (isPtrArg (tok->next ()) || isArrayArg (tok->next (), mSettings )) &&
314+ isAutoVariableRHS (tok->linkAt (2 )->next ()->astOperand2 (), mSettings )) {
315315 errorAutoVariableAssignment (tok->next (), false );
316316 }
317317 // Invalid pointer deallocation
318- else if ((Token::Match (tok, " %name% ( %var%|%str% ) ;" ) && mSettings -> library .getDeallocFuncInfo (tok)) ||
318+ else if ((Token::Match (tok, " %name% ( %var%|%str% ) ;" ) && mSettings . library .getDeallocFuncInfo (tok)) ||
319319 (tok->isCpp () && Token::Match (tok, " delete [| ]| (| %var%|%str% !![" ))) {
320320 tok = Token::findmatch (tok->next (), " %var%|%str%" );
321321 if (Token::simpleMatch (tok->astParent (), " ." ))
@@ -333,7 +333,7 @@ void CheckAutoVariablesImpl::autoVariables()
333333 }
334334 }
335335 }
336- } else if ((Token::Match (tok, " %name% ( & %var% ) ;" ) && mSettings -> library .getDeallocFuncInfo (tok)) ||
336+ } else if ((Token::Match (tok, " %name% ( & %var% ) ;" ) && mSettings . library .getDeallocFuncInfo (tok)) ||
337337 (tok->isCpp () && Token::Match (tok, " delete [| ]| (| & %var% !![" ))) {
338338 tok = Token::findmatch (tok->next (), " %var%" );
339339 if (isAutoVar (tok))
@@ -564,7 +564,7 @@ static bool isAssignedToNonLocal(const Token* tok)
564564
565565void CheckAutoVariablesImpl::checkVarLifetimeScope (const Token * start, const Token * end)
566566{
567- const bool printInconclusive = mSettings -> certainty .isEnabled (Certainty::inconclusive);
567+ const bool printInconclusive = mSettings . certainty .isEnabled (Certainty::inconclusive);
568568 if (!start)
569569 return ;
570570 const Scope * scope = start->scope ();
@@ -577,7 +577,7 @@ void CheckAutoVariablesImpl::checkVarLifetimeScope(const Token * start, const To
577577 for (const Token *tok = start; tok && tok != end; tok = tok->next ()) {
578578 // Return reference from function
579579 if (returnRef && Token::simpleMatch (tok->astParent (), " return" )) {
580- for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (tok, * mSettings , true )) {
580+ for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (tok, mSettings , true )) {
581581 if (!printInconclusive && lt.inconclusive )
582582 continue ;
583583 const Variable* var = lt.token ->variable ();
@@ -586,7 +586,7 @@ void CheckAutoVariablesImpl::checkVarLifetimeScope(const Token * start, const To
586586 errorReturnReference (tok, lt.errorPath , lt.inconclusive );
587587 break ;
588588 }
589- if (isDeadTemporary (lt.token , nullptr , mSettings -> library )) {
589+ if (isDeadTemporary (lt.token , nullptr , mSettings . library )) {
590590 errorReturnTempReference (tok, lt.errorPath , lt.inconclusive );
591591 break ;
592592 }
@@ -597,18 +597,18 @@ void CheckAutoVariablesImpl::checkVarLifetimeScope(const Token * start, const To
597597 tok->variable ()->declarationId () == tok->varId () && tok->variable ()->isStatic () &&
598598 !tok->variable ()->isArgument ()) {
599599 ErrorPath errorPath;
600- const Variable *var = ValueFlow::getLifetimeVariable (tok, errorPath, * mSettings );
600+ const Variable *var = ValueFlow::getLifetimeVariable (tok, errorPath, mSettings );
601601 if (var && isInScope (var->nameToken (), tok->scope ())) {
602602 errorDanglingReference (tok, var, std::move (errorPath));
603603 continue ;
604604 }
605605 // Reference to temporary
606606 } else if (tok->variable () && (tok->variable ()->isReference () || tok->variable ()->isRValueReference ())) {
607- for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (getParentLifetime (tok), * mSettings )) {
607+ for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (getParentLifetime (tok), mSettings )) {
608608 if (!printInconclusive && lt.inconclusive )
609609 continue ;
610610 const Token * tokvalue = lt.token ;
611- if (isDeadTemporary (tokvalue, tok, mSettings -> library )) {
611+ if (isDeadTemporary (tokvalue, tok, mSettings . library )) {
612612 errorDanglingTempReference (tok, lt.errorPath , lt.inconclusive );
613613 break ;
614614 }
@@ -622,23 +622,23 @@ void CheckAutoVariablesImpl::checkVarLifetimeScope(const Token * start, const To
622622 continue ;
623623 if (!printInconclusive && val.isInconclusive ())
624624 continue ;
625- const Token* parent = getParentLifetime (val.tokvalue , mSettings -> library );
625+ const Token* parent = getParentLifetime (val.tokvalue , mSettings . library );
626626 if (!exprs.insert (parent).second )
627627 continue ;
628- for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (parent, * mSettings , escape || isAssignedToNonLocal (tok))) {
628+ for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (parent, mSettings , escape || isAssignedToNonLocal (tok))) {
629629 const Token * tokvalue = lt.token ;
630630 if (val.isLocalLifetimeValue ()) {
631631 if (escape) {
632632 if (getPointerDepth (tok) < getPointerDepth (tokvalue))
633633 continue ;
634- if (!ValueFlow::isLifetimeBorrowed (tok, * mSettings ))
634+ if (!ValueFlow::isLifetimeBorrowed (tok, mSettings ))
635635 continue ;
636636 if (tokvalue->exprId () == tok->exprId () && !(tok->variable () && tok->variable ()->isArray ()) &&
637637 !astIsContainerView (tok->astParent ()))
638638 continue ;
639639 if ((tokvalue->variable () && !isEscapedReference (tokvalue->variable ()) &&
640640 isInScope (tokvalue->variable ()->nameToken (), scope)) ||
641- isDeadTemporary (tokvalue, nullptr , mSettings -> library )) {
641+ isDeadTemporary (tokvalue, nullptr , mSettings . library )) {
642642 if (!diag (tokvalue))
643643 errorReturnDanglingLifetime (tok, &val);
644644 break ;
@@ -647,7 +647,7 @@ void CheckAutoVariablesImpl::checkVarLifetimeScope(const Token * start, const To
647647 errorInvalidLifetime (tok, &val);
648648 break ;
649649 } else if (!tokvalue->variable () &&
650- isDeadTemporary (tokvalue, tok, mSettings -> library )) {
650+ isDeadTemporary (tokvalue, tok, mSettings . library )) {
651651 if (!diag (tokvalue))
652652 errorDanglingTemporaryLifetime (tok, &val, tokvalue);
653653 break ;
@@ -665,7 +665,7 @@ void CheckAutoVariablesImpl::checkVarLifetimeScope(const Token * start, const To
665665 } else if (tok->variable () && tok->variable ()->declarationId () == tok->varId ()) {
666666 var = tok->variable ();
667667 }
668- if (!ValueFlow::isLifetimeBorrowed (tok, * mSettings ))
668+ if (!ValueFlow::isLifetimeBorrowed (tok, mSettings ))
669669 continue ;
670670 const Token* nextTok = nextAfterAstRightmostLeaf (tok->astTop ());
671671 if (!nextTok)
@@ -677,7 +677,7 @@ void CheckAutoVariablesImpl::checkVarLifetimeScope(const Token * start, const To
677677 var->valueType () ? var->valueType ()->pointer : 0 ,
678678 var->declarationId (),
679679 var->isGlobal (),
680- * mSettings )) {
680+ mSettings )) {
681681 if (!diag (tok2))
682682 errorDanglngLifetime (tok2, &val, var->isLocal ());
683683 break ;
@@ -819,13 +819,13 @@ void CheckAutoVariablesImpl::errorInvalidDeallocation(const Token *tok, const Va
819819
820820void CheckAutoVariables::runChecks (const Tokenizer &tokenizer, ErrorLogger *errorLogger)
821821{
822- CheckAutoVariablesImpl checkAutoVariables (&tokenizer, & tokenizer.getSettings (), errorLogger);
822+ CheckAutoVariablesImpl checkAutoVariables (&tokenizer, tokenizer.getSettings (), errorLogger);
823823 checkAutoVariables.assignFunctionArg ();
824824 checkAutoVariables.autoVariables ();
825825 checkAutoVariables.checkVarLifetime ();
826826}
827827
828- void CheckAutoVariables::getErrorMessages (ErrorLogger *errorLogger, const Settings * settings) const
828+ void CheckAutoVariables::getErrorMessages (ErrorLogger *errorLogger, const Settings & settings) const
829829{
830830 CheckAutoVariablesImpl c (nullptr ,settings,errorLogger);
831831 c.errorAutoVariableAssignment (nullptr , false );
0 commit comments