Refactoring; Use range for loop

This commit is contained in:
Daniel Marjamäki 2018-07-14 07:49:04 +02:00
parent d759015d99
commit 1dd647ae84
1 changed files with 10 additions and 18 deletions

View File

@ -2415,28 +2415,20 @@ void CheckClass::checkDuplInheritedMembers()
return; return;
// Iterate over all classes // Iterate over all classes
for (std::list<Type>::const_iterator classIt = mSymbolDatabase->typeList.begin(); for (const Type &classIt : mSymbolDatabase->typeList) {
classIt != mSymbolDatabase->typeList.end();
++classIt) {
// Iterate over the parent classes // Iterate over the parent classes
for (std::vector<Type::BaseInfo>::const_iterator parentClassIt = classIt->derivedFrom.begin(); for (const Type::BaseInfo &parentClassIt : classIt.derivedFrom) {
parentClassIt != classIt->derivedFrom.end();
++parentClassIt) {
// Check if there is info about the 'Base' class // Check if there is info about the 'Base' class
if (!parentClassIt->type || !parentClassIt->type->classScope) if (!parentClassIt.type || !parentClassIt.type->classScope)
continue; continue;
// Check if they have a member variable in common // Check if they have a member variable in common
for (std::list<Variable>::const_iterator classVarIt = classIt->classScope->varlist.begin(); for (const Variable &classVarIt : classIt.classScope->varlist) {
classVarIt != classIt->classScope->varlist.end(); for (const Variable &parentClassVarIt : parentClassIt.type->classScope->varlist) {
++classVarIt) { if (classVarIt.name() == parentClassVarIt.name() && !parentClassVarIt.isPrivate()) { // Check if the class and its parent have a common variable
for (std::list<Variable>::const_iterator parentClassVarIt = parentClassIt->type->classScope->varlist.begin(); duplInheritedMembersError(classVarIt.nameToken(), parentClassVarIt.nameToken(),
parentClassVarIt != parentClassIt->type->classScope->varlist.end(); classIt.name(), parentClassIt.type->name(), classVarIt.name(),
++parentClassVarIt) { classIt.classScope->type == Scope::eStruct,
if (classVarIt->name() == parentClassVarIt->name() && !parentClassVarIt->isPrivate()) { // Check if the class and its parent have a common variable parentClassIt.type->classScope->type == Scope::eStruct);
duplInheritedMembersError(classVarIt->nameToken(), parentClassVarIt->nameToken(),
classIt->name(), parentClassIt->type->name(), classVarIt->name(),
classIt->classScope->type == Scope::eStruct,
parentClassIt->type->classScope->type == Scope::eStruct);
} }
} }
} }