Made isVariableDeclarationIdentifiesTemplatedPointerToPointerVariable() pass.
And added isVariableDeclarationIdentifiesTemplatedArrayVariable() (passing) into the bargain.
This commit is contained in:
parent
69d4db714e
commit
abfd907763
|
@ -1236,24 +1236,21 @@ bool SymbolDatabase::SpaceInfo::isVariableDeclaration(const Token* tok, const To
|
|||
|
||||
if (Token::Match(localTypeTok, "%type% < "))
|
||||
{
|
||||
const Token* closetok = NULL;
|
||||
bool found = findClosingBracket(localTypeTok->next(), closetok);
|
||||
const Token* closeTok = NULL;
|
||||
bool found = findClosingBracket(localTypeTok->next(), closeTok);
|
||||
if (found)
|
||||
{
|
||||
if (Token::Match(closetok, "> %var% ;"))
|
||||
const Token* localVarTok = skipPointers(closeTok->next());
|
||||
|
||||
if (isSimpleVariable(localVarTok) || isArrayVariable(localVarTok))
|
||||
{
|
||||
vartok = closetok->next();
|
||||
vartok = localVarTok;
|
||||
typetok = localTypeTok;
|
||||
}
|
||||
else if (Token::Match(closetok, "> * %var% ;"))
|
||||
else if (Token::Match(closeTok, "> :: %type% %var% ;"))
|
||||
{
|
||||
vartok = closetok->tokAt(2);
|
||||
typetok = localTypeTok;
|
||||
}
|
||||
else if (Token::Match(closetok, "> :: %type% %var% ;"))
|
||||
{
|
||||
vartok = closetok->tokAt(3);
|
||||
typetok = closetok->tokAt(2);
|
||||
vartok = closeTok->tokAt(3);
|
||||
typetok = closeTok->tokAt(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ private:
|
|||
TEST_CASE(test_isVariableDeclarationIdentifiesOfArrayPointers);
|
||||
TEST_CASE(isVariableDeclarationIdentifiesTemplatedPointerVariable);
|
||||
TEST_CASE(isVariableDeclarationIdentifiesTemplatedPointerToPointerVariable);
|
||||
TEST_CASE(isVariableDeclarationIdentifiesTemplatedArrayVariable);
|
||||
TEST_CASE(isVariableDeclarationIdentifiesTemplatedVariable);
|
||||
TEST_CASE(isVariableDeclarationIdentifiesTemplatedVariableIterator);
|
||||
TEST_CASE(isVariableDeclarationIdentifiesNestedTemplateVariable);
|
||||
|
@ -229,15 +230,19 @@ private:
|
|||
reset();
|
||||
givenACodeSampleToTokenize var("std::deque<int>*** ints;");
|
||||
bool result = si.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
TODO_ASSERT_EQUALS(true, result);
|
||||
if (NULL != vartok)
|
||||
{
|
||||
TODO_ASSERT_EQUALS("ints", vartok->str());
|
||||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("ints", vartok->str());
|
||||
ASSERT_EQUALS("deque", typetok->str());
|
||||
}
|
||||
if (NULL != typetok)
|
||||
|
||||
void isVariableDeclarationIdentifiesTemplatedArrayVariable()
|
||||
{
|
||||
TODO_ASSERT_EQUALS("deque", typetok->str());
|
||||
}
|
||||
reset();
|
||||
givenACodeSampleToTokenize var("std::deque<int> ints[3];");
|
||||
bool result = si.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
ASSERT_EQUALS("ints", vartok->str());
|
||||
ASSERT_EQUALS("deque", typetok->str());
|
||||
}
|
||||
|
||||
void isVariableDeclarationIdentifiesTemplatedVariable()
|
||||
|
|
Loading…
Reference in New Issue