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

Functions

bool c_implicit_typecast (exprt &expr, const typet &dest_type, const namespacet &ns)
bool c_implicit_typecast (expr2tc &expr, const type2tc &dest_type, const namespacet &ns)
bool check_c_implicit_typecast (const typet &src_type, const typet &dest_type, const namespacet &ns)
bool check_c_implicit_typecast (const type2tc &src_type, const type2tc &dest_type, const namespacet &ns)
bool c_implicit_typecast_arithmetic (exprt &expr1, exprt &expr2, const namespacet &ns)
bool c_implicit_typecast_arithmetic (expr2tc &expr1, expr2tc &expr2, const namespacet &ns)
bool check_c_implicit_typecast (const typet &src_type, const typet &dest_type)
static bool is_numeric_type (const type2tc &t)
bool check_c_implicit_typecast (const type2tc &src_type, const type2tc &dest_type)
static void take_reference_address (exprt &expr)
 Build the pointer that models a reference bound to expr.
static bool is_reference_type (const type2tc &type)
 IREP2 form of is_lvalue_or_rvalue_reference (std_types.cpp), kept local until a second caller wants it.
void take_reference_address (expr2tc &expr, pointer_ref_kindt rk)
 IREP2 form of take_reference_address; see the irept copy for why a conditional takes the address per arm ([expr.cond], #6291).
static bool pointer_subtypes_compatible (const type2tc &src_subtype, const type2tc &dest_subtype, const namespacet &ns)
 How generous C is between pointer subtypes: void either way, a common base type, two function pointers, or two scalars.
static bool same_c_type (const type2tc &a, const type2tc &b)
 The pointer-destination arm.

Function Documentation

◆ c_implicit_typecast() [1/2]

bool c_implicit_typecast ( expr2tc & expr,
const type2tc & dest_type,
const namespacet & ns )

◆ c_implicit_typecast() [2/2]

bool c_implicit_typecast ( exprt & expr,
const typet & dest_type,
const namespacet & ns )

◆ c_implicit_typecast_arithmetic() [1/2]

bool c_implicit_typecast_arithmetic ( expr2tc & expr1,
expr2tc & expr2,
const namespacet & ns )

◆ c_implicit_typecast_arithmetic() [2/2]

bool c_implicit_typecast_arithmetic ( exprt & expr1,
exprt & expr2,
const namespacet & ns )

◆ check_c_implicit_typecast() [1/4]

bool check_c_implicit_typecast ( const type2tc & src_type,
const type2tc & dest_type )

◆ check_c_implicit_typecast() [2/4]

bool check_c_implicit_typecast ( const type2tc & src_type,
const type2tc & dest_type,
const namespacet & ns )

◆ check_c_implicit_typecast() [3/4]

bool check_c_implicit_typecast ( const typet & src_type,
const typet & dest_type )

◆ check_c_implicit_typecast() [4/4]

bool check_c_implicit_typecast ( const typet & src_type,
const typet & dest_type,
const namespacet & ns )

◆ is_numeric_type()

bool is_numeric_type ( const type2tc & t)
static

◆ is_reference_type()

bool is_reference_type ( const type2tc & type)
static

IREP2 form of is_lvalue_or_rvalue_reference (std_types.cpp), kept local until a second caller wants it.

◆ pointer_subtypes_compatible()

bool pointer_subtypes_compatible ( const type2tc & src_subtype,
const type2tc & dest_subtype,
const namespacet & ns )
static

How generous C is between pointer subtypes: void either way, a common base type, two function pointers, or two scalars.

Anything else warns.

◆ same_c_type()

bool same_c_type ( const type2tc & a,
const type2tc & b )
static

The pointer-destination arm.

Returns true when the conversion is complete – the irept copy's return; // ok – and false to fall through to the tail. Whether two types are the same C type, treating a function's parameter names as not part of it – C11 6.7.6.3p15 requires compatible return types and agreeing parameter type lists, and says nothing of their names. code_type2t reflects argument_names, so int (*)(int x) and int (*)(int) compare unequal as IREP2 nodes; inserting a cast between them is a divergence from the irept copy, which inserts none (docs/roadmap/scope-clang-c-irep2.md ยง143.1).

◆ take_reference_address() [1/2]

void take_reference_address ( expr2tc & expr,
pointer_ref_kindt rk )

IREP2 form of take_reference_address; see the irept copy for why a conditional takes the address per arm ([expr.cond], #6291).

Take the address of an object bound to a reference; see c_typecast.cpp for why a conditional takes it per arm and why rk matters.

rk must be the destination's own kind. irept can hardcode #reference because its operator== skips comment attributes, so T& and T&& compare equal there; ref_kind is a real field, so a wrong kind leaves do_typecast's dest_type != type guard true and appends a cast irept never produces.

◆ take_reference_address() [2/2]

void take_reference_address ( exprt & expr)
static

Build the pointer that models a reference bound to expr.

A conditional whose arms are lvalues is itself an lvalue ([expr.cond]), so the address has to be taken per arm: &(c ? a : b) is c ? &a : &b. Left as address_of(if(...)) the pointer analysis resolves neither arm and the bound reference silently designates the wrong object (#6291, #3387).