Tokenizer: remove simplifyAssignmentInFunctionCall used in simplifyTokenList2
This commit is contained in:
parent
1275b5275e
commit
c0f3d5b2fb
|
@ -5275,9 +5275,6 @@ bool Tokenizer::simplifyTokenList2()
|
|||
tok->clearValueFlow();
|
||||
}
|
||||
|
||||
// f(x=g()) => x=g(); f(x)
|
||||
simplifyAssignmentInFunctionCall();
|
||||
|
||||
// ";a+=b;" => ";a=a+b;"
|
||||
simplifyCompoundAssignment();
|
||||
|
||||
|
@ -11172,45 +11169,6 @@ void Tokenizer::simplifyDebug()
|
|||
}
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyAssignmentInFunctionCall()
|
||||
{
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (tok->str() == "(")
|
||||
tok = tok->link();
|
||||
|
||||
// Find 'foo(var='. Exclude 'assert(var=' to allow tests to check that assert(...) does not contain side-effects
|
||||
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());
|
||||
Token* const vartok = tok->tokAt(3);
|
||||
|
||||
// Goto ',' or ')'..
|
||||
for (Token *tok2 = vartok->tokAt(2); tok2; tok2 = tok2->next()) {
|
||||
if (tok2->link() && Token::Match(tok2, "(|[|{"))
|
||||
tok2 = tok2->link();
|
||||
else if (tok2->str() == ";")
|
||||
break;
|
||||
else if (Token::Match(tok2, ")|,")) {
|
||||
tok2 = tok2->previous();
|
||||
|
||||
tok2->insertToken(vartok->str());
|
||||
tok2->next()->varId(vartok->varId());
|
||||
|
||||
tok2->insertToken("(");
|
||||
Token::createMutualLinks(tok2->next(), tok->linkAt(2));
|
||||
|
||||
tok2->insertToken(funcname);
|
||||
tok2->insertToken(";");
|
||||
|
||||
Token::eraseTokens(tok, vartok);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyAssignmentBlock()
|
||||
{
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -218,10 +218,6 @@ public:
|
|||
*/
|
||||
bool isFunctionParameterPassedByValue(const Token *fpar) const;
|
||||
|
||||
/** Simplify assignment in function call "f(x=g());" => "x=g();f(x);"
|
||||
*/
|
||||
void simplifyAssignmentInFunctionCall();
|
||||
|
||||
/** Simplify assignment where rhs is a block : "x=({123;});" => "{x=123;}" */
|
||||
void simplifyAssignmentBlock();
|
||||
|
||||
|
|
|
@ -60,9 +60,6 @@ private:
|
|||
|
||||
TEST_CASE(test1); // array access. replace "*(p+1)" => "p[1]"
|
||||
|
||||
// foo(p = new char[10]); => p = new char[10]; foo(p);
|
||||
TEST_CASE(simplifyAssignmentInFunctionCall);
|
||||
|
||||
// ";a+=b;" => ";a=a+b;"
|
||||
TEST_CASE(simplifyCompoundAssignment);
|
||||
|
||||
|
@ -1777,11 +1774,6 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void simplifyAssignmentInFunctionCall() {
|
||||
ASSERT_EQUALS("; x = g ( ) ; f ( x ) ;", tok(";f(x=g());"));
|
||||
ASSERT_EQUALS("; hs = ( xyz_t ) { h . centerX , h . centerY , 1 + index } ; putInput ( hs , 1 ) ;", tok(";putInput(hs = (xyz_t) { h->centerX, h->centerY, 1 + index }, 1);"));
|
||||
}
|
||||
|
||||
void simplifyCompoundAssignment() {
|
||||
ASSERT_EQUALS("; x = x + y ;", tok("; x += y;"));
|
||||
ASSERT_EQUALS("; x = x - y ;", tok("; x -= y;"));
|
||||
|
|
Loading…
Reference in New Issue