CheckOther: Use SymbolDatabase. Ticket: #2318
This commit is contained in:
parent
1d349bf4cf
commit
a2aa601899
|
@ -2484,13 +2484,21 @@ bool CheckOther::isIdentifierObjectType(const Token * const tok)
|
||||||
|
|
||||||
void CheckOther::checkMisusedScopedObject()
|
void CheckOther::checkMisusedScopedObject()
|
||||||
{
|
{
|
||||||
bool withinFunction = false;
|
SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
unsigned int depth = 0;
|
|
||||||
|
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
std::list<SymbolDatabase::SpaceInfo *>::iterator i;
|
||||||
|
|
||||||
|
for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i)
|
||||||
{
|
{
|
||||||
withinFunction |= Token::Match(tok, ") const| {");
|
SymbolDatabase::SpaceInfo *info = *i;
|
||||||
if (withinFunction)
|
|
||||||
|
// only check functions
|
||||||
|
if (info->type != SymbolDatabase::SpaceInfo::Function)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
unsigned int depth = 0;
|
||||||
|
|
||||||
|
for (const Token *tok = info->classStart; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
if (tok->str() == "{")
|
if (tok->str() == "{")
|
||||||
{
|
{
|
||||||
|
@ -2499,11 +2507,11 @@ void CheckOther::checkMisusedScopedObject()
|
||||||
else if (tok->str() == "}")
|
else if (tok->str() == "}")
|
||||||
{
|
{
|
||||||
--depth;
|
--depth;
|
||||||
withinFunction &= depth > 0;
|
if (depth == 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (withinFunction
|
if (Token::Match(tok, "[;{}] %var% (")
|
||||||
&& Token::Match(tok, "[;{}] %var% (")
|
|
||||||
&& Token::Match(tok->tokAt(2)->link(), ") ;")
|
&& Token::Match(tok->tokAt(2)->link(), ") ;")
|
||||||
&& isIdentifierObjectType(tok)
|
&& isIdentifierObjectType(tok)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue