add support for global namespace to Tokenizer::simplifyVarDecl()
This commit is contained in:
parent
fc258164cd
commit
710eb8ffd9
|
@ -5644,7 +5644,7 @@ void Tokenizer::simplifyVarDecl()
|
|||
continue;
|
||||
|
||||
Token *type0 = tok;
|
||||
if (!Token::Match(type0, "%type%"))
|
||||
if (!Token::Match(type0, "::| %type%"))
|
||||
continue;
|
||||
if (Token::Match(type0, "else|return|public:|protected:|private:"))
|
||||
continue;
|
||||
|
@ -5675,6 +5675,12 @@ void Tokenizer::simplifyVarDecl()
|
|||
continue;
|
||||
|
||||
// check for qualification..
|
||||
if (Token::Match(tok2, ":: %type%"))
|
||||
{
|
||||
typelen++;
|
||||
tok2 = tok2->next();
|
||||
}
|
||||
|
||||
if (Token::Match(tok2, "%type% :: %type%"))
|
||||
{
|
||||
while (tok2 && Token::Match(tok2, "%type% ::"))
|
||||
|
|
|
@ -239,6 +239,7 @@ private:
|
|||
TEST_CASE(vardecl11);
|
||||
TEST_CASE(vardecl12);
|
||||
TEST_CASE(vardecl13);
|
||||
TEST_CASE(vardecl14);
|
||||
TEST_CASE(vardecl_stl_1);
|
||||
TEST_CASE(vardecl_stl_2);
|
||||
TEST_CASE(vardecl_template);
|
||||
|
@ -4251,6 +4252,12 @@ private:
|
|||
ASSERT_EQUALS("void f ( ) {\nint a ; a = ( x < y ) ? 1 : 0 ;\n}", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void vardecl14()
|
||||
{
|
||||
const char code[] = "::std::tr1::shared_ptr<int> pNum1, pNum2;\n";
|
||||
ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void volatile_variables()
|
||||
{
|
||||
const char code[] = "volatile int a=0;\n"
|
||||
|
|
Loading…
Reference in New Issue