Skip to content

Commit 332254e

Browse files
committed
Make patterns compilable (mini refactoring)
1 parent c971387 commit 332254e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/checkbool.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,13 @@ void CheckBool::checkComparisonOfBoolExpressionWithInt()
402402
continue;
403403

404404
if (numTok->isNumber()) {
405-
if (numTok->str() == "0" && Token::Match(tok, numInRhs ? ">|==|!=" : "<|==|!="))
405+
if (numTok->str() == "0" &&
406+
(numInRhs ? Token::Match(tok, ">|==|!=")
407+
: Token::Match(tok, "<|==|!=")))
406408
continue;
407-
if (numTok->str() == "1" && Token::Match(tok, numInRhs ? "<|==|!=" : ">|==|!="))
409+
if (numTok->str() == "1" &&
410+
(numInRhs ? Token::Match(tok, "<|==|!=")
411+
: Token::Match(tok, ">|==|!=")))
408412
continue;
409413
comparisonOfBoolExpressionWithIntError(tok, true);
410414
} else if (isNonBoolStdType(numTok->variable()))

lib/checknullpointer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,11 @@ void CheckNullPointer::removeAssignedVarFromSet(const Token* tok, std::set<unsig
458458
{
459459
// If a pointer's address is passed into a function, stop considering it
460460
if (Token::Match(tok->previous(), "[;{}] %var% (")) {
461-
// Common functions that are known NOT to modify their pointer argument
462-
const char safeFunctions[] = "printf|sprintf|fprintf|vprintf";
463-
464461
const Token* endParen = tok->next()->link();
465462
for (const Token* tok2 = tok->next(); tok2 != endParen; tok2 = tok2->next()) {
466-
if (tok2->isName() && tok2->varId() > 0 && !Token::Match(tok, safeFunctions)) {
463+
if (tok2->isName() && tok2->varId() > 0
464+
// Common functions that are known NOT to modify their pointer argument
465+
&& !Token::Match(tok, "printf|sprintf|fprintf|vprintf")) {
467466
pointerArgs.erase(tok2->varId());
468467
}
469468
}

0 commit comments

Comments
 (0)