rust_assert (lookup != ctx.loop_and_label_stack.rend ());
info = *lookup;
}
- add_jump_to (info.continue_bb);
+ push_goto (info.continue_bb);
// No code allowed after continue. No BB starts - would be empty.
}
{
push_assignment (info.label_var, visit_expr (*brk.get_expr ()));
}
- add_jump_to (info.break_bb);
+ push_goto (info.break_bb);
// No code allowed after break. No BB starts - would be empty.
}
{
auto loop = setup_loop (expr);
- add_jump_to (loop.continue_bb);
+ push_goto (loop.continue_bb);
ctx.current_bb = loop.continue_bb;
(void) visit_expr (*expr.get_loop_block ());
if (!ctx.get_current_bb ().is_terminated ())
- add_jump_to (loop.continue_bb);
+ push_goto (loop.continue_bb);
ctx.current_bb = loop.break_bb;
}
{
auto loop = setup_loop (expr);
- add_jump_to (loop.continue_bb);
+ push_goto (loop.continue_bb);
ctx.current_bb = loop.continue_bb;
auto cond_val = visit_expr (*expr.get_predicate_expr ());
ctx.current_bb = body_bb;
(void) visit_expr (*expr.get_loop_block ());
- add_jump_to (loop.continue_bb);
+ push_goto (loop.continue_bb);
ctx.current_bb = loop.break_bb;
}
ctx.current_bb = new_bb ();
BasicBlockId then_start_block = ctx.current_bb;
(void) visit_expr (*expr.get_if_block ());
+ if (!ctx.get_current_bb ().is_terminated ())
+ push_goto (INVALID_BB); // Resolved later.
BasicBlockId then_end_block = ctx.current_bb;
ctx.current_bb = new_bb ();
add_jump (if_block, then_start_block);
add_jump (if_block, final_block);
- if (!ctx.basic_blocks[then_end_block].is_terminated ())
+ auto &then_end_bb = ctx.basic_blocks[then_end_block];
+ if (then_end_bb.is_goto_terminated () && then_end_bb.successors.empty ())
add_jump (then_end_block, final_block);
}
ctx.current_bb = new_bb ();
auto then_res = visit_expr (*expr.get_if_block ());
push_assignment (result, then_res);
+ if (!ctx.get_current_bb ().is_terminated ())
+ push_goto (INVALID_BB); // Resolved later.
BasicBlockId then_block = ctx.current_bb;
ctx.current_bb = new_bb ();
auto else_res = visit_expr (*expr.get_else_block ());
push_assignment (result, else_res);
+ if (!ctx.get_current_bb ().is_terminated ())
+ push_goto (INVALID_BB); // Resolved later.
BasicBlockId else_block = ctx.current_bb;
ctx.current_bb = new_bb ();
add_jump (if_block, then_block);
add_jump (if_block, else_block);
- if (!ctx.basic_blocks[then_block].is_terminated ())
+ auto &then_bb = ctx.basic_blocks[then_block];
+ if (then_bb.is_goto_terminated () && then_bb.successors.empty ())
add_jump (then_block, final_block);
- if (!ctx.basic_blocks[else_block].is_terminated ())
+
+ auto &else_bb = ctx.basic_blocks[else_block];
+ if (else_bb.is_goto_terminated () && else_bb.successors.empty ())
add_jump (else_block, final_block);
}
void
}
else
{
- // TODO
- rust_sorry_at (stmt.get_locus (), "pattern matching in let statements");
+ rust_sorry_at (stmt.get_locus (), "pattern matching in let statements "
+ "without initializer is not supported");
}
}
{
(void) visit_expr (*stmt.get_expr ());
}
+
} // namespace BIR
} // namespace Rust
\ No newline at end of file
visit (expr);
push_assignment (return_place, translated);
auto final_bb = new_bb ();
- add_jump_to (final_bb);
+ push_goto (final_bb);
ctx.current_bb = short_circuit_bb;
translated = ctx.place_db.get_constant (lookup_type (expr));
push_assignment (return_place, translated);
- add_jump_to (final_bb);
+ push_goto (final_bb);
ctx.current_bb = final_bb;
return return_place;
void visit (HIR::LazyBooleanExpr &expr) override
{
expr.get_lhs ()->accept_vis (*this);
- push_switch (translated);
- add_jump_to (short_circuit_bb);
+ push_switch (translated, {short_circuit_bb});
start_new_subsequent_bb ();
expr.get_rhs ()->accept_vis (*this);