Function pointers: re-enabled the simplifyFunctionPointers

This commit is contained in:
Daniel Marjamäki 2010-01-23 07:43:12 +01:00
parent cfacd5fe10
commit 8a9eba980b
2 changed files with 31 additions and 4 deletions

View File

@ -952,7 +952,7 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[])
removeExceptionSpecifications(_tokens);
// simplify function pointers
// simplifyFunctionPointers();
simplifyFunctionPointers();
setVarId();
if (!validate())

View File

@ -2169,6 +2169,33 @@ private:
ASSERT_EQUALS("\"a\"", tok("\"\\177\""));
}
std::string simplifyTypedef(const char code[])
{
errout.str("");
Settings settings;
Tokenizer tokenizer(&settings, this);
tokenizer._files.push_back("test.cpp");
std::istringstream istr(code);
tokenizer.createTokens(istr);
tokenizer.createLinks();
tokenizer.simplifyTypedef();
std::string ret;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
{
if (tok != tokenizer.tokens())
ret += " ";
ret += tok->str();
}
return ret;
}
void simplifyTypedef1()
{
const char code[] = "class A\n"
@ -2663,7 +2690,7 @@ private:
"void ( * pf ) ( ) ; "
"void * ( * pfv ) ( void * ) ;";
ASSERT_EQUALS(tok(expected), tok(code));
ASSERT_EQUALS(expected, simplifyTypedef(code));
}
void simplifyTypedef22()
@ -2831,7 +2858,7 @@ private:
"void ( * fill_names ) ( struct vfs_class * me , void ( * ) ( const char * ) ) ; "
"}";
ASSERT_EQUALS(expected, tok(code, false));
ASSERT_EQUALS(expected, simplifyTypedef(code));
}
{
@ -2846,7 +2873,7 @@ private:
"void ( * fill_names ) ( void ( * ) ( const char * ) , struct vfs_class * me ) ; "
"}";
ASSERT_EQUALS(expected, tok(code, false));
ASSERT_EQUALS(expected, simplifyTypedef(code));
}
}