ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
typecast2t Class Reference

Typecast expression. More...

#include <irep2_expr.h>

Inheritance diagram for typecast2t:
[legend]

Public Member Functions

 typecast2t (const type2tc &type, const expr2tc &from_, const expr2tc &rounding_mode_, const irep_idt &derived_to_base_=irep_idt(), bool base_to_derived_=false)
 Primary constructor.
 typecast2t (const type2tc &type, const expr2tc &from_, const irep_idt &derived_to_base_=irep_idt(), bool base_to_derived_=false)
 Primary constructor.
 typecast2t (const typecast2t &ref)=default
expr2tc do_simplify () const override
 expr-specific simplification methods.
Public Member Functions inherited from expr2t
virtual ~expr2t ()=default
expr2tc clone () const
expr2tc with_type (const type2tc &new_type) const
 Build a fresh expression of the same kind and field values as this one, but with a different type.
bool operator== (const expr2t &ref) const
bool operator< (const expr2t &ref) const
bool operator!= (const expr2t &ref) const
std::string pretty (unsigned int indent=0) const
 Produce textual representation of this expr.
DUMP_METHOD void dump () const
 Write textual representation of this object to stdout.
size_t crc () const
 Calculate a hash/digest of the current expr.
bool cmp (const expr2t &ref) const
 Structural comparison.
int lt (const expr2t &ref) const
 Trinary structural ordering.
list_of_memberst tostring (unsigned int indent) const
 Convert fields of subclasses to a string representation.
const expr2tc * get_sub_expr (size_t idx) const
 Fetch a sub-operand.
size_t get_num_sub_exprs () const
 Count the number of sub-exprs there are.
expr2tc simplify () const
 Simplify an expression.
expr2tc simplify (bool suppress_reassoc) const
 Simplify with reassociation suppression.
template<typename T>
void foreach_operand (T &&t) const
 Indirect, abstract operand iteration.
template<typename T>
void Foreach_operand (T &&t)
Public Member Functions inherited from irep2t
 irep2t () noexcept
 irep2t (const irep2t &) noexcept
irep2t & operator= (const irep2t &)=delete
virtual ~irep2t ()=default
void mark_writer () const noexcept
void clear_writer () const noexcept

Public Attributes

expr2tc from
expr2tc rounding_mode
irep_idt derived_to_base
 The base class this cast converts to, when the frontend could not route the conversion through a @base@ component and the displacement has to be applied once the layout is padded (clang_c_adjust_expr.cpp, #7025).
bool base_to_derived
 The mirror: a downcast whose operand points at a base subobject.
Public Attributes inherited from expr2t
const expr_ids expr_id
 Instance of expr_ids recording tihs exprs type.
const type2tc type
 Type of this expr.
std::atomic< size_t > crc_val
Public Attributes inherited from irep2t
std::atomic< unsigned int > refcount
std::atomic< std::uintptr_t > writer_thread

Static Public Attributes

static constexpr auto fields
static std::string field_names [esbmct::num_type_fields]

Additional Inherited Members

Public Types inherited from expr2t
enum  expr_ids { end_expr_id }
 Enumeration identifying each sort of expr. More...
typedef esbmct::function_ref< void(const expr2tc &)> const_op_delegate
typedef esbmct::function_ref< void(expr2tc &)> op_delegate
typedef expr2tc container_type
typedef expr2t base_type
Static Public Member Functions inherited from irep2t
static std::uintptr_t current_thread_tag () noexcept
Protected Member Functions inherited from expr2t
 expr2t (const type2tc &type, expr_ids id)
 Primary constructor.
 expr2t (const expr2t &ref)
 Copy constructor.
void foreach_operand_impl_const (const_op_delegate &expr) const
void foreach_operand_impl (op_delegate &expr)

Detailed Description

Typecast expression.

Represents cast from contained expression 'from' to the type of this typecast.

Constructor & Destructor Documentation

◆ typecast2t() [1/3]

typecast2t::typecast2t ( const type2tc & type,
const expr2tc & from_,
const expr2tc & rounding_mode_,
const irep_idt & derived_to_base_ = irep_idt(),
bool base_to_derived_ = false )
inline

Primary constructor.

Parameters
typeType to typecast to
fromExpression to cast from.
rounding_modeRounding mode, important only for floatbvs

◆ typecast2t() [2/3]

typecast2t::typecast2t ( const type2tc & type,
const expr2tc & from_,
const irep_idt & derived_to_base_ = irep_idt(),
bool base_to_derived_ = false )
inline

Primary constructor.

This constructor defaults the rounding mode to the __ESBMC_rounding_mode symbol

Parameters
typeType to typecast to
fromExpression to cast from.

◆ typecast2t() [3/3]

typecast2t::typecast2t ( const typecast2t & ref)
default

Member Function Documentation

◆ do_simplify()

expr2tc typecast2t::do_simplify ( ) const
overridevirtual

expr-specific simplification methods.

By default, an expression can't be simplified, and this method returns a nil expression to show that. However if simplification is possible, the subclass overrides this and if it can simplify its operands, returns a new simplified expression. It should attempt to modify itself (it's const).

If simplification failed the first time around, the simplify method will simplify this expressions individual operands, and will then call an expr with the simplified operands to see if it's now become simplifiable. This call occurs whether or not any operands were actually simplified, see below.

The 'second' parameter can be used to avoid invoking expensive attempts to simplify an expression more than once - on the first call to do_simplify this parameter will be false, then on the second it's be true, allowing method implementation to save the expensive stuff until all of its operands have certainly been simplified.

Currently simplification does some things that it shouldn't: pointer arithmetic for example. I'm not sure where this can be relocated to though.

Returns
expr2tc A nil expression if no simplifcation could occur, or a new simplified object if it can.

Reimplemented from expr2t.

Member Data Documentation

◆ base_to_derived

bool typecast2t::base_to_derived

The mirror: a downcast whose operand points at a base subobject.

◆ derived_to_base

irep_idt typecast2t::derived_to_base

The base class this cast converts to, when the frontend could not route the conversion through a @base@ component and the displacement has to be applied once the layout is padded (clang_c_adjust_expr.cpp, #7025).

Empty on every other cast. Carried because an IREP2 adjust pass cannot otherwise tell such a cast apart, and reading the base subobject without the displacement silently proves false assertions (docs/roadmap/scope-clang-cpp-irep2.md ยง3.12).

◆ field_names

std::string typecast2t::field_names
static
Initial value:
=
{"from", "rounding_mode", "derived_to_base", "base_to_derived", "", ""}

◆ fields

auto typecast2t::fields
staticconstexpr
Initial value:
= std::make_tuple(
const type2tc type
Type of this expr.
Definition irep2.h:910
bool base_to_derived
The mirror: a downcast whose operand points at a base subobject.
Definition irep2_expr.h:744
expr2tc from
Definition irep2_expr.h:731
expr2tc rounding_mode
Definition irep2_expr.h:732
irep_idt derived_to_base
The base class this cast converts to, when the frontend could not route the conversion through a @bas...
Definition irep2_expr.h:741

◆ from

expr2tc typecast2t::from

◆ rounding_mode

expr2tc typecast2t::rounding_mode

The documentation for this class was generated from the following files: