oops, remove some leftover commented-out debug code and run astyle.

This commit is contained in:
Matthias Krüger 2018-01-01 05:04:59 +01:00
parent af9b9595ce
commit 1f3ca7ddf6
1 changed files with 19 additions and 24 deletions

View File

@ -88,36 +88,31 @@ void CheckInternal::checkTokenMatchPatterns()
void CheckInternal::checkRedundantTokCheck()
{
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
if (Token::Match(tok, "&& Token :: simpleMatch|Match|findsimplematch|findmatch (")) {
// in code like
// if (tok->previous() && Token::match(tok->previous(), "bla")) {}
// the first tok->previous() check is redundant
const Token *astOp1 = tok->astOperand1();
const Token *astOp2 = getArguments(tok->tokAt(3))[0];
// std::cout << "\n astOp1: " << tok->astOperand1()->str() << ""; // tok
// std::cout << "\n astOp2: " << getArguments(tok->tokAt(3))[0]->str() << "\n "; // tok
// std::cout << "\n";
if (astOp1->expressionString() == astOp2->expressionString()) {
checkRedundantTokCheckError(astOp2);
}
// if (!tok || !Token::match(tok, "foo"))
} else if (Token::Match(tok, "%oror% ! Token :: simpleMatch|Match|findsimplematch|findmatch (")) {
// the first tok condition is negated
const Token *negTok = tok->next()->astParent()->astOperand1();
if (Token::simpleMatch(negTok, "!")) {
const Token *astOp1 = negTok->astOperand1();
const Token *astOp2 = getArguments(tok->tokAt(4))[0];
if (Token::Match(tok, "&& Token :: simpleMatch|Match|findsimplematch|findmatch (")) {
// in code like
// if (tok->previous() && Token::match(tok->previous(), "bla")) {}
// the first tok->previous() check is redundant
const Token *astOp1 = tok->astOperand1();
const Token *astOp2 = getArguments(tok->tokAt(3))[0];
if (astOp1->expressionString() == astOp2->expressionString()) {
checkRedundantTokCheckError(astOp2);
}
}
// if (!tok || !Token::match(tok, "foo"))
} else if (Token::Match(tok, "%oror% ! Token :: simpleMatch|Match|findsimplematch|findmatch (")) {
const Token *negTok = tok->next()->astParent()->astOperand1();
// the first tok condition is negated
if (Token::simpleMatch(negTok, "!")) {
const Token *astOp1 = negTok->astOperand1();
const Token *astOp2 = getArguments(tok->tokAt(4))[0];
if (astOp1->expressionString() == astOp2->expressionString()) {
checkRedundantTokCheckError(astOp2);
}
}
}
}
}
}
void CheckInternal::checkRedundantTokCheckError(const Token* tok)