Skip to content

Commit c1c5fa7

Browse files
author
Daniel Kroening
committed
introduce make_boolean_expr
This is a type-safe drop-in replacement for exprt::make_bool(value).
1 parent 458ae26 commit c1c5fa7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/util/expr_util.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,11 @@ bool is_constantt::is_constant_address_of(const exprt &expr) const
281281

282282
return false;
283283
}
284+
285+
constant_exprt make_boolean_expr(bool value)
286+
{
287+
if(value)
288+
return true_exprt();
289+
else
290+
return false_exprt();
291+
}

src/util/expr_util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Author: Daniel Kroening, [email protected]
2121

2222
#include <functional>
2323

24+
class constant_exprt;
2425
class exprt;
2526
class symbol_exprt;
2627
class update_exprt;
@@ -96,4 +97,7 @@ class is_constantt
9697
virtual bool is_constant_address_of(const exprt &) const;
9798
};
9899

100+
/// returns true_exprt if given true and false_exprt otherwise
101+
constant_exprt make_boolean_expr(bool);
102+
99103
#endif // CPROVER_UTIL_EXPR_UTIL_H

0 commit comments

Comments
 (0)