Skip to content

Commit 3a7412b

Browse files
author
Your Name
committed
Move to valueflow
1 parent fdd0dae commit 3a7412b

2 files changed

Lines changed: 32 additions & 31 deletions

File tree

test/testcondition.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,37 +4935,6 @@ class TestCondition : public TestFixture {
49354935
" if (v > 0) {}\n"
49364936
"}\n");
49374937
ASSERT_EQUALS("", errout_str());
4938-
4939-
check("bool f();\n" // a modification after a conditional escape must still be seen
4940-
"int main() {\n"
4941-
" bool datumAdded = false;\n"
4942-
" if (f()) {\n"
4943-
" if (f()) return 1;\n"
4944-
" if (f()) datumAdded = true;\n"
4945-
" }\n"
4946-
" if (datumAdded) {}\n"
4947-
"}\n");
4948-
ASSERT_EQUALS("", errout_str());
4949-
4950-
check("bool f();\n"
4951-
"int main() {\n"
4952-
" bool b = false;\n"
4953-
" if (f()) {\n"
4954-
" if (f()) return 1;\n"
4955-
" b = true;\n"
4956-
" }\n"
4957-
" if (b) {}\n"
4958-
"}\n");
4959-
ASSERT_EQUALS("", errout_str());
4960-
4961-
check("bool f();\n" // the branch always escapes - keep the known value
4962-
"int main() {\n"
4963-
" bool b = false;\n"
4964-
" if (f()) { b = true; return 1; }\n"
4965-
" if (b) {}\n"
4966-
"}\n");
4967-
ASSERT_EQUALS("[test.cpp:5:9]: (style) Condition 'b' is always false [knownConditionTrueFalse]\n",
4968-
errout_str());
49694938
}
49704939

49714940
void alwaysTrueSymbolic()

test/testvalueflow.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,6 +3214,38 @@ class TestValueFlow : public TestFixture {
32143214
" return x;\n"
32153215
"}\n";
32163216
ASSERT_EQUALS(true, testValueOfXKnown(code, 3U, 0));
3217+
3218+
code = "bool f();\n" // a modification after a conditional escape must still be seen
3219+
"void g() {\n"
3220+
" bool x = false;\n"
3221+
" if (f()) {\n"
3222+
" if (f()) return;\n"
3223+
" if (f()) x = true;\n"
3224+
" }\n"
3225+
" if (x) {}\n"
3226+
"}\n";
3227+
ASSERT_EQUALS(true, testValueOfX(code, 8U, 0));
3228+
ASSERT_EQUALS(false, testValueOfXKnown(code, 8U, 0));
3229+
3230+
code = "bool f();\n"
3231+
"void g() {\n"
3232+
" bool x = false;\n"
3233+
" if (f()) {\n"
3234+
" if (f()) return;\n"
3235+
" x = true;\n"
3236+
" }\n"
3237+
" if (x) {}\n"
3238+
"}\n";
3239+
ASSERT_EQUALS(true, testValueOfX(code, 8U, 0));
3240+
ASSERT_EQUALS(false, testValueOfXKnown(code, 8U, 0));
3241+
3242+
code = "bool f();\n" // the branch always escapes - keep the known value
3243+
"void g() {\n"
3244+
" bool x = false;\n"
3245+
" if (f()) { x = true; return; }\n"
3246+
" if (x) {}\n"
3247+
"}\n";
3248+
ASSERT_EQUALS(true, testValueOfXKnown(code, 5U, 0));
32173249
}
32183250

32193251
void valueFlowAfterSwap()

0 commit comments

Comments
 (0)