Move declarations closer to where they're first used
This commit is contained in:
parent
4c18967329
commit
9199dde560
|
@ -86,11 +86,10 @@ static bool checkRvalueExpression(const Token * const vartok)
|
||||||
if (var == nullptr)
|
if (var == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Token * const next = vartok->next();
|
|
||||||
|
|
||||||
if (Token::Match(vartok->previous(), "& %var% [") && var->isPointer())
|
if (Token::Match(vartok->previous(), "& %var% [") && var->isPointer())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const Token * const next = vartok->next();
|
||||||
// &a.b[0]
|
// &a.b[0]
|
||||||
if (Token::Match(vartok, "%var% . %var% [") && !var->isPointer()) {
|
if (Token::Match(vartok, "%var% . %var% [") && !var->isPointer()) {
|
||||||
const Variable *var2 = next->next()->variable();
|
const Variable *var2 = next->next()->variable();
|
||||||
|
|
|
@ -8286,11 +8286,11 @@ void Tokenizer::eraseDeadCode(Token *begin, const Token *end)
|
||||||
} else if (isgoto && Token::Match(tok, "[{};] do|while|for|BOOST_FOREACH")) {
|
} else if (isgoto && Token::Match(tok, "[{};] do|while|for|BOOST_FOREACH")) {
|
||||||
//it's possible that code inside loop is not dead,
|
//it's possible that code inside loop is not dead,
|
||||||
//because of the possible presence of the label pointed by 'goto'
|
//because of the possible presence of the label pointed by 'goto'
|
||||||
std::string labelpattern = "[{};] " + begin->previous()->str() + " : ;";
|
|
||||||
Token *start = tok->tokAt(2);
|
Token *start = tok->tokAt(2);
|
||||||
if (start && start->str() == "(")
|
if (start && start->str() == "(")
|
||||||
start = start->link()->next();
|
start = start->link()->next();
|
||||||
if (start && start->str() == "{") {
|
if (start && start->str() == "{") {
|
||||||
|
std::string labelpattern = "[{};] " + begin->previous()->str() + " : ;";
|
||||||
bool simplify = true;
|
bool simplify = true;
|
||||||
for (Token *tok2 = start->next(); tok2 != start->link(); tok2 = tok2->next()) {
|
for (Token *tok2 = start->next(); tok2 != start->link(); tok2 = tok2->next()) {
|
||||||
if (Token::Match(tok2, labelpattern.c_str())) {
|
if (Token::Match(tok2, labelpattern.c_str())) {
|
||||||
|
|
Loading…
Reference in New Issue