File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -424,7 +424,12 @@ namespace {
424424
425425 if (terminate == Analyzer::Terminate::Escape) {
426426 branch.escape = true ;
427- branch.escapeUnknown = false ;
427+ // The traversal followed an escaping path, but if the scope does not structurally
428+ // always escape then another path (e.g. a modified fork) falls through, so the escape
429+ // is only conditional - keep isModified() meaningful by not treating it as conclusive.
430+ bool structuralUnknown = false ;
431+ const bool structuralEscape = isEscapeScope (branch.endBlock , structuralUnknown);
432+ branch.escapeUnknown = !structuralEscape || structuralUnknown;
428433 } else {
429434 // Detect an escape the traversal did not flag (e.g. an unknown noreturn call);
430435 // escapeUnknown reports a possible (unknown) escape.
@@ -557,7 +562,7 @@ namespace {
557562 forkContinue = false ;
558563 }
559564
560- if (allAnalysis. isModified () || !forkContinue) {
565+ if (!forkContinue) {
561566 // TODO: Don't bail on missing condition
562567 if (!condTok)
563568 return Break (Analyzer::Terminate::Bail);
Original file line number Diff line number Diff line change @@ -4922,6 +4922,19 @@ class TestCondition : public TestFixture {
49224922 " if (bits > 0) {}\n "
49234923 " }\n " );
49244924 ASSERT_EQUALS (" " , errout_str ());
4925+
4926+ check (" int g();\n " // the modifying branch has an escaping sibling - still must be lowered
4927+ " void f(int t, int u) {\n "
4928+ " int v = 0;\n "
4929+ " if (t) {\n "
4930+ " if (u == 2)\n "
4931+ " v = g();\n "
4932+ " else\n "
4933+ " return;\n "
4934+ " }\n "
4935+ " if (v > 0) {}\n "
4936+ " }\n " );
4937+ ASSERT_EQUALS (" " , errout_str ());
49254938 }
49264939
49274940 void alwaysTrueSymbolic ()
You can’t perform that action at this time.
0 commit comments