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())
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
if (Token::Match(tok, "[{};] %type% *| %var% ( %num% ) ;") &&
|
if (Token::Match(tok, "[{};] %type% *| %var% ( %num% ) ;"))
|
||||||
tok->next()->isStandardType())
|
|
||||||
{
|
{
|
||||||
|
// call constructor of class => no simplification
|
||||||
|
if (!tok->next()->isStandardType() && tok->tokAt(2)->str() != "*")
|
||||||
|
continue;
|
||||||
|
|
||||||
// goto variable name..
|
// goto variable name..
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
if (tok->str() == "*")
|
if (tok->str() == "*")
|
||||||
|
|
|
@ -3237,8 +3237,20 @@ private:
|
||||||
void simplifyInitVar()
|
void simplifyInitVar()
|
||||||
{
|
{
|
||||||
// ticket #1005 - int *p(0); => int *p = 0;
|
// 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 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue