tokenizer: improved the simplification of '*(var+num)' => 'var[num]'

This commit is contained in:
Daniel Marjamäki 2009-02-15 14:02:57 +00:00
parent 56d685c179
commit b1982b2041
2 changed files with 5 additions and 1 deletions

View File

@ -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();

View File

@ -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);