Skip to content

Commit

Permalink
Fix bailout
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Apr 29, 2024
1 parent f3ffef9 commit bf92af3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/checkassert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,20 @@ void CheckAssert::assertWithSideEffects()
for (const Token* tmp = tok->next(); tmp != endTok; tmp = tmp->next()) {
if (Token::simpleMatch(tmp, "sizeof ("))
tmp = tmp->linkAt(1);
if (findLambdaEndToken(tmp)) // bailout
break;

checkVariableAssignment(tmp, tok->scope());

if (tmp->tokType() != Token::eFunction) {
if (const Library::Function* f = mSettings->library.getFunction(tmp)) {
if (f->isconst || f->ispure)
continue;
if (Library::getContainerYield(tmp->next()) != Library::Container::Yield::NO_YIELD) // bailout, assume read access
continue;
if (!f->isconst && !f->ispure)
sideEffectInAssertError(tmp, mSettings->library.getFunctionName(tmp));
if (std::any_of(f->argumentChecks.begin(), f->argumentChecks.end(), [](const std::pair<int, Library::ArgumentChecks>& ac) {
return ac.second.iteratorInfo.container > 0; // bailout, takes iterators -> assume read access
}))
continue;
sideEffectInAssertError(tmp, mSettings->library.getFunctionName(tmp));
}
continue;
}
Expand Down

0 comments on commit bf92af3

Please sign in to comment.