Tokenizer: Removed the Tokenizer::simplifyNamespaces. Ticket: #1700

This commit is contained in:
Daniel Marjamäki 2010-05-23 13:51:41 +02:00
parent b20cf06b66
commit 78255fdfc5
3 changed files with 3 additions and 60 deletions

View File

@ -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<const Token*> type;
@ -3161,8 +3112,6 @@ bool Tokenizer::simplifyTokenList()
simplifyStd();
simplifyNamespaces();
simplifyGoto();
// Combine wide strings

View File

@ -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
*/

View File

@ -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));
}