Fix issue 9738: ValueFlow: handle std::tie better (#2657)
This commit is contained in:
parent
d1279856d5
commit
526abd4b52
|
@ -110,6 +110,8 @@ struct ForwardTraversal {
|
|||
ForwardAnalyzer::Action action = analyzer->analyze(tok);
|
||||
if (!action.isNone())
|
||||
analyzer->update(tok, action);
|
||||
if (action.isInconclusive() && !analyzer->lowerToInconclusive())
|
||||
return Progress::Break;
|
||||
if (action.isInvalid())
|
||||
return Progress::Break;
|
||||
return Progress::Continue;
|
||||
|
|
|
@ -93,6 +93,7 @@ private:
|
|||
TEST_CASE(valueFlowForwardTernary);
|
||||
TEST_CASE(valueFlowForwardLambda);
|
||||
TEST_CASE(valueFlowForwardTryCatch);
|
||||
TEST_CASE(valueFlowForwardInconclusiveImpossible);
|
||||
|
||||
TEST_CASE(valueFlowFwdAnalysis);
|
||||
|
||||
|
@ -2684,6 +2685,19 @@ private:
|
|||
ASSERT_EQUALS(false, testValueOfX(code,3U,16));
|
||||
}
|
||||
|
||||
void valueFlowForwardInconclusiveImpossible() {
|
||||
const char *code;
|
||||
|
||||
code = "void foo() {\n"
|
||||
" bool valid = f1();\n"
|
||||
" if (!valid) return;\n"
|
||||
" std::tie(endVal, valid) = f2();\n"
|
||||
" bool x = !valid;"
|
||||
" bool b = x;" // <- not always true
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 6U, 1));
|
||||
}
|
||||
|
||||
void valueFlowRightShift() {
|
||||
const char *code;
|
||||
/* Set some temporary fixed values to simplify testing */
|
||||
|
|
Loading…
Reference in New Issue