From 1f3ca7ddf6f9e54b2aa630d405f18b306fb6e9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 1 Jan 2018 05:04:59 +0100 Subject: [PATCH] oops, remove some leftover commented-out debug code and run astyle. --- lib/checkinternal.cpp | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/lib/checkinternal.cpp b/lib/checkinternal.cpp index f9c1e0c7d..c31c06a9e 100644 --- a/lib/checkinternal.cpp +++ b/lib/checkinternal.cpp @@ -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)