diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 305eef748..17403808f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2728,55 +2728,6 @@ void Tokenizer::setVarId() } } - -//--------------------------------------------------------------------------- -// Simplify token list -//--------------------------------------------------------------------------- - -void Tokenizer::simplifyNamespaces() -{ - for (Token *token = _tokens; token; token = token->next()) - { - while (token && token->str() == "namespace" && token->varId() == 0 && - (!token->previous() || token->previous()->str() != "using")) - { - // Token is namespace and there is no "using" before it. - Token *start = token; - Token *tok = token->tokAt(2); - if (!tok) - return; - - tok = tok->link(); - if (tok && tok->str() == "}") - { - tok = tok->previous(); - tok->deleteNext(); - start->deleteNext(); - start->deleteNext(); - if (start->previous()) - { - token = start->next(); - start = start->previous(); - start->deleteNext(); - } - else - { - // First token in the list, don't delete - // as _tokens is attached to it. - start->deleteThis(); - } - } - else - { - return; - } - } - - if (!token) - break; - } -} - bool Tokenizer::createLinks() { std::list type; @@ -3161,8 +3112,6 @@ bool Tokenizer::simplifyTokenList() simplifyStd(); - simplifyNamespaces(); - simplifyGoto(); // Combine wide strings diff --git a/lib/tokenize.h b/lib/tokenize.h index d9855dedf..b9bf7a8cd 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -325,12 +325,6 @@ public: */ void simplifyFunctionParameters(); - /** - * Simplify namespaces by removing them, e.g. - * "namespace b{ void f(){} }" becomes "void f(){}" - */ - void simplifyNamespaces(); - /** * Simplify templates */ diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 40f179300..4c77998d2 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1862,7 +1862,7 @@ private: { const char code[] = "using namespace std; namespace a{ namespace b{ void f(){} } }"; - const std::string expected("using namespace std ; void f ( ) { }"); + const std::string expected("using namespace std ; namespace a { namespace b { void f ( ) { } } }"); ASSERT_EQUALS(expected, sizeof_(code)); } @@ -1870,7 +1870,7 @@ private: { const char code[] = "namespace b{ void f(){} }"; - const std::string expected("void f ( ) { }"); + const std::string expected("namespace b { void f ( ) { } }"); ASSERT_EQUALS(expected, sizeof_(code)); } @@ -1878,7 +1878,7 @@ private: { const char code[] = "int a; namespace b{ }"; - const std::string expected("int a ;"); + const std::string expected("int a ; namespace b { }"); ASSERT_EQUALS(expected, sizeof_(code)); }