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:
amai2012 2015-05-31 06:50:55 +02:00
commit bc2c172a1f
2 changed files with 6 additions and 8 deletions

View File

@ -6732,9 +6732,9 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
ret = true;
}
// condition "(|&&|%OROR% %varid% )|&&|%OROR%
// condition "(|&&|%OROR% %varid% )|&&|%OROR%|;
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->varId(valueVarId);
ret = true;

View File

@ -2231,8 +2231,7 @@ private:
"4:\n"
"5: return u@1 && v@2 ;\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";
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
ASSERT_EQUALS(wanted, tokenizeDebugListing(code, true));
}
{
@ -2245,12 +2244,11 @@ private:
const char wanted[] = "\n\n##file 0\n"
"1: bool foo ( int u@1 , int v@2 )\n"
"2: {\n"
"3: ;\n"
"4: ;\n"
"3:\n"
"4:\n"
"5: return u@1 || v@2 ;\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";
TODO_ASSERT_EQUALS(wanted, current, tokenizeDebugListing(code, true));
ASSERT_EQUALS(wanted, tokenizeDebugListing(code, true));
}
}