Refactoring: Use stl algorithm
This commit is contained in:
parent
69faa0d8c8
commit
fd4e371091
|
@ -739,31 +739,23 @@ bool isUniqueExpression(const Token* tok)
|
|||
// Iterate over the variables in scope and the parameters of the function if possible
|
||||
const Function * fun = scope->function;
|
||||
const std::list<Variable>* setOfVars[] = {&scope->varlist, fun ? &fun->argumentList : nullptr};
|
||||
if (varType) {
|
||||
|
||||
for (const std::list<Variable>* vars:setOfVars) {
|
||||
if (!vars)
|
||||
continue;
|
||||
for (const Variable& v:*vars) {
|
||||
if (v.type() && v.type()->name() == varType->name() && v.name() != var->name()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const std::list<Variable>* vars:setOfVars) {
|
||||
if (!vars)
|
||||
continue;
|
||||
for (const Variable& v:*vars) {
|
||||
if (v.isFloatingType() == var->isFloatingType() &&
|
||||
bool other = std::any_of(vars->cbegin(), vars->cend(), [=](const Variable &v) {
|
||||
if (varType)
|
||||
return v.type() && v.type()->name() == varType->name() && v.name() != var->name();
|
||||
return v.isFloatingType() == var->isFloatingType() &&
|
||||
v.isEnumType() == var->isEnumType() &&
|
||||
v.isClass() == var->isClass() &&
|
||||
v.isArray() == var->isArray() &&
|
||||
v.isPointer() == var->isPointer() &&
|
||||
v.name() != var->name())
|
||||
v.name() != var->name();
|
||||
});
|
||||
if (other)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!isUniqueExpression(tok->astOperand1())) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue