Preserve varId in simplifyArrayAccessSyntax (#6523)
This commit is contained in:
parent
8a7d62cec8
commit
5c348890b2
|
@ -2054,6 +2054,7 @@ void Tokenizer::simplifyArrayAccessSyntax()
|
||||||
if (Token::Match(tok, "%num% [ %name% ]")) {
|
if (Token::Match(tok, "%num% [ %name% ]")) {
|
||||||
std::string temp = tok->str();
|
std::string temp = tok->str();
|
||||||
tok->str(tok->strAt(2));
|
tok->str(tok->strAt(2));
|
||||||
|
tok->varId(tok->tokAt(2)->varId());
|
||||||
tok->tokAt(2)->str(temp);
|
tok->tokAt(2)->str(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ private:
|
||||||
TEST_CASE(simplifyOperator1);
|
TEST_CASE(simplifyOperator1);
|
||||||
TEST_CASE(simplifyOperator2);
|
TEST_CASE(simplifyOperator2);
|
||||||
|
|
||||||
TEST_CASE(reverseArraySyntax)
|
TEST_CASE(simplifyArrayAccessSyntax)
|
||||||
TEST_CASE(simplify_numeric_condition)
|
TEST_CASE(simplify_numeric_condition)
|
||||||
TEST_CASE(simplify_condition);
|
TEST_CASE(simplify_condition);
|
||||||
|
|
||||||
|
@ -2523,8 +2523,9 @@ private:
|
||||||
"}"));
|
"}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void reverseArraySyntax() {
|
void simplifyArrayAccessSyntax() {
|
||||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
ASSERT_EQUALS("\n\n##file 0\n"
|
||||||
|
"1: int a@1 ; a@1 [ 13 ] ;\n", tokenizeDebugListing("int a; 13[a];"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplify_numeric_condition() {
|
void simplify_numeric_condition() {
|
||||||
|
|
Loading…
Reference in New Issue