Tokenizer::simplifyKnownVariables: Fixed TODO testcases (better handling of comparisons)
This commit is contained in:
parent
2182ede486
commit
0d2d0c864a
|
@ -6527,7 +6527,7 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
||||||
// Using the variable in condition..
|
// Using the variable in condition..
|
||||||
if (Token::Match(tok3->previous(), ("if ( " + structname + " %varid% ==|!=|<|<=|>|>=|)").c_str(), varid) ||
|
if (Token::Match(tok3->previous(), ("if ( " + structname + " %varid% ==|!=|<|<=|>|>=|)").c_str(), varid) ||
|
||||||
Token::Match(tok3, ("( " + structname + " %varid% ==|!=|<|<=|>|>=").c_str(), varid) ||
|
Token::Match(tok3, ("( " + structname + " %varid% ==|!=|<|<=|>|>=").c_str(), varid) ||
|
||||||
Token::Match(tok3, ("!|==|!=|<|<=|>|>= " + structname + " %varid% ==|!=|<|<=|>|>=|)").c_str(), varid) ||
|
Token::Match(tok3, ("!|==|!=|<|<=|>|>= " + structname + " %varid% ==|!=|<|<=|>|>=|)|;").c_str(), varid) ||
|
||||||
Token::Match(tok3->previous(), "strlen|free ( %varid% )", varid))
|
Token::Match(tok3->previous(), "strlen|free ( %varid% )", varid))
|
||||||
{
|
{
|
||||||
if (!structname.empty())
|
if (!structname.empty())
|
||||||
|
|
|
@ -1722,22 +1722,14 @@ private:
|
||||||
" int i = v;\n"
|
" int i = v;\n"
|
||||||
" return h == i;\n"
|
" return h == i;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char wanted[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ;\n"
|
"3: ;\n"
|
||||||
"4: ;\n"
|
"4:\n"
|
||||||
"5: return u@1 == v@2 ;\n"
|
"5: return u@1 == v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
const char current[] = "\n\n##file 0\n"
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
|
||||||
"2: {\n"
|
|
||||||
"3: ;\n"
|
|
||||||
"4: int i@4 ; i@4 = v@2 ;\n"
|
|
||||||
"5: return u@1 == i@4 ;\n"
|
|
||||||
"6: }\n";
|
|
||||||
|
|
||||||
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1747,21 +1739,14 @@ private:
|
||||||
" int i = v;\n"
|
" int i = v;\n"
|
||||||
" return h != i;\n"
|
" return h != i;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char wanted[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
|
||||||
"2: {\n"
|
|
||||||
"3: ;\n"
|
|
||||||
"4: ;\n"
|
|
||||||
"5: return u@1 != v@2 ;\n"
|
|
||||||
"6: }\n";
|
|
||||||
const char current[] = "\n\n##file 0\n"
|
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ;\n"
|
"3: ;\n"
|
||||||
"4: int i@4 ; i@4 = v@2 ;\n"
|
"4:\n"
|
||||||
"5: return u@1 != i@4 ;\n"
|
"5: return u@1 != v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1771,15 +1756,14 @@ private:
|
||||||
" int i = v;\n"
|
" int i = v;\n"
|
||||||
" return h > i;\n"
|
" return h > i;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char wanted[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ;\n"
|
"3: ;\n"
|
||||||
"4: ;\n"
|
"4:\n"
|
||||||
"5: return u@1 > v@2 ;\n"
|
"5: return u@1 > v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
const char current[] = "\n\n##file 0\n1: bool foo ( int u@1 , int v@2 )\n2: {\n3: ;\n4: int i@4 ; i@4 = v@2 ;\n5: return u@1 > i@4 ;\n6: }\n";
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1789,15 +1773,14 @@ private:
|
||||||
" int i = v;\n"
|
" int i = v;\n"
|
||||||
" return h >= i;\n"
|
" return h >= i;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char wanted[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ;\n"
|
"3: ;\n"
|
||||||
"4: ;\n"
|
"4:\n"
|
||||||
"5: return u@1 >= v@2 ;\n"
|
"5: return u@1 >= v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
const char current[] = "\n\n##file 0\n1: bool foo ( int u@1 , int v@2 )\n2: {\n3: ;\n4: int i@4 ; i@4 = v@2 ;\n5: return u@1 >= i@4 ;\n6: }\n";
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1807,15 +1790,14 @@ private:
|
||||||
" int i = v;\n"
|
" int i = v;\n"
|
||||||
" return h < i;\n"
|
" return h < i;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char wanted[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ;\n"
|
"3: ;\n"
|
||||||
"4: ;\n"
|
"4:\n"
|
||||||
"5: return u@1 < v@2 ;\n"
|
"5: return u@1 < v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
const char current[] = "\n\n##file 0\n1: bool foo ( int u@1 , int v@2 )\n2: {\n3: ;\n4: int i@4 ; i@4 = v@2 ;\n5: return u@1 < i@4 ;\n6: }\n";
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1825,15 +1807,14 @@ private:
|
||||||
" int i = v;\n"
|
" int i = v;\n"
|
||||||
" return h <= i;\n"
|
" return h <= i;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char wanted[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ;\n"
|
"3: ;\n"
|
||||||
"4: ;\n"
|
"4:\n"
|
||||||
"5: return u@1 <= v@2 ;\n"
|
"5: return u@1 <= v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
const char current[] = "\n\n##file 0\n1: bool foo ( int u@1 , int v@2 )\n2: {\n3: ;\n4: int i@4 ; i@4 = v@2 ;\n5: return u@1 <= i@4 ;\n6: }\n";
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue