Fixed simplifyAssignmentInFunctionCall for complex expressions (#6927)

This commit is contained in:
PKEuS 2015-10-27 20:01:40 +01:00
parent 7866990d04
commit 4ee56d2306
2 changed files with 5 additions and 4 deletions

View File

@ -9178,12 +9178,12 @@ void Tokenizer::simplifyAssignmentInFunctionCall()
else if (Token::Match(tok, "[;{}] %name% ( %name% =") &&
Token::simpleMatch(tok->linkAt(2), ") ;") &&
!Token::Match(tok->next(), "assert|while")) {
const std::string funcname(tok->next()->str());
const Token * const vartok = tok->tokAt(3);
const std::string& funcname(tok->next()->str());
Token* const vartok = tok->tokAt(3);
// Goto ',' or ')'..
for (Token *tok2 = tok->tokAt(4); tok2; tok2 = tok2->next()) {
if (tok2->str() == "(")
for (Token *tok2 = vartok->tokAt(2); tok2; tok2 = tok2->next()) {
if (tok2->link() && Token::Match(tok2, "(|[|{"))
tok2 = tok2->link();
else if (tok2->str() == ";")
break;

View File

@ -5672,6 +5672,7 @@ private:
void simplifyAssignmentInFunctionCall() {
ASSERT_EQUALS("; x = g ( ) ; f ( x ) ;", tokenizeAndStringify(";f(x=g());"));
ASSERT_EQUALS("; hs = ( xyz_t ) { h . centerX , h . centerY , 1 + index } ; putInput ( hs , 1 ) ;", tokenizeAndStringify(";putInput(hs = (xyz_t) { h->centerX, h->centerY, 1 + index }, 1);"));
}
void simplifyRoundCurlyParentheses() {