Skip to content

Commit fc8c74d

Browse files
committed
Multi-operand constructor for code_ifthenelset
This enables RAII rather then incremental construction.
1 parent 36c1fa5 commit fc8c74d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/util/std_code.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,25 @@ class code_ifthenelset:public codet
583583
op2().make_nil();
584584
}
585585

586+
/// An if \p condition then \p then_code else \p else_code statement.
587+
code_ifthenelset(
588+
const exprt &condition,
589+
const codet &then_code,
590+
const codet &else_code)
591+
: codet(ID_ifthenelse)
592+
{
593+
add_to_operands(condition, then_code, else_code);
594+
}
595+
596+
/// An if \p condition then \p then_code statement (no "else" case).
597+
code_ifthenelset(
598+
const exprt &condition,
599+
const codet &then_code)
600+
: codet(ID_ifthenelse)
601+
{
602+
add_to_operands(condition, then_code, nil_exprt());
603+
}
604+
586605
const exprt &cond() const
587606
{
588607
return op0();

0 commit comments

Comments
 (0)