Refactoring uninitialized variables (checking variable declarations)
This commit is contained in:
parent
406cbda563
commit
d3ed1c8960
|
@ -2817,24 +2817,18 @@ private:
|
||||||
const Token *parse(const Token &tok, std::list<ExecutionPath *> &checks) const
|
const Token *parse(const Token &tok, std::list<ExecutionPath *> &checks) const
|
||||||
{
|
{
|
||||||
// Variable declaration..
|
// Variable declaration..
|
||||||
if (tok.isName() && tok.str() != "return")
|
if (Token::Match(tok.previous(), "[;{}] %var%") && tok.str() != "return")
|
||||||
{
|
{
|
||||||
if (Token::Match(&tok, "enum %type% {"))
|
if (Token::Match(&tok, "enum %type% {"))
|
||||||
return tok.tokAt(2)->link();
|
return tok.tokAt(2)->link();
|
||||||
|
|
||||||
if (Token::Match(tok.previous(), "[;{}] %type% *| %var% ;"))
|
const Token * vartok = &tok;
|
||||||
{
|
while (Token::Match(vartok, "const|struct"))
|
||||||
const Token * vartok = tok.next();
|
vartok = vartok->next();
|
||||||
const bool p(vartok->str() == "*");
|
|
||||||
if (p)
|
|
||||||
vartok = vartok->next();
|
|
||||||
declare(checks, vartok, tok, p, false);
|
|
||||||
return vartok;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Token::Match(tok.previous(), "[;{}] struct %type% *| %var% ;"))
|
if (Token::Match(vartok, "%type% *| %var% ;"))
|
||||||
{
|
{
|
||||||
const Token * vartok = tok.tokAt(2);
|
vartok = vartok->next();
|
||||||
const bool p(vartok->str() == "*");
|
const bool p(vartok->str() == "*");
|
||||||
if (p)
|
if (p)
|
||||||
vartok = vartok->next();
|
vartok = vartok->next();
|
||||||
|
@ -2843,17 +2837,16 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variable declaration for array..
|
// Variable declaration for array..
|
||||||
if (Token::Match(tok.previous(), "[;{}] %type% %var% [ %num% ] ;"))
|
if (Token::Match(vartok, "%type% %var% [ %num% ] ;"))
|
||||||
{
|
{
|
||||||
const Token * vartok = tok.next();
|
vartok = vartok->next();
|
||||||
declare(checks, vartok, tok, false, true);
|
declare(checks, vartok, tok, false, true);
|
||||||
return vartok->next()->link();
|
return vartok->next()->link();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Template pointer variable..
|
// Template pointer variable..
|
||||||
if (Token::Match(tok.previous(), "[;{}] %type% ::|<"))
|
if (Token::Match(vartok, "%type% ::|<"))
|
||||||
{
|
{
|
||||||
const Token * vartok = &tok;
|
|
||||||
while (Token::Match(vartok, "%type% ::"))
|
while (Token::Match(vartok, "%type% ::"))
|
||||||
vartok = vartok->tokAt(2);
|
vartok = vartok->tokAt(2);
|
||||||
if (Token::Match(vartok, "%type% < %type%"))
|
if (Token::Match(vartok, "%type% < %type%"))
|
||||||
|
|
Loading…
Reference in New Issue