Skip to content

Commit

Permalink
Update checkother.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Apr 17, 2024
1 parent 3a212f1 commit 320381f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,16 @@ static bool isSimpleExpr(const Token* tok, const Variable* var, const Settings*
return true;
bool needsCheck = tok->varId() > 0;
if (!needsCheck) {
if (tok->isArithmeticalOp())
return isSimpleExpr(tok->astOperand1(), var, settings) && (!tok->astOperand2() || isSimpleExpr(tok->astOperand2(), var, settings));
const Token* ftok = tok->previous();
if (Token::Match(ftok, "%name% (") &&
((ftok->function() && ftok->function()->isConst()) || settings->library.isFunctionConst(ftok->str(), /*pure*/ true)))
needsCheck = true;
if (tok->isArithmeticalOp() &&
(!tok->astOperand1() || isSimpleExpr(tok->astOperand1(), var, settings)) &&
(!tok->astOperand2() || isSimpleExpr(tok->astOperand2(), var, settings)))
return true;
else if (tok->str() == "[")
needsCheck = tok->astOperand1() && tok->astOperand1()->varId() > 0;
else if (isLeafDot(tok->astOperand2()))
needsCheck = tok->astOperand2()->varId() > 0;
}
return (needsCheck && !findExpressionChanged(tok, tok->astParent(), var->scope()->bodyEnd, settings));
}
Expand Down

0 comments on commit 320381f

Please sign in to comment.