Make patterns compilable (mini refactoring)

This commit is contained in:
Thomas Jarosch 2015-01-09 23:43:45 +01:00
parent c971387ccd
commit 332254e0af
2 changed files with 9 additions and 6 deletions

View File

@ -402,9 +402,13 @@ void CheckBool::checkComparisonOfBoolExpressionWithInt()
continue;
if (numTok->isNumber()) {
if (numTok->str() == "0" && Token::Match(tok, numInRhs ? ">|==|!=" : "<|==|!="))
if (numTok->str() == "0" &&
(numInRhs ? Token::Match(tok, ">|==|!=")
: Token::Match(tok, "<|==|!=")))
continue;
if (numTok->str() == "1" && Token::Match(tok, numInRhs ? "<|==|!=" : ">|==|!="))
if (numTok->str() == "1" &&
(numInRhs ? Token::Match(tok, "<|==|!=")
: Token::Match(tok, ">|==|!=")))
continue;
comparisonOfBoolExpressionWithIntError(tok, true);
} else if (isNonBoolStdType(numTok->variable()))

View File

@ -458,12 +458,11 @@ void CheckNullPointer::removeAssignedVarFromSet(const Token* tok, std::set<unsig
{
// If a pointer's address is passed into a function, stop considering it
if (Token::Match(tok->previous(), "[;{}] %var% (")) {
// Common functions that are known NOT to modify their pointer argument
const char safeFunctions[] = "printf|sprintf|fprintf|vprintf";
const Token* endParen = tok->next()->link();
for (const Token* tok2 = tok->next(); tok2 != endParen; tok2 = tok2->next()) {
if (tok2->isName() && tok2->varId() > 0 && !Token::Match(tok, safeFunctions)) {
if (tok2->isName() && tok2->varId() > 0
// Common functions that are known NOT to modify their pointer argument
&& !Token::Match(tok, "printf|sprintf|fprintf|vprintf")) {
pointerArgs.erase(tok2->varId());
}
}