@@ -160,6 +160,8 @@ namespace {
160160 ForwardTraversal* traversal = nullptr ;
161161 // The condition that holds on it, if it is a fork
162162 const Token* condTok = nullptr ;
163+ // The paths that stopped in the block, if it was walked on a fork
164+ Outcome stoppedPaths;
163165 bool isEscape () const {
164166 return escape || escapeUnknown;
165167 }
@@ -578,7 +580,7 @@ namespace {
578580 }
579581
580582 // Walk a block on a fork of this traversal, on which the condition holds
581- Branch updateForkedBranch (ForwardTraversal& ft, const Token* condTok, Token* endBlock, bool split, int depth)
583+ Branch updateForkedBranch (ForwardTraversal& ft, const Token* condTok, Token* endBlock, bool split, int depth) const
582584 {
583585 ft.actions = actions;
584586 if (split) {
@@ -595,12 +597,10 @@ namespace {
595597 // left for the forks that walk to the end of the range, which are the expensive ones.
596598 if (!split && branch.reachesEnd && canFork ())
597599 ++(*forkBudget);
598- // A path that stopped in the block is covered if this path goes on for it
599- Outcome stops = std::move (ft.parted );
600+ branch.stoppedPaths = std::move (ft.parted );
600601 ft.parted = Outcome{};
601602 if (!branch.reachesEnd )
602- stops.stop (ft.actions , ft.terminate );
603- parted.add (stops, !split);
603+ branch.stoppedPaths .stop (ft.actions , ft.terminate );
604604 return branch;
605605 }
606606
@@ -689,7 +689,13 @@ namespace {
689689 }
690690 }
691691 // Each fork holds its own condition, so one of several cannot go on for the others
692- if (successors.size () == 1 ) {
692+ const bool replaced = successors.size () == 1 ;
693+ // A path that stopped in a block is covered only if a path goes on for it past the
694+ // statement. Otherwise nothing walks the code that follows on its way.
695+ const bool covered = !split && (replaced || progress == Progress::Continue);
696+ for (const Branch& branch : branches)
697+ parted.add (branch.stoppedPaths , covered);
698+ if (replaced) {
693699 replaceWith (std::move (*successors.front ()));
694700 return Progress::Continue;
695701 }
0 commit comments