Refactorization: Replaced several Token::findmatch calls by symboldatabase usage
This commit is contained in:
parent
776ad32a0b
commit
ddf34440b6
|
@ -1537,8 +1537,8 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
|
||||||
var = tok->next()->variable();
|
var = tok->next()->variable();
|
||||||
nextTok = 8;
|
nextTok = 8;
|
||||||
} else if (Token::Match(tok, "[;{}] %var% = %str% ;") &&
|
} else if (Token::Match(tok, "[;{}] %var% = %str% ;") &&
|
||||||
tok->next()->varId() > 0 &&
|
tok->next()->variable() &&
|
||||||
nullptr != Token::findmatch(_tokenizer->tokens(), "[;{}] const| %type% * %varid% ;", tok->next()->varId())) {
|
tok->next()->variable()->isPointer()) {
|
||||||
size = 1 + int(tok->tokAt(3)->strValue().size());
|
size = 1 + int(tok->tokAt(3)->strValue().size());
|
||||||
type = "char";
|
type = "char";
|
||||||
var = tok->next()->variable();
|
var = tok->next()->variable();
|
||||||
|
|
|
@ -493,8 +493,7 @@ void CheckOther::warningOldStylePointerCast()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Is "type" a class?
|
// Is "type" a class?
|
||||||
const std::string pattern("class|struct " + tok->strAt(1));
|
if (_tokenizer->getSymbolDatabase()->isClassOrStruct(tok->strAt(1)))
|
||||||
if (Token::findmatch(_tokenizer->tokens(), pattern.c_str(), tok))
|
|
||||||
cstyleCastError(tok);
|
cstyleCastError(tok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,8 +533,8 @@ void CheckStl::erase()
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (i->type == Scope::eWhile && Token::Match(tok, "while ( %var% !=")) {
|
else if (i->type == Scope::eWhile && Token::Match(tok, "while ( %var% !=")) {
|
||||||
const unsigned int varid = tok->tokAt(2)->varId();
|
const Variable* var = tok->tokAt(2)->variable();
|
||||||
if (varid > 0 && Token::findmatch(_tokenizer->tokens(), "> :: iterator %varid%", varid))
|
if (var && Token::simpleMatch(var->typeEndToken()->tokAt(-2), "> :: iterator"))
|
||||||
EraseCheckLoop::checkScope(this, tok->tokAt(2));
|
EraseCheckLoop::checkScope(this, tok->tokAt(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1168,7 +1168,7 @@ void CheckStl::string_c_str()
|
||||||
string_c_strError(tok);
|
string_c_strError(tok);
|
||||||
} else if (Token::Match(tok, "[;{}] %var% = %var% (") &&
|
} else if (Token::Match(tok, "[;{}] %var% = %var% (") &&
|
||||||
Token::Match(tok->linkAt(4), ") . c_str|data ( ) ;") &&
|
Token::Match(tok->linkAt(4), ") . c_str|data ( ) ;") &&
|
||||||
Token::findmatch(_tokenizer->tokens(), ("std :: string|wstring " + tok->strAt(3) + " (").c_str())) {
|
tok->tokAt(3)->function() && Token::Match(tok->tokAt(3)->function()->retDef, "std :: string|wstring %var%")) {
|
||||||
const Variable* var = tok->next()->variable();
|
const Variable* var = tok->next()->variable();
|
||||||
if (var && var->isPointer())
|
if (var && var->isPointer())
|
||||||
string_c_strError(tok);
|
string_c_strError(tok);
|
||||||
|
|
Loading…
Reference in New Issue