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