Removed Tokenizer::simplifyIfSameInnerCondition(). It covered only very simple patterns and is unlikely to have an impact on real-world code.
This commit is contained in:
parent
6b4a0a5ed7
commit
c8c59aa92b
|
@ -3602,7 +3602,6 @@ bool Tokenizer::simplifyTokenList2()
|
|||
simplifyErrNoInWhile();
|
||||
simplifyIfAndWhileAssign();
|
||||
simplifyRedundantParentheses();
|
||||
simplifyIfSameInnerCondition();
|
||||
simplifyNestedStrcat();
|
||||
simplifyFuncInWhile();
|
||||
|
||||
|
@ -5911,31 +5910,6 @@ void Tokenizer::simplifyVariableMultipleAssign()
|
|||
}
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyIfSameInnerCondition()
|
||||
{
|
||||
// same inner condition
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "if ( %name% ) {")) {
|
||||
const unsigned int varid(tok->tokAt(2)->varId());
|
||||
if (!varid)
|
||||
continue;
|
||||
|
||||
for (Token *tok2 = tok->tokAt(5); tok2; tok2 = tok2->next()) {
|
||||
if (Token::Match(tok2, "{|}"))
|
||||
break;
|
||||
if (Token::simpleMatch(tok2, "if (")) {
|
||||
tok2 = tok2->tokAt(2);
|
||||
if (Token::Match(tok2, "%varid% )", varid))
|
||||
tok2->str("true");
|
||||
else if (Token::Match(tok2, "! %varid% )", varid))
|
||||
tok2->next()->varId(varid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Binary operators simplification map
|
||||
namespace {
|
||||
const std::map<std::string, std::string> cAlternativeTokens = make_container< std::map<std::string, std::string> >()
|
||||
|
|
|
@ -305,9 +305,6 @@ public:
|
|||
*/
|
||||
void simplifyVariableMultipleAssign();
|
||||
|
||||
/** @brief simplify if (a) { if (a) */
|
||||
void simplifyIfSameInnerCondition();
|
||||
|
||||
/**
|
||||
* Simplify the 'C Alternative Tokens'
|
||||
* Examples:
|
||||
|
|
|
@ -59,7 +59,6 @@ private:
|
|||
TEST_CASE(removePreIncrement);
|
||||
|
||||
TEST_CASE(elseif1);
|
||||
TEST_CASE(ifa_ifa); // "if (a) { if (a) .." => "if (a) { if (1) .."
|
||||
|
||||
TEST_CASE(sizeof_array);
|
||||
TEST_CASE(sizeof5);
|
||||
|
@ -854,11 +853,6 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void ifa_ifa() {
|
||||
ASSERT_EQUALS("int a ; if ( a ) { { ab } cd }", tok("int a ; if (a) { if (a) { ab } cd }", true));
|
||||
}
|
||||
|
||||
|
||||
unsigned int sizeofFromTokenizer(const char type[]) {
|
||||
errout.str("");
|
||||
|
||||
|
|
Loading…
Reference in New Issue