astyle formatting

[ci skip]
This commit is contained in:
Daniel Marjamäki 2020-12-19 08:56:46 +01:00
parent 6366a577f9
commit 1744cbaf66
3 changed files with 5 additions and 7 deletions

View File

@ -1611,8 +1611,7 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
bool sideEffectReturnFound = false;
std::set<const Variable*> pointersToGlobals;
for (Token* bodyToken = func.functionScope->bodyStart->next(); bodyToken != func.functionScope->bodyEnd;
bodyToken = bodyToken->next())
{
bodyToken = bodyToken->next()) {
// check variable inside function body
const Variable* bodyVariable = bodyToken->variable();
if (bodyVariable) {
@ -1620,7 +1619,7 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
return false;
}
// check if global variable is changed
if (bodyVariable->isGlobal() || (pointersToGlobals.find(bodyVariable) != pointersToGlobals.end()) ) {
if (bodyVariable->isGlobal() || (pointersToGlobals.find(bodyVariable) != pointersToGlobals.end())) {
if (bodyVariable->isPointer() || bodyVariable->isArray()) {
return false; // TODO: Update astutils.cpp:1544 isVariableChanged() and remove this. Unhandled case: `*(global_arr + 1) = new_val`
}
@ -1631,8 +1630,7 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
// check if pointer to global variable assigned to another variable (another_var = &global_var)
if (Token::simpleMatch(bodyToken->tokAt(-1), "&") && Token::simpleMatch(bodyToken->tokAt(-2), "=")) {
const Token* assigned_var_token = bodyToken->tokAt(-3);
if (assigned_var_token && assigned_var_token->variable())
{
if (assigned_var_token && assigned_var_token->variable()) {
pointersToGlobals.insert(assigned_var_token->variable());
}
}

View File

@ -3125,7 +3125,7 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog
std::list<ValueFlow::Value> values = tok->values();
// Only forward lifetime values
values.remove_if(&isNotLifetimeValue);
for(const ValueFlow::Value& value:values)
for (const ValueFlow::Value& value:values)
setTokenValue(parent, value, tokenlist->getSettings());
valueFlowForwardLifetime(parent, tokenlist, errorLogger, settings);
}

View File

@ -384,7 +384,7 @@ private:
const Token *tok = Token::findmatch(tokenizer.tokens(), tokstr);
if (!tok)
return result;
for(const ValueFlow::Value& value:tok->values()) {
for (const ValueFlow::Value& value:tok->values()) {
if (!value.isLifetimeValue())
continue;
if (!value.tokvalue)