Fixed ticket #520 (Tokenizer: properly set varId for containers with STL types)
http://sourceforge.net/apps/trac/cppcheck/ticket/520
This commit is contained in:
parent
c8caefa94c
commit
f50aa1e188
|
@ -755,6 +755,10 @@ void Tokenizer::setVarId()
|
||||||
if (Token::Match(tok, "%type% <"))
|
if (Token::Match(tok, "%type% <"))
|
||||||
{
|
{
|
||||||
Token *tok2 = tok->tokAt(2);
|
Token *tok2 = tok->tokAt(2);
|
||||||
|
|
||||||
|
if (Token::simpleMatch(tok2, "std ::"))
|
||||||
|
tok2 = tok2->tokAt(2);
|
||||||
|
|
||||||
while (tok2 && (tok2->isName() || tok2->str() == "*"))
|
while (tok2 && (tok2->isName() || tok2->str() == "*"))
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
|
||||||
|
|
|
@ -1272,7 +1272,8 @@ private:
|
||||||
void varidStl()
|
void varidStl()
|
||||||
{
|
{
|
||||||
const std::string code("list<int> ints;\n"
|
const std::string code("list<int> ints;\n"
|
||||||
"list<int>::iterator it;\n");
|
"list<int>::iterator it;\n"
|
||||||
|
"std::vector<std::string> dirs;\n");
|
||||||
|
|
||||||
// tokenize..
|
// tokenize..
|
||||||
Tokenizer tokenizer;
|
Tokenizer tokenizer;
|
||||||
|
@ -1284,7 +1285,8 @@ private:
|
||||||
const std::string actual(tokenizer.tokens()->stringifyList(true));
|
const std::string actual(tokenizer.tokens()->stringifyList(true));
|
||||||
const std::string expected("\n\n##file 0\n"
|
const std::string expected("\n\n##file 0\n"
|
||||||
"1: list < int > ints@1 ;\n"
|
"1: list < int > ints@1 ;\n"
|
||||||
"2: list < int > :: iterator it@2 ;\n");
|
"2: list < int > :: iterator it@2 ;\n"
|
||||||
|
"3: std :: vector < std :: string > dirs@3 ;\n");
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, actual);
|
ASSERT_EQUALS(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue