add support for global namespace to Tokenizer::simplifyVarDecl()

This commit is contained in:
Robert Reif 2011-03-24 23:06:20 -04:00
parent fc258164cd
commit 710eb8ffd9
2 changed files with 14 additions and 1 deletions

View File

@ -5644,7 +5644,7 @@ void Tokenizer::simplifyVarDecl()
continue; continue;
Token *type0 = tok; Token *type0 = tok;
if (!Token::Match(type0, "%type%")) if (!Token::Match(type0, "::| %type%"))
continue; continue;
if (Token::Match(type0, "else|return|public:|protected:|private:")) if (Token::Match(type0, "else|return|public:|protected:|private:"))
continue; continue;
@ -5675,6 +5675,12 @@ void Tokenizer::simplifyVarDecl()
continue; continue;
// check for qualification.. // check for qualification..
if (Token::Match(tok2, ":: %type%"))
{
typelen++;
tok2 = tok2->next();
}
if (Token::Match(tok2, "%type% :: %type%")) if (Token::Match(tok2, "%type% :: %type%"))
{ {
while (tok2 && Token::Match(tok2, "%type% ::")) while (tok2 && Token::Match(tok2, "%type% ::"))

View File

@ -239,6 +239,7 @@ private:
TEST_CASE(vardecl11); TEST_CASE(vardecl11);
TEST_CASE(vardecl12); TEST_CASE(vardecl12);
TEST_CASE(vardecl13); TEST_CASE(vardecl13);
TEST_CASE(vardecl14);
TEST_CASE(vardecl_stl_1); TEST_CASE(vardecl_stl_1);
TEST_CASE(vardecl_stl_2); TEST_CASE(vardecl_stl_2);
TEST_CASE(vardecl_template); TEST_CASE(vardecl_template);
@ -4251,6 +4252,12 @@ private:
ASSERT_EQUALS("void f ( ) {\nint a ; a = ( x < y ) ? 1 : 0 ;\n}", tokenizeAndStringify(code)); 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() void volatile_variables()
{ {
const char code[] = "volatile int a=0;\n" const char code[] = "volatile int a=0;\n"