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:
PKEuS 2015-08-21 12:34:53 +02:00
parent 6b4a0a5ed7
commit c8c59aa92b
3 changed files with 0 additions and 35 deletions

View File

@ -3602,7 +3602,6 @@ bool Tokenizer::simplifyTokenList2()
simplifyErrNoInWhile(); simplifyErrNoInWhile();
simplifyIfAndWhileAssign(); simplifyIfAndWhileAssign();
simplifyRedundantParentheses(); simplifyRedundantParentheses();
simplifyIfSameInnerCondition();
simplifyNestedStrcat(); simplifyNestedStrcat();
simplifyFuncInWhile(); 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 // Binary operators simplification map
namespace { namespace {
const std::map<std::string, std::string> cAlternativeTokens = make_container< std::map<std::string, std::string> >() const std::map<std::string, std::string> cAlternativeTokens = make_container< std::map<std::string, std::string> >()

View File

@ -305,9 +305,6 @@ public:
*/ */
void simplifyVariableMultipleAssign(); void simplifyVariableMultipleAssign();
/** @brief simplify if (a) { if (a) */
void simplifyIfSameInnerCondition();
/** /**
* Simplify the 'C Alternative Tokens' * Simplify the 'C Alternative Tokens'
* Examples: * Examples:

View File

@ -59,7 +59,6 @@ private:
TEST_CASE(removePreIncrement); TEST_CASE(removePreIncrement);
TEST_CASE(elseif1); TEST_CASE(elseif1);
TEST_CASE(ifa_ifa); // "if (a) { if (a) .." => "if (a) { if (1) .."
TEST_CASE(sizeof_array); TEST_CASE(sizeof_array);
TEST_CASE(sizeof5); 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[]) { unsigned int sizeofFromTokenizer(const char type[]) {
errout.str(""); errout.str("");