Merge pull request #607 from simartin/simplify_known_var_todo
Simplify known variables when they are at the end of a statement.
This commit is contained in:
commit
bc2c172a1f
|
@ -6732,9 +6732,9 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// condition "(|&&|%OROR% %varid% )|&&|%OROR%
|
// condition "(|&&|%OROR% %varid% )|&&|%OROR%|;
|
||||||
if (!Token::Match(tok3->previous(), "( %name% )") &&
|
if (!Token::Match(tok3->previous(), "( %name% )") &&
|
||||||
Token::Match(tok3->previous(), "&&|(|%oror% %varid% &&|%oror%|)", varid)) {
|
Token::Match(tok3->previous(), "&&|(|%oror% %varid% &&|%oror%|)|;", varid)) {
|
||||||
tok3->str(value);
|
tok3->str(value);
|
||||||
tok3->varId(valueVarId);
|
tok3->varId(valueVarId);
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
|
@ -2231,8 +2231,7 @@ private:
|
||||||
"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(wanted, tokenizeDebugListing(code, true));
|
||||||
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2245,12 +2244,11 @@ private:
|
||||||
const char wanted[] = "\n\n##file 0\n"
|
const char wanted[] = "\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(wanted, tokenizeDebugListing(code, true));
|
||||||
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue