ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
irep2_utils.cpp File Reference
Include dependency graph for irep2_utils.cpp:

Functions

void make_not (expr2tc &expr)
 Negate expr in place.
expr2tc conjunction (std::vector< expr2tc > cs)
 Build the left-associative AND-chain of cs: and(and(and(c0, c1), c2), ...).
expr2tc disjunction (std::vector< expr2tc > cs)
 Build the left-associative OR-chain of cs.
expr2tc gen_nondet (const type2tc &type)
 Build a sideeffect2t of kind nondet of type, i.e.
expr2tc gen_zero (const type2tc &type, bool array_as_array_of)
 Build the canonical zero value of type.
expr2tc gen_one (const type2tc &type)
 Build the canonical one value of type.
expr2tc distribute_vector_operation (expr2t::expr_ids id, const expr2tc &op1, const expr2tc &op2, const expr2tc &rm)
 Element-wise vector operation by expr_id dispatch.
expr2tc make_cmp_value (const type2tc &t, int v)
void get_symbols (const expr2tc &expr, std::unordered_set< expr2tc, irep2_hash > &symbols)
 Collect every user-level symbol2t referenced by expr into symbols.
std::string indent_str_irep2 (unsigned int indent)
template<>
bool do_get_sub_expr< expr2tc > (const expr2tc &item, size_t idx, size_t &it, const expr2tc *&ptr)
template<>
bool do_get_sub_expr< std::vector< expr2tc > > (const std::vector< expr2tc > &item, size_t idx, size_t &it, const expr2tc *&ptr)
template<>
size_t do_count_sub_exprs< const expr2tc > (const expr2tc &)
template<>
size_t do_count_sub_exprs< const std::vector< expr2tc > > (const std::vector< expr2tc > &item)
template<>
void call_expr_delegate< const expr2tc, expr2t::const_op_delegate > (const expr2tc &ref, expr2t::const_op_delegate &f)
template<>
void call_expr_delegate< expr2tc, expr2t::op_delegate > (expr2tc &ref, expr2t::op_delegate &f)
template<>
void call_type_delegate< const type2tc, type2t::const_subtype_delegate > (const type2tc &ref, type2t::const_subtype_delegate &f)
template<>
void call_type_delegate< type2tc, type2t::subtype_delegate > (type2tc &ref, type2t::subtype_delegate &f)
std::string type_to_string (const bool &thebool, int)
std::string type_to_string (const sideeffect_allockind &data, int)
std::string type_to_string (const unsigned int &theval, int)
std::string type_to_string (const constant_string_kindt &theval, int)
std::string type_to_string (const pointer_ref_kindt &theval, int)
std::string type_to_string (const printf_kindt &theval, int)
std::string type_to_string (const symbol_renaming_level &theval, int)
std::string type_to_string (const BigInt &theint, int)
std::string type_to_string (const fixedbvt &theval, int)
std::string type_to_string (const ieee_floatt &theval, int)
std::string type_to_string (const std::vector< expr2tc > &theval, int indent)
std::string type_to_string (const std::vector< type2tc > &theval, int indent)
std::string type_to_string (const std::vector< irep_idt > &theval, int indent)
std::string type_to_string (const expr2tc &theval, int indent)
std::string type_to_string (const type2tc &theval, int indent)
std::string type_to_string (const irep_idt &theval, int)
int do_type_lt (const BigInt &side1, const BigInt &side2)
int do_type_lt (const std::vector< expr2tc > &side1, const std::vector< expr2tc > &side2)
int do_type_lt (const std::vector< type2tc > &side1, const std::vector< type2tc > &side2)
int do_type_lt (const expr2tc &side1, const expr2tc &side2)
int do_type_lt (const type2tc &side1, const type2tc &side2)
std::vector< expr2tc > pad_struct_operands (const struct_type2t &st, std::vector< expr2tc > ops)
 Insert a zero operand at each reserved padding-member position so a struct literal's operand list matches its type's component list, exactly as clang_c_adjust::adjust_struct's insertion loop does.
static expr2tc strip_typecasts (const expr2tc &e)
irep_idt quantifier_bound_name (const expr2tc &binder)
 Base name of the variable a forall2t/exists2t binds, or an empty id when binder holds no symbol at all.
irep_idt quantifier_direct_bound_name (const expr2tc &binder)
 As quantifier_bound_name, but empty unless binder is (a typecast of) address_of(symbol), i.e.

Function Documentation

◆ call_expr_delegate< const expr2tc, expr2t::const_op_delegate >()

◆ call_expr_delegate< expr2tc, expr2t::op_delegate >()

◆ call_type_delegate< const type2tc, type2t::const_subtype_delegate >()

◆ call_type_delegate< type2tc, type2t::subtype_delegate >()

◆ conjunction()

expr2tc conjunction ( std::vector< expr2tc > cs)

Build the left-associative AND-chain of cs: and(and(and(c0, c1), c2), ...).

Returns gen_true_expr() when the input is empty (identity for conjunction).

◆ disjunction()

expr2tc disjunction ( std::vector< expr2tc > cs)

Build the left-associative OR-chain of cs.

Returns gen_true_expr() when the input is empty — note this is the convention used by the existing callers, not the strict identity for disjunction (which would be false). Preserves callers that short-circuit on "no constraints means trivially satisfied".

◆ distribute_vector_operation()

expr2tc distribute_vector_operation ( expr2t::expr_ids id,
const expr2tc & op1,
const expr2tc & op2 = expr2tc(),
const expr2tc & rm = expr2tc() )

Element-wise vector operation by expr_id dispatch.

At least one of op1 / op2 must be a vector. For each lane, builds the corresponding scalar IR node (neg / add / sub / mul / div / mod / shl / bit{and,or,xor,not} / ieee_{add,sub,mul,div}). IEEE variants honour the rounding-mode operand rm; the others ignore it. Returns a fresh constant_vector2t holding the lanes. Unlike the templated overload, this form doesn't take a functor — it switches on id internally, which is convenient at frontend / migration sites that already have the expr_id at hand.

◆ do_count_sub_exprs< const expr2tc >()

template<>
size_t do_count_sub_exprs< const expr2tc > ( const expr2tc & )

◆ do_count_sub_exprs< const std::vector< expr2tc > >()

template<>
size_t do_count_sub_exprs< const std::vector< expr2tc > > ( const std::vector< expr2tc > & item)

◆ do_get_sub_expr< expr2tc >()

template<>
bool do_get_sub_expr< expr2tc > ( const expr2tc & item,
size_t idx,
size_t & it,
const expr2tc *& ptr )

◆ do_get_sub_expr< std::vector< expr2tc > >()

template<>
bool do_get_sub_expr< std::vector< expr2tc > > ( const std::vector< expr2tc > & item,
size_t idx,
size_t & it,
const expr2tc *& ptr )

◆ do_type_lt() [1/5]

int do_type_lt ( const BigInt & side1,
const BigInt & side2 )

◆ do_type_lt() [2/5]

int do_type_lt ( const expr2tc & side1,
const expr2tc & side2 )

◆ do_type_lt() [3/5]

int do_type_lt ( const std::vector< expr2tc > & side1,
const std::vector< expr2tc > & side2 )

◆ do_type_lt() [4/5]

int do_type_lt ( const std::vector< type2tc > & side1,
const std::vector< type2tc > & side2 )

◆ do_type_lt() [5/5]

int do_type_lt ( const type2tc & side1,
const type2tc & side2 )

◆ gen_nondet()

expr2tc gen_nondet ( const type2tc & type)

Build a sideeffect2t of kind nondet of type, i.e.

an expression whose value is left to the SMT solver. Used at frontend / migration boundaries to seed unspecified inputs.

◆ gen_one()

expr2tc gen_one ( const type2tc & type)

Build the canonical one value of type.

Defined for bool, BV (any width), fixedbv, floatbv. Aborts on aggregate types — "one" isn't meaningful for structs/arrays/unions.

◆ gen_zero()

expr2tc gen_zero ( const type2tc & type,
bool array_as_array_of = false )

Build the canonical zero value of type.

Handles bool, BV (signed/unsigned, any width), fixedbv, floatbv, vector, array, pointer (NULL), struct (zero-of-each-member) and union (zero-of- first-member). Recursive for aggregates.

Parameters
array_as_array_ofWhen true, an array_type collapses to a single constant_array_of2t rather than expanding to N elements. Useful when downstream consumers prefer the run-length form.

◆ get_symbols()

void get_symbols ( const expr2tc & expr,
std::unordered_set< expr2tc, irep2_hash > & symbols )

Collect every user-level symbol2t referenced by expr into symbols.

Symbols whose name begins with "__ESBMC_" are treated as compiler internals and skipped (their subtree is not descended). Recursive — visits the expression tree via foreach_operand.

◆ indent_str_irep2()

std::string indent_str_irep2 ( unsigned int indent)

◆ make_cmp_value()

expr2tc make_cmp_value ( const type2tc & t,
int v )

◆ make_not()

void make_not ( expr2tc & expr)

Negate expr in place.

Folds constant true/false directly to gen_false_expr() / gen_true_expr() singletons, peels a redundant not(not(x)) to x, otherwise wraps in not2tc. The result is swapped into expr.

◆ pad_struct_operands()

std::vector< expr2tc > pad_struct_operands ( const struct_type2t & st,
std::vector< expr2tc > ops )

Insert a zero operand at each reserved padding-member position so a struct literal's operand list matches its type's component list, exactly as clang_c_adjust::adjust_struct's insertion loop does.

IREP2 carries no is_padding flag, so the member name is the signal (util/irep/pad_names.h). Idempotent: returns ops unchanged when already padded.

◆ quantifier_bound_name()

irep_idt quantifier_bound_name ( const expr2tc & binder)

Base name of the variable a forall2t/exists2t binds, or an empty id when binder holds no symbol at all.

Strips typecasts, then the address_of the solver expects around a binder that names a variable directly.

A binder of any other shape yields the name of whatever symbol it does hold: void *q = &i; __ESBMC_forall(q, ...) binds i but reads as q. Callers that must not confuse the two want the strict form below.

◆ quantifier_direct_bound_name()

irep_idt quantifier_direct_bound_name ( const expr2tc & binder)

As quantifier_bound_name, but empty unless binder is (a typecast of) address_of(symbol), i.e.

unless it names the bound variable directly.

◆ strip_typecasts()

expr2tc strip_typecasts ( const expr2tc & e)
static

◆ type_to_string() [1/16]

std::string type_to_string ( const BigInt & theint,
int  )

◆ type_to_string() [2/16]

std::string type_to_string ( const bool & thebool,
int  )

◆ type_to_string() [3/16]

std::string type_to_string ( const constant_string_kindt & theval,
int  )

◆ type_to_string() [4/16]

std::string type_to_string ( const expr2tc & theval,
int indent )

◆ type_to_string() [5/16]

std::string type_to_string ( const fixedbvt & theval,
int  )

◆ type_to_string() [6/16]

std::string type_to_string ( const ieee_floatt & theval,
int  )

◆ type_to_string() [7/16]

std::string type_to_string ( const irep_idt & theval,
int  )

◆ type_to_string() [8/16]

std::string type_to_string ( const pointer_ref_kindt & theval,
int  )

◆ type_to_string() [9/16]

std::string type_to_string ( const printf_kindt & theval,
int  )

◆ type_to_string() [10/16]

std::string type_to_string ( const sideeffect_allockind & data,
int  )

◆ type_to_string() [11/16]

std::string type_to_string ( const std::vector< expr2tc > & theval,
int indent )

◆ type_to_string() [12/16]

std::string type_to_string ( const std::vector< irep_idt > & theval,
int indent )

◆ type_to_string() [13/16]

std::string type_to_string ( const std::vector< type2tc > & theval,
int indent )

◆ type_to_string() [14/16]

std::string type_to_string ( const symbol_renaming_level & theval,
int  )

◆ type_to_string() [15/16]

std::string type_to_string ( const type2tc & theval,
int indent )

◆ type_to_string() [16/16]

std::string type_to_string ( const unsigned int & theval,
int  )