tokenizer: improved the simplification of '*(var+num)' => 'var[num]'
This commit is contained in:
parent
56d685c179
commit
b1982b2041
|
@ -922,6 +922,8 @@ void Tokenizer::simplifyTokenList()
|
|||
|
||||
if (Token::Match(next, "* ( %var% + %num% )"))
|
||||
{
|
||||
unsigned int varid = tok->tokAt(3)->varId();
|
||||
|
||||
const char *str[4] = {"var", "[", "num", "]"};
|
||||
str[0] = tok->strAt(3);
|
||||
str[2] = tok->strAt(5);
|
||||
|
@ -930,6 +932,8 @@ void Tokenizer::simplifyTokenList()
|
|||
{
|
||||
tok = tok->next();
|
||||
tok->str(str[i]);
|
||||
if (i == 0)
|
||||
tok->varId(varid);
|
||||
}
|
||||
|
||||
tok->deleteNext();
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
TEST_CASE(varid1);
|
||||
TEST_CASE(varid2);
|
||||
TEST_CASE(varid3);
|
||||
// TODO TEST_CASE(varid4); // There is currently a problem for "*(a+10)" => "a[10]"
|
||||
TEST_CASE(varid4);
|
||||
// TODO TEST_CASE(varid5); // There is currently a problem for "int a,b;" => "int a; int b;"
|
||||
|
||||
TEST_CASE(file1);
|
||||
|
|
Loading…
Reference in New Issue