fix(semantic): connect test expression of for statements to the cfg. (#3122)

I don't know if it is correct or not, Fixes my issues with dangling cfg nodes created in for statements. #3071
This commit is contained in:
Ali Rezvani 2024-05-10 17:41:25 +03:30 committed by GitHub
parent 18d853bb2b
commit c91d26129c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -785,6 +785,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
}
/* cfg */
let after_test_graph_ix = self.cfg.current_node_ix;
let update_graph_ix = self.cfg.new_basic_block();
/* cfg */
@ -803,10 +804,10 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg */
let after_for_stmt = self.cfg.new_basic_block();
self.cfg.add_edge(before_for_graph_ix, test_graph_ix, EdgeType::Normal);
self.cfg.add_edge(test_graph_ix, body_graph_ix, EdgeType::Normal);
self.cfg.add_edge(after_test_graph_ix, body_graph_ix, EdgeType::Normal);
self.cfg.add_edge(body_graph_ix, update_graph_ix, EdgeType::Backedge);
self.cfg.add_edge(update_graph_ix, test_graph_ix, EdgeType::Backedge);
self.cfg.add_edge(test_graph_ix, after_for_stmt, EdgeType::Normal);
self.cfg.add_edge(after_test_graph_ix, after_for_stmt, EdgeType::Normal);
self.cfg.after_statement(
&statement_state,