ValueFlow: set values for false/true
This commit is contained in:
parent
fa03a93f89
commit
405a1fba11
|
@ -455,6 +455,13 @@ static void valueFlowNumber(TokenList *tokenlist)
|
||||||
if (tok->isNumber() && MathLib::isInt(tok->str()))
|
if (tok->isNumber() && MathLib::isInt(tok->str()))
|
||||||
setTokenValue(tok, ValueFlow::Value(MathLib::toLongNumber(tok->str())));
|
setTokenValue(tok, ValueFlow::Value(MathLib::toLongNumber(tok->str())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tokenlist->isCPP()) {
|
||||||
|
for (Token *tok = tokenlist->front(); tok; tok = tok->next()) {
|
||||||
|
if (tok->isName() && !tok->varId() && Token::Match(tok, "false|true"))
|
||||||
|
setTokenValue(tok, ValueFlow::Value(tok->str() == "true"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void valueFlowString(TokenList *tokenlist)
|
static void valueFlowString(TokenList *tokenlist)
|
||||||
|
|
|
@ -151,12 +151,9 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowNumber() {
|
void valueFlowNumber() {
|
||||||
const char *code;
|
ASSERT_EQUALS(123, valueOfTok("x=123;", "123").intvalue);
|
||||||
|
ASSERT_EQUALS(0, valueOfTok("x=false;", "false").intvalue);
|
||||||
code = "void f() {\n"
|
ASSERT_EQUALS(1, valueOfTok("x=true;", "true").intvalue);
|
||||||
" x = 123;\n"
|
|
||||||
"}";
|
|
||||||
ASSERT_EQUALS(123, valueOfTok(code, "123").intvalue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowString() {
|
void valueFlowString() {
|
||||||
|
|
Loading…
Reference in New Issue