Fixed #7752 (ValueFlow: no conditional value, probably because condition is in ternary operator and/or in function call.)
This commit is contained in:
parent
ad74421526
commit
7fb812f415
|
@ -990,7 +990,7 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, SymbolDatabase *symbo
|
||||||
Token::Match(tok, "%oror%|&& %name% %oror%|&&|)")) {
|
Token::Match(tok, "%oror%|&& %name% %oror%|&&|)")) {
|
||||||
vartok = tok->next();
|
vartok = tok->next();
|
||||||
num = 0;
|
num = 0;
|
||||||
} else if (tok->str() == "!" && tok->astOperand1() && tok->astOperand1()->isName()) {
|
} else if (Token::Match(tok, "[!?]") && Token::Match(tok->astOperand1(), "%name%")) {
|
||||||
vartok = tok->astOperand1();
|
vartok = tok->astOperand1();
|
||||||
num = 0;
|
num = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -612,6 +612,12 @@ private:
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(true, testValueOfX(code, 2U, 123));
|
ASSERT_EQUALS(true, testValueOfX(code, 2U, 123));
|
||||||
|
|
||||||
|
code = "void f(const s *x) {\n"
|
||||||
|
" x->a = 0;\n"
|
||||||
|
" if (x ? x->a : 0) {}\n"
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(true, testValueOfX(code, 2U, 0));
|
||||||
|
|
||||||
code = "void f(int x, int y) {\n"
|
code = "void f(int x, int y) {\n"
|
||||||
" a = x;\n"
|
" a = x;\n"
|
||||||
" if (y){}\n"
|
" if (y){}\n"
|
||||||
|
|
Loading…
Reference in New Issue