Skip to content

Commit 8a572dc

Browse files
committed
Multi-operand constructor for code_ifthenelset
This enables RAII rather then incremental construction.
1 parent 69f54ca commit 8a572dc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/util/std_code.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,23 @@ class code_ifthenelset:public codet
622622
op2().make_nil();
623623
}
624624

625+
/// An if \p condition then \p then_code else \p else_code statement.
626+
code_ifthenelset(
627+
const exprt &condition,
628+
const codet &then_code,
629+
const codet &else_code)
630+
: codet(ID_ifthenelse)
631+
{
632+
add_to_operands(condition, then_code, else_code);
633+
}
634+
635+
/// An if \p condition then \p then_code statement (no "else" case).
636+
code_ifthenelset(const exprt &condition, const codet &then_code)
637+
: codet(ID_ifthenelse)
638+
{
639+
add_to_operands(condition, then_code, nil_exprt());
640+
}
641+
625642
const exprt &cond() const
626643
{
627644
return op0();

0 commit comments

Comments
 (0)