Reorder checks, move declaration closer to where it's needed
This commit is contained in:
parent
bb0b4c2b4a
commit
f58a25bebd
|
@ -1664,7 +1664,7 @@ void CheckUninitVar::checkRhs(const Token *tok, const Variable &var, bool alloc,
|
||||||
|
|
||||||
bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool alloc, bool cpp)
|
bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool alloc, bool cpp)
|
||||||
{
|
{
|
||||||
if (vartok->previous()->str() == "return" && !alloc)
|
if (!alloc && vartok->previous()->str() == "return")
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Passing variable to typeof/__alignof__
|
// Passing variable to typeof/__alignof__
|
||||||
|
@ -1673,8 +1673,6 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool all
|
||||||
|
|
||||||
// Passing variable to function..
|
// Passing variable to function..
|
||||||
if (Token::Match(vartok->previous(), "[(,] %var% [,)]") || Token::Match(vartok->tokAt(-2), "[(,] & %var% [,)]")) {
|
if (Token::Match(vartok->previous(), "[(,] %var% [,)]") || Token::Match(vartok->tokAt(-2), "[(,] & %var% [,)]")) {
|
||||||
const bool address(vartok->previous()->str() == "&");
|
|
||||||
|
|
||||||
// locate start parentheses in function call..
|
// locate start parentheses in function call..
|
||||||
unsigned int argumentNumber = 0;
|
unsigned int argumentNumber = 0;
|
||||||
const Token *start = vartok;
|
const Token *start = vartok;
|
||||||
|
@ -1693,6 +1691,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool all
|
||||||
if (func) {
|
if (func) {
|
||||||
const Variable *arg = func->getArgumentVar(argumentNumber);
|
const Variable *arg = func->getArgumentVar(argumentNumber);
|
||||||
if (arg) {
|
if (arg) {
|
||||||
|
const bool address(vartok->previous()->str() == "&");
|
||||||
const Token *argStart = arg->typeStartToken();
|
const Token *argStart = arg->typeStartToken();
|
||||||
while (argStart->previous() && argStart->previous()->isName())
|
while (argStart->previous() && argStart->previous()->isName())
|
||||||
argStart = argStart->previous();
|
argStart = argStart->previous();
|
||||||
|
|
Loading…
Reference in New Issue