Tokenizer::simplifyKnownVariables: Fixed TODO testcase (better handling of ^)
This commit is contained in:
parent
472d8154ca
commit
2182ede486
|
@ -6618,10 +6618,10 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
||||||
|
|
||||||
// Variable is used in calculation..
|
// Variable is used in calculation..
|
||||||
if (((tok3->previous()->varId() > 0) && Token::Match(tok3, ("& " + structname + " %varid%").c_str(), varid)) ||
|
if (((tok3->previous()->varId() > 0) && 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, ("[(=+-*/%^|[] " + 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(), ("[=+-*/%|[] ( " + structname + " %varid%").c_str(), varid))
|
Token::Match(tok3->previous(), ("[=+-*/%^|[] ( " + structname + " %varid%").c_str(), varid))
|
||||||
{
|
{
|
||||||
if (!structname.empty())
|
if (!structname.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1654,21 +1654,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: int foo ( int u@1 , int v@2 )\n"
|
"1: int 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: int 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue