Refactoring; Use range for loop
This commit is contained in:
parent
1dd647ae84
commit
4429ee55c3
|
@ -568,8 +568,8 @@ bool CheckClass::isBaseClassFunc(const Token *tok, const Scope *scope)
|
||||||
if (derivedFrom && derivedFrom->classScope) {
|
if (derivedFrom && derivedFrom->classScope) {
|
||||||
const std::list<Function>& functionList = derivedFrom->classScope->functionList;
|
const std::list<Function>& functionList = derivedFrom->classScope->functionList;
|
||||||
|
|
||||||
for (std::list<Function>::const_iterator func = functionList.begin(); func != functionList.end(); ++func) {
|
for (const Function &func : functionList) {
|
||||||
if (func->tokenDef->str() == tok->str())
|
if (func.tokenDef->str() == tok->str())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1011,9 +1011,9 @@ static bool checkFunctionUsage(const Function *privfunc, const Scope* scope)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::list<Variable>::const_iterator i = scope->varlist.begin(); i != scope->varlist.end(); ++i) {
|
for (const Variable &var : scope->varlist) {
|
||||||
if (i->isStatic()) {
|
if (var.isStatic()) {
|
||||||
const Token* tok = Token::findmatch(scope->bodyEnd, "%varid% =|(|{", i->declarationId());
|
const Token* tok = Token::findmatch(scope->bodyEnd, "%varid% =|(|{", var.declarationId());
|
||||||
if (tok)
|
if (tok)
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
while (tok && tok->str() != ";") {
|
while (tok && tok->str() != ";") {
|
||||||
|
@ -1192,10 +1192,8 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn if type is a class that contains any virtual functions
|
// Warn if type is a class that contains any virtual functions
|
||||||
std::list<Function>::const_iterator func;
|
for (const Function &func : type->functionList) {
|
||||||
|
if (func.isVirtual()) {
|
||||||
for (func = type->functionList.begin(); func != type->functionList.end(); ++func) {
|
|
||||||
if (func->isVirtual()) {
|
|
||||||
if (allocation)
|
if (allocation)
|
||||||
mallocOnClassError(tok, tok->str(), type->classDef, "virtual method");
|
mallocOnClassError(tok, tok->str(), type->classDef, "virtual method");
|
||||||
else
|
else
|
||||||
|
@ -1204,20 +1202,18 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn if type is a class or struct that contains any std::* variables
|
// Warn if type is a class or struct that contains any std::* variables
|
||||||
std::list<Variable>::const_iterator var;
|
for (const Variable &var : type->varlist) {
|
||||||
|
if (var.isReference() && !var.isStatic()) {
|
||||||
for (var = type->varlist.begin(); var != type->varlist.end(); ++var) {
|
|
||||||
if (var->isReference() && !var->isStatic()) {
|
|
||||||
memsetErrorReference(tok, tok->str(), type->classDef->str());
|
memsetErrorReference(tok, tok->str(), type->classDef->str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// don't warn if variable static or const, pointer or array of pointers
|
// don't warn if variable static or const, pointer or array of pointers
|
||||||
if (!var->isStatic() && !var->isConst() && !var->isPointer() && (!var->isArray() || var->typeEndToken()->str() != "*")) {
|
if (!var.isStatic() && !var.isConst() && !var.isPointer() && (!var.isArray() || var.typeEndToken()->str() != "*")) {
|
||||||
const Token *tok1 = var->typeStartToken();
|
const Token *tok1 = var.typeStartToken();
|
||||||
const Scope *typeScope = var->typeScope();
|
const Scope *typeScope = var.typeScope();
|
||||||
|
|
||||||
// check for std:: type
|
// check for std:: type
|
||||||
if (var->isStlType() && tok1->strAt(2) != "array" && !mSettings->library.podtype(tok1->strAt(2)))
|
if (var.isStlType() && tok1->strAt(2) != "array" && !mSettings->library.podtype(tok1->strAt(2)))
|
||||||
if (allocation)
|
if (allocation)
|
||||||
mallocOnClassError(tok, tok->str(), type->classDef, "'std::" + tok1->strAt(2) + "'");
|
mallocOnClassError(tok, tok->str(), type->classDef, "'std::" + tok1->strAt(2) + "'");
|
||||||
else
|
else
|
||||||
|
@ -1228,7 +1224,7 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
|
||||||
checkMemsetType(start, tok, typeScope, allocation, parsedTypes);
|
checkMemsetType(start, tok, typeScope, allocation, parsedTypes);
|
||||||
|
|
||||||
// check for float
|
// check for float
|
||||||
else if (printPortability && var->isFloatingType() && tok->str() == "memset")
|
else if (printPortability && var.isFloatingType() && tok->str() == "memset")
|
||||||
memsetErrorFloat(tok, type->classDef->str());
|
memsetErrorFloat(tok, type->classDef->str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue