Skip to content

Commit 312193e

Browse files
author
Your Name
committed
Remove flow check
1 parent a9d518e commit 312193e

2 files changed

Lines changed: 4 additions & 24 deletions

File tree

lib/forwardanalyzer.cpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -412,23 +412,8 @@ namespace {
412412
return bail;
413413
}
414414

415-
Progress updateBranch(Branch& branch, int depth, bool flow)
415+
Progress updateBranch(Branch& branch, int depth)
416416
{
417-
// Determine the branch's effect on the value without reporting (read-only)
418-
branch.action |= analyzeScope(branch.endBlock);
419-
// Mirror checkBranch()/tryForkUpdateScope(): only flow the value into the branch when
420-
// the analyzer allows it. A conditional value (e.g. a possible null carried under an
421-
// unrelated condition) must not be propagated into the branch, otherwise it produces
422-
// false positives. 'flow' is evaluated on the unassumed value by the caller.
423-
if (!flow) {
424-
bool unknown = false;
425-
if (isEscapeScope(branch.endBlock, unknown)) {
426-
branch.escape = true;
427-
branch.escapeUnknown = unknown;
428-
}
429-
return Progress::Continue;
430-
}
431-
432417
// Save and reset actions
433418
Analyzer::Action prevActions = actions;
434419
actions = Analyzer::Action::None;
@@ -796,18 +781,13 @@ namespace {
796781
return Break();
797782
} else {
798783
const bool conditional = stopOnCondition(condTok);
799-
// Decide whether the value may flow into each branch using the unassumed
800-
// value (as checkBranch() does), before assume() makes the forks conditional
801-
const bool flowThen = analyzer->updateScope(thenBranch.endBlock, analyzeScope(thenBranch.endBlock).isModified());
802-
const bool flowElse = hasElse && elseBranch.endBlock &&
803-
analyzer->updateScope(elseBranch.endBlock, analyzeScope(elseBranch.endBlock).isModified());
804784
ForwardTraversal ft = fork();
805785
ft.analyzer->assume(condTok, true);
806-
Progress p = ft.updateBranch(thenBranch, depth - 1, flowThen);
786+
Progress p = ft.updateBranch(thenBranch, depth - 1);
807787

808788
analyzer->assume(condTok, false);
809789
if (hasElse) {
810-
if (updateBranch(elseBranch, depth - 1, flowElse) == Progress::Break)
790+
if (updateBranch(elseBranch, depth - 1) == Progress::Break)
811791
return Break();
812792
}
813793
if (thenBranch.isDead() || elseBranch.isDead()) {

test/teststl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2736,7 +2736,7 @@ class TestStl : public TestFixture {
27362736
"}\n", s);
27372737
ASSERT_EQUALS("[test.cpp:5:9]: warning: Array index -1 is out of bounds. [negativeContainerIndex]\n"
27382738
"[test.cpp:8:8]: note: Calling function 'f', 1st argument '-1' value is -1\n"
2739-
"[test.cpp:3:9]: note: Assuming condition is true\n"
2739+
"[test.cpp:3:9]: note: Assuming condition is false\n"
27402740
"[test.cpp:5:9]: note: Negative array index\n",
27412741
errout_str());
27422742
}

0 commit comments

Comments
 (0)