Tokenizer: improved the simplifyInitVar
This commit is contained in:
parent
3b08712930
commit
8716c771a4
|
@ -4126,9 +4126,12 @@ void Tokenizer::simplifyInitVar()
|
|||
{
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "[{};] %type% *| %var% ( %num% ) ;") &&
|
||||
tok->next()->isStandardType())
|
||||
if (Token::Match(tok, "[{};] %type% *| %var% ( %num% ) ;"))
|
||||
{
|
||||
// call constructor of class => no simplification
|
||||
if (!tok->next()->isStandardType() && tok->tokAt(2)->str() != "*")
|
||||
continue;
|
||||
|
||||
// goto variable name..
|
||||
tok = tok->tokAt(2);
|
||||
if (tok->str() == "*")
|
||||
|
|
|
@ -3237,9 +3237,21 @@ private:
|
|||
void simplifyInitVar()
|
||||
{
|
||||
// ticket #1005 - int *p(0); => int *p = 0;
|
||||
{
|
||||
const char code[] = "void foo() { int *p(0); }";
|
||||
ASSERT_EQUALS("void foo ( ) { int * p ; p = 0 ; }", tok(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void foo() { int p(0); }";
|
||||
ASSERT_EQUALS("void foo ( ) { int p ; p = 0 ; }", tok(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void a() { foo *p(0); }";
|
||||
ASSERT_EQUALS("void a ( ) { foo * p ; p = 0 ; }", tok(code));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSimplifyTokens)
|
||||
|
|
Loading…
Reference in New Issue