Get rid of set object

This commit is contained in:
Dmitry-Me 2015-09-10 17:59:20 +03:00
parent 5e50166135
commit 70d98c7176
1 changed files with 5 additions and 5 deletions

View File

@ -365,7 +365,7 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value)
// is condition only depending on 1 variable? // is condition only depending on 1 variable?
std::stack<const Token*> tokens; std::stack<const Token*> tokens;
tokens.push(parent->astOperand1()); tokens.push(parent->astOperand1());
std::set<unsigned int> variables; // used variables unsigned int varId = 0;
while (!tokens.empty()) { while (!tokens.empty()) {
const Token *t = tokens.top(); const Token *t = tokens.top();
tokens.pop(); tokens.pop();
@ -374,9 +374,9 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value)
tokens.push(t->astOperand1()); tokens.push(t->astOperand1());
tokens.push(t->astOperand2()); tokens.push(t->astOperand2());
if (t->varId()) { if (t->varId()) {
variables.insert(t->varId()); if (varId > 0 || value.varId != 0U)
if (variables.size() > 1U || value.varId != 0U)
return; return;
varId = t->varId();
} else if (t->str() == "(" && Token::Match(t->previous(), "%name%")) } else if (t->str() == "(" && Token::Match(t->previous(), "%name%"))
return; // function call return; // function call
} }
@ -385,8 +385,8 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value)
v.conditional = true; v.conditional = true;
v.changeKnownToPossible(); v.changeKnownToPossible();
if (!variables.empty()) if (varId)
v.varId = *(variables.begin()); v.varId = varId;
setTokenValue(parent, v); setTokenValue(parent, v);
} }