Tokenizer: fixed typedef issues
This commit is contained in:
parent
1aac8f3e52
commit
0212225859
|
@ -455,8 +455,8 @@ void Tokenizer::simplifyTypedef()
|
||||||
Token::Match(tok->next(), "%type% :: %type% <") ||
|
Token::Match(tok->next(), "%type% :: %type% <") ||
|
||||||
Token::Match(tok->next(), "%type% *| %type% ;") ||
|
Token::Match(tok->next(), "%type% *| %type% ;") ||
|
||||||
Token::Match(tok->next(), "%type% %type% *| %type% ;") ||
|
Token::Match(tok->next(), "%type% %type% *| %type% ;") ||
|
||||||
Token::Match(tok->next(), "%type% *| %type% [ %num% ]") ||
|
Token::Match(tok->next(), "%type% *| %type% [ %num% ] ;") ||
|
||||||
Token::Match(tok->next(), "%type% %type% *| %type% [ %num% ]"))
|
Token::Match(tok->next(), "%type% %type% *| %type% [ %num% ] ;"))
|
||||||
{
|
{
|
||||||
if ((tok->tokAt(2)->str() == "<") ||
|
if ((tok->tokAt(2)->str() == "<") ||
|
||||||
(tok->tokAt(4) && (tok->tokAt(4)->str() == "<")))
|
(tok->tokAt(4) && (tok->tokAt(4)->str() == "<")))
|
||||||
|
@ -482,6 +482,9 @@ void Tokenizer::simplifyTypedef()
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (end && end->next() && Token::Match(end->next(), ":: %type%"))
|
||||||
|
end = end->tokAt(2);
|
||||||
|
|
||||||
if (end && end->next() && Token::Match(end->next(), "%type% ;"))
|
if (end && end->next() && Token::Match(end->next(), "%type% ;"))
|
||||||
{
|
{
|
||||||
typeName = end->strAt(1);
|
typeName = end->strAt(1);
|
||||||
|
|
|
@ -2408,17 +2408,21 @@ private:
|
||||||
const char code[] = "typedef vector<int> V1;\n"
|
const char code[] = "typedef vector<int> V1;\n"
|
||||||
"typedef std::vector<int> V2;\n"
|
"typedef std::vector<int> V2;\n"
|
||||||
"typedef std::vector<std::vector<int> > V3;\n"
|
"typedef std::vector<std::vector<int> > V3;\n"
|
||||||
|
"typedef std::list<int>::iterator IntListIterator;\n"
|
||||||
"V1 v1;\n"
|
"V1 v1;\n"
|
||||||
"V2 v2;\n"
|
"V2 v2;\n"
|
||||||
"V3 v3;";
|
"V3 v3;\n"
|
||||||
|
"IntListIterator iter;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"typedef vector < int > V1 ; "
|
"typedef vector < int > V1 ; "
|
||||||
"typedef std :: vector < int > V2 ; "
|
"typedef std :: vector < int > V2 ; "
|
||||||
"typedef std :: vector < std :: vector < int > > V3 ; "
|
"typedef std :: vector < std :: vector < int > > V3 ; "
|
||||||
|
"typedef std :: list < int > :: iterator IntListIterator ; "
|
||||||
"vector < int > v1 ; "
|
"vector < int > v1 ; "
|
||||||
"std :: vector < int > v2 ; "
|
"std :: vector < int > v2 ; "
|
||||||
"std :: vector < std :: vector < int > > v3 ;";
|
"std :: vector < std :: vector < int > > v3 ; "
|
||||||
|
"std :: list < int > :: iterator iter ;";
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, tok(code, false));
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue