astyle formatting
This commit is contained in:
parent
01df6e23ef
commit
484b68c550
|
@ -1517,8 +1517,8 @@ bool CheckUnusedVar::isRecordTypeWithoutSideEffects(const Type* type)
|
||||||
return withoutSideEffects = false;
|
return withoutSideEffects = false;
|
||||||
}
|
}
|
||||||
const Function* initValueFunc = valueToken->function();
|
const Function* initValueFunc = valueToken->function();
|
||||||
if (initValueFunc && !isFunctionWithoutSideEffects(*initValueFunc, valueToken,
|
if (initValueFunc && !isFunctionWithoutSideEffects(*initValueFunc, valueToken,
|
||||||
std::list<const Function*>{})) {
|
std::list<const Function*> {})) {
|
||||||
return withoutSideEffects = false;
|
return withoutSideEffects = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1594,7 +1594,8 @@ bool CheckUnusedVar::isEmptyType(const Type* type)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const Token* functionUsageToken,
|
bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const Token* functionUsageToken,
|
||||||
std::list<const Function*> checkedFuncs) {
|
std::list<const Function*> checkedFuncs)
|
||||||
|
{
|
||||||
// no body to analyze
|
// no body to analyze
|
||||||
if (!func.hasBody()) {
|
if (!func.hasBody()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1608,9 +1609,8 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sideEffectReturnFound = false;
|
bool sideEffectReturnFound = false;
|
||||||
for (Token* bodyToken = func.functionScope->bodyStart->next(); bodyToken != func.functionScope->bodyEnd;
|
for (Token* bodyToken = func.functionScope->bodyStart->next(); bodyToken != func.functionScope->bodyEnd;
|
||||||
bodyToken = bodyToken->next())
|
bodyToken = bodyToken->next()) {
|
||||||
{
|
|
||||||
const Variable* bodyVariable = bodyToken->variable();
|
const Variable* bodyVariable = bodyToken->variable();
|
||||||
if (bodyVariable) {
|
if (bodyVariable) {
|
||||||
// check variable for side-effects
|
// check variable for side-effects
|
||||||
|
@ -1618,7 +1618,7 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check if global variable is changed
|
// check if global variable is changed
|
||||||
if (bodyVariable->isGlobal()) {
|
if (bodyVariable->isGlobal()) {
|
||||||
return false; // TODO: analyze global variable usage
|
return false; // TODO: analyze global variable usage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1645,7 +1645,7 @@ bool CheckUnusedVar::isFunctionWithoutSideEffects(const Function& func, const To
|
||||||
}
|
}
|
||||||
// simple one-token return
|
// simple one-token return
|
||||||
const Variable* returnVariable = returnValueToken->variable();
|
const Variable* returnVariable = returnValueToken->variable();
|
||||||
if (returnValueToken->isLiteral() ||
|
if (returnValueToken->isLiteral() ||
|
||||||
(returnVariable && isVariableWithoutSideEffects(*returnVariable))) {
|
(returnVariable && isVariableWithoutSideEffects(*returnVariable))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ private:
|
||||||
bool isVariableWithoutSideEffects(const Variable& var);
|
bool isVariableWithoutSideEffects(const Variable& var);
|
||||||
bool isEmptyType(const Type* type);
|
bool isEmptyType(const Type* type);
|
||||||
bool isFunctionWithoutSideEffects(const Function& func, const Token* functionUsageToken,
|
bool isFunctionWithoutSideEffects(const Function& func, const Token* functionUsageToken,
|
||||||
std::list<const Function*> checkedFuncs);
|
std::list<const Function*> checkedFuncs);
|
||||||
|
|
||||||
// Error messages..
|
// Error messages..
|
||||||
void unusedStructMemberError(const Token *tok, const std::string &structname, const std::string &varname, bool isUnion = false);
|
void unusedStructMemberError(const Token *tok, const std::string &structname, const std::string &varname, bool isUnion = false);
|
||||||
|
|
|
@ -515,8 +515,7 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanFunction()
|
void cleanFunction() {
|
||||||
{
|
|
||||||
// unknown function
|
// unknown function
|
||||||
functionVariableUsage(
|
functionVariableUsage(
|
||||||
"class F {\n"
|
"class F {\n"
|
||||||
|
@ -541,7 +540,7 @@ private:
|
||||||
" C c;\n"
|
" C c;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// return literal
|
// return literal
|
||||||
functionVariableUsage(
|
functionVariableUsage(
|
||||||
"int func() { return 1; }\n"
|
"int func() { return 1; }\n"
|
||||||
|
|
Loading…
Reference in New Issue