astyle formatting

This commit is contained in:
Daniel Marjamäki 2020-11-28 05:52:35 +01:00
parent 01df6e23ef
commit 484b68c550
3 changed files with 11 additions and 12 deletions

View File

@ -1517,8 +1517,8 @@ bool CheckUnusedVar::isRecordTypeWithoutSideEffects(const Type* type)
return withoutSideEffects = false;
}
const Function* initValueFunc = valueToken->function();
if (initValueFunc && !isFunctionWithoutSideEffects(*initValueFunc, valueToken,
std::list<const Function*>{})) {
if (initValueFunc && !isFunctionWithoutSideEffects(*initValueFunc, valueToken,
std::list<const Function*> {})) {
return withoutSideEffects = false;
}
}
@ -1594,7 +1594,8 @@ bool CheckUnusedVar::isEmptyType(const Type* type)
}
bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const Token* functionUsageToken,
std::list<const Function*> checkedFuncs) {
std::list<const Function*> checkedFuncs)
{
// no body to analyze
if (!func.hasBody()) {
return false;
@ -1608,9 +1609,8 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
}
bool sideEffectReturnFound = false;
for (Token* bodyToken = func.functionScope->bodyStart->next(); bodyToken != func.functionScope->bodyEnd;
bodyToken = bodyToken->next())
{
for (Token* bodyToken = func.functionScope->bodyStart->next(); bodyToken != func.functionScope->bodyEnd;
bodyToken = bodyToken->next()) {
const Variable* bodyVariable = bodyToken->variable();
if (bodyVariable) {
// check variable for side-effects
@ -1618,7 +1618,7 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
return false;
}
// check if global variable is changed
if (bodyVariable->isGlobal()) {
if (bodyVariable->isGlobal()) {
return false; // TODO: analyze global variable usage
}
}
@ -1645,7 +1645,7 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
}
// simple one-token return
const Variable* returnVariable = returnValueToken->variable();
if (returnValueToken->isLiteral() ||
if (returnValueToken->isLiteral() ||
(returnVariable && isVariableWithoutSideEffects(*returnVariable))) {
continue;
}

View File

@ -75,7 +75,7 @@ private:
bool isVariableWithoutSideEffects(const Variable& var);
bool isEmptyType(const Type* type);
bool isFunctionWithoutSideEffects(const Function& func, const Token* functionUsageToken,
std::list<const Function*> checkedFuncs);
std::list<const Function*> checkedFuncs);
// Error messages..
void unusedStructMemberError(const Token *tok, const std::string &structname, const std::string &varname, bool isUnion = false);

View File

@ -515,8 +515,7 @@ private:
ASSERT_EQUALS("", errout.str());
}
void cleanFunction()
{
void cleanFunction() {
// unknown function
functionVariableUsage(
"class F {\n"
@ -541,7 +540,7 @@ private:
" C c;\n"
"}");
ASSERT_EQUALS("", errout.str());
// return literal
functionVariableUsage(
"int func() { return 1; }\n"