mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
improvement(semantic/cfg): better control flow for WhileStatements. (#3451)
Fixes a simple cfg issue, previously it wouldn't follow the body subgraph correctly.
This commit is contained in:
parent
209a99d49f
commit
0012094188
3 changed files with 6 additions and 8 deletions
|
|
@ -1546,13 +1546,13 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
|
|||
self.visit_statement(&stmt.body);
|
||||
|
||||
/* cfg - after body basic block */
|
||||
let after_body_graph_ix = self.cfg.new_basic_block();
|
||||
let after_body_graph_ix = self.cfg.current_node_ix;
|
||||
let after_while_graph_ix = self.cfg.new_basic_block();
|
||||
|
||||
self.cfg.add_edge(before_while_stmt_graph_ix, condition_graph_ix, EdgeType::Normal);
|
||||
self.cfg.add_edge(condition_graph_ix, body_graph_ix, EdgeType::Normal);
|
||||
self.cfg.add_edge(body_graph_ix, after_body_graph_ix, EdgeType::Normal);
|
||||
self.cfg.add_edge(body_graph_ix, condition_graph_ix, EdgeType::Backedge);
|
||||
self.cfg.add_edge(condition_graph_ix, after_body_graph_ix, EdgeType::Normal);
|
||||
self.cfg.add_edge(after_body_graph_ix, condition_graph_ix, EdgeType::Backedge);
|
||||
self.cfg.add_edge(condition_graph_ix, after_while_graph_ix, EdgeType::Normal);
|
||||
|
||||
self.cfg.restore_state(
|
||||
&statement_state,
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ digraph {
|
|||
7 -> 8 [ label = Normal ]
|
||||
0 -> 1 [ label = Normal ]
|
||||
1 -> 2 [ label = Normal ]
|
||||
2 -> 9 [ label = Normal ]
|
||||
2 -> 1 [ label = Backedge ]
|
||||
8 -> 1 [ label = Backedge ]
|
||||
1 -> 9 [ label = Normal ]
|
||||
5 -> 1 [ label = Normal ]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ digraph {
|
|||
5 -> 6 [ label = Unreachable , style = "dotted" ]
|
||||
1 -> 2 [ label = Normal ]
|
||||
2 -> 5 [ label = Normal ]
|
||||
5 -> 7 [ label = Normal ]
|
||||
5 -> 2 [ label = Backedge ]
|
||||
6 -> 2 [ label = Backedge ]
|
||||
2 -> 7 [ label = Normal ]
|
||||
7 -> 8 [ label = Unreachable , style = "dotted" ]
|
||||
0 -> 9 [ label = Normal ]
|
||||
|
|
|
|||
Loading…
Reference in a new issue