Refactoring; Use range for loops
This commit is contained in:
parent
ed76f06ca7
commit
58ac8a9982
|
@ -1039,10 +1039,10 @@ void CheckClass::privateFunctions()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::list<const Function*> privateFuncs;
|
std::list<const Function*> privateFuncs;
|
||||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
for (const Function &func : scope->functionList) {
|
||||||
// Get private functions..
|
// Get private functions..
|
||||||
if (func->type == Function::eFunction && func->access == Private && !func->isOperator()) // TODO: There are smarter ways to check private operator usage
|
if (func.type == Function::eFunction && func.access == Private && !func.isOperator()) // TODO: There are smarter ways to check private operator usage
|
||||||
privateFuncs.push_back(&*func);
|
privateFuncs.push_back(&func);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bailout for overridden virtual functions of base classes
|
// Bailout for overridden virtual functions of base classes
|
||||||
|
@ -1481,25 +1481,25 @@ void CheckClass::operatorEqToSelf()
|
||||||
if (scope->definedType->derivedFrom.size() > 1)
|
if (scope->definedType->derivedFrom.size() > 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
for (const Function &func : scope->functionList) {
|
||||||
if (func->type == Function::eOperatorEqual && func->hasBody()) {
|
if (func.type == Function::eOperatorEqual && func.hasBody()) {
|
||||||
// make sure that the operator takes an object of the same type as *this, otherwise we can't detect self-assignment checks
|
// make sure that the operator takes an object of the same type as *this, otherwise we can't detect self-assignment checks
|
||||||
if (func->argumentList.empty())
|
if (func.argumentList.empty())
|
||||||
continue;
|
continue;
|
||||||
const Token* typeTok = func->argumentList.front().typeEndToken();
|
const Token* typeTok = func.argumentList.front().typeEndToken();
|
||||||
while (typeTok->str() == "const" || typeTok->str() == "&" || typeTok->str() == "*")
|
while (typeTok->str() == "const" || typeTok->str() == "&" || typeTok->str() == "*")
|
||||||
typeTok = typeTok->previous();
|
typeTok = typeTok->previous();
|
||||||
if (typeTok->str() != scope->className)
|
if (typeTok->str() != scope->className)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// make sure return signature is correct
|
// make sure return signature is correct
|
||||||
if (Token::Match(func->retDef, "%type% &") && func->retDef->str() == scope->className) {
|
if (Token::Match(func.retDef, "%type% &") && func.retDef->str() == scope->className) {
|
||||||
// find the parameter name
|
// find the parameter name
|
||||||
const Token *rhs = func->argumentList.begin()->nameToken();
|
const Token *rhs = func.argumentList.begin()->nameToken();
|
||||||
|
|
||||||
if (!hasAssignSelf(&(*func), rhs)) {
|
if (!hasAssignSelf(&func, rhs)) {
|
||||||
if (hasAllocation(&(*func), scope))
|
if (hasAllocation(&func, scope))
|
||||||
operatorEqToSelfError(func->token);
|
operatorEqToSelfError(func.token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue