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

clang C adjuster class for: More...

#include <clang_c_adjust.h>

Inheritance diagram for clang_c_adjust:
[legend]

Public Member Functions

 clang_c_adjust (contextt &_context)
virtual ~clang_c_adjust ()=default
bool adjust ()
void set_irep2_owns_arms ()
 Hand the index rewrite to the IREP2 adjuster.

Static Public Member Functions

static exprt declare_gcc_polymorphic_builtin (const symbol_exprt &callee, const exprt::operandst &arguments, const locationt &call_location, contextt &context)
 Declare the concrete instance of the GCC __sync_* / C11 __c11_atomic_* polymorphic builtin that callee and arguments select, adding its parameter symbols and its synthesised body to context on first use.

Protected Member Functions

bool has_single_arithmetic_argument (const side_effect_expr_function_callt &expr) const
 methods for symbol adjustment
bool shadows_user_definition (const irep_idt &identifier, const exprt &f_op) const
 True when a name-matched builtin lowering would discard a definition the program supplies, in which case the definition wins.
virtual void adjust_symbol (symbolt &symbol)
void adjust_type (typet &type)
 methods for type (typet) adjustment
void adjust_expr (exprt &expr)
 methods for expression (exprt) adjustment and other IRs derived from exprt
void adjust_base_to_derived (exprt &expr)
void adjust_derived_to_base (exprt &expr, const irep_idt &base_id)
void adjust_call_argument (exprt &arg)
void adjust_struct (exprt &expr)
void adjust_ptr_mem (exprt &expr)
void adjust_side_effect_assignment (exprt &expr)
virtual void adjust_side_effect_function_call (side_effect_expr_function_callt &expr)
void adjust_side_effect_statement_expression (side_effect_exprt &expr)
virtual void adjust_member (member_exprt &expr)
void adjust_expr_binary_arithmetic (exprt &expr)
bool lower_complex_binary_arithmetic (exprt &expr)
 Rewrite a binary arithmetic expression over complex operands into the component-level form, in place.
bool lower_complex_compound_assignment (exprt &expr)
 A compound assignment over a complex operand has to be expanded here.
void adjust_expr_unary_complex (exprt &expr)
void bind_sideeffect_operands (exprt &expr, code_blockt &block)
void finish_complex_lowering (exprt &expr, exprt &result, code_blockt &block)
void adjust_expr_shifts (exprt &expr)
void adjust_expr_unary_boolean (exprt &expr)
void adjust_expr_binary_boolean (exprt &expr)
virtual void adjust_expr_rel (exprt &expr)
void adjust_float_arith (exprt &expr)
void adjust_index (index_exprt &index)
void adjust_dereference (exprt &deref)
void adjust_address_of (exprt &expr)
void adjust_sizeof (exprt &expr)
virtual void adjust_side_effect (side_effect_exprt &expr)
void adjust_symbol (exprt &expr)
void adjust_comma (exprt &expr)
void adjust_builtin_va_arg (exprt &expr)
virtual void adjust_function_call_arguments (side_effect_expr_function_callt &expr)
void do_special_functions (side_effect_expr_function_callt &expr)
void adjust_operands (exprt &expr)
void adjust_if (exprt &expr)
virtual void adjust_code (codet &code)
 methods for code (codet) adjustment and other IRs derived from codet
virtual void adjust_ifthenelse (codet &code)
virtual void adjust_while (codet &code)
virtual void adjust_for (codet &code)
virtual void adjust_switch (codet &code)
void adjust_assign (codet &code)
void adjust_decl (codet &code)
virtual void adjust_decl_block (codet &code)
virtual void align_se_function_call_return_type (exprt &f_op, side_effect_expr_function_callt &expr)
 ancillary methods to support the expr/code adjustments above
virtual void adjust_reference (exprt &expr)

Static Protected Member Functions

static exprt is_gcc_polymorphic_builtin (const irep_idt &identifier, const exprt::operandst &arguments)
static code_blockt instantiate_gcc_polymorphic_builtin (const irep_idt &identifier, const symbol_exprt &function_symbol, contextt &context)

Protected Attributes

bool irep2_owns_arms = false
contextt & context
namespacet ns
symbol_generator tmp_symbol {"clang_c_adjust::"}

Detailed Description

clang C adjuster class for:

  • symbol adjustment, dealing with ESBMC-IR symbolt
  • type adjustment, dealing with ESBMC-IR typet or other IRs derived from typet
  • expression adjustment, dealing with ESBMC-IR exprt or other IRs derived from exprt
  • code adjustment, dealing with ESBMC-IR codet or other IRs derived from codet

Constructor & Destructor Documentation

◆ clang_c_adjust()

clang_c_adjust::clang_c_adjust ( contextt & _context)
explicit

◆ ~clang_c_adjust()

virtual clang_c_adjust::~clang_c_adjust ( )
virtualdefault

Member Function Documentation

◆ adjust()

bool clang_c_adjust::adjust ( )

◆ adjust_address_of()

void clang_c_adjust::adjust_address_of ( exprt & expr)
protected

◆ adjust_assign()

void clang_c_adjust::adjust_assign ( codet & code)
protected

◆ adjust_base_to_derived()

void clang_c_adjust::adjust_base_to_derived ( exprt & expr)
protected

◆ adjust_builtin_va_arg()

void clang_c_adjust::adjust_builtin_va_arg ( exprt & expr)
protected

◆ adjust_call_argument()

void clang_c_adjust::adjust_call_argument ( exprt & arg)
protected

◆ adjust_code()

void clang_c_adjust::adjust_code ( codet & code)
protectedvirtual

methods for code (codet) adjustment and other IRs derived from codet

Reimplemented in clang_cpp_adjust.

◆ adjust_comma()

void clang_c_adjust::adjust_comma ( exprt & expr)
protected

◆ adjust_decl()

void clang_c_adjust::adjust_decl ( codet & code)
protected

◆ adjust_decl_block()

void clang_c_adjust::adjust_decl_block ( codet & code)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_dereference()

void clang_c_adjust::adjust_dereference ( exprt & deref)
protected

◆ adjust_derived_to_base()

void clang_c_adjust::adjust_derived_to_base ( exprt & expr,
const irep_idt & base_id )
protected

◆ adjust_expr()

void clang_c_adjust::adjust_expr ( exprt & expr)
protected

methods for expression (exprt) adjustment and other IRs derived from exprt

◆ adjust_expr_binary_arithmetic()

void clang_c_adjust::adjust_expr_binary_arithmetic ( exprt & expr)
protected

◆ adjust_expr_binary_boolean()

void clang_c_adjust::adjust_expr_binary_boolean ( exprt & expr)
protected

◆ adjust_expr_rel()

void clang_c_adjust::adjust_expr_rel ( exprt & expr)
protectedvirtual

◆ adjust_expr_shifts()

void clang_c_adjust::adjust_expr_shifts ( exprt & expr)
protected

◆ adjust_expr_unary_boolean()

void clang_c_adjust::adjust_expr_unary_boolean ( exprt & expr)
protected

◆ adjust_expr_unary_complex()

void clang_c_adjust::adjust_expr_unary_complex ( exprt & expr)
protected

◆ adjust_float_arith()

void clang_c_adjust::adjust_float_arith ( exprt & expr)
protected

if type is not a float then we should check if it is a vector this is needed because a operation such as {0.1, 0.2} + 1 needs to use the float version

◆ adjust_for()

void clang_c_adjust::adjust_for ( codet & code)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_function_call_arguments()

void clang_c_adjust::adjust_function_call_arguments ( side_effect_expr_function_callt & expr)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_if()

void clang_c_adjust::adjust_if ( exprt & expr)
protected

◆ adjust_ifthenelse()

void clang_c_adjust::adjust_ifthenelse ( codet & code)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_index()

void clang_c_adjust::adjust_index ( index_exprt & index)
protected

◆ adjust_member()

void clang_c_adjust::adjust_member ( member_exprt & expr)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_operands()

void clang_c_adjust::adjust_operands ( exprt & expr)
protected

◆ adjust_ptr_mem()

void clang_c_adjust::adjust_ptr_mem ( exprt & expr)
protected

◆ adjust_reference()

void clang_c_adjust::adjust_reference ( exprt & expr)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_side_effect()

void clang_c_adjust::adjust_side_effect ( side_effect_exprt & expr)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_side_effect_assignment()

void clang_c_adjust::adjust_side_effect_assignment ( exprt & expr)
protected

◆ adjust_side_effect_function_call()

void clang_c_adjust::adjust_side_effect_function_call ( side_effect_expr_function_callt & expr)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_side_effect_statement_expression()

void clang_c_adjust::adjust_side_effect_statement_expression ( side_effect_exprt & expr)
protected

◆ adjust_sizeof()

void clang_c_adjust::adjust_sizeof ( exprt & expr)
protected

◆ adjust_struct()

void clang_c_adjust::adjust_struct ( exprt & expr)
protected

◆ adjust_switch()

void clang_c_adjust::adjust_switch ( codet & code)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_symbol() [1/2]

void clang_c_adjust::adjust_symbol ( exprt & expr)
protected

◆ adjust_symbol() [2/2]

void clang_c_adjust::adjust_symbol ( symbolt & symbol)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ adjust_type()

void clang_c_adjust::adjust_type ( typet & type)
protected

methods for type (typet) adjustment

◆ adjust_while()

void clang_c_adjust::adjust_while ( codet & code)
protectedvirtual

Reimplemented in clang_cpp_adjust.

◆ align_se_function_call_return_type()

void clang_c_adjust::align_se_function_call_return_type ( exprt & f_op,
side_effect_expr_function_callt & expr )
protectedvirtual

ancillary methods to support the expr/code adjustments above

Reimplemented in clang_cpp_adjust.

◆ bind_sideeffect_operands()

void clang_c_adjust::bind_sideeffect_operands ( exprt & expr,
code_blockt & block )
protected

◆ declare_gcc_polymorphic_builtin()

exprt clang_c_adjust::declare_gcc_polymorphic_builtin ( const symbol_exprt & callee,
const exprt::operandst & arguments,
const locationt & call_location,
contextt & context )
static

Declare the concrete instance of the GCC __sync_* / C11 __c11_atomic_* polymorphic builtin that callee and arguments select, adding its parameter symbols and its synthesised body to context on first use.

Returns the symbol to call in place of callee, nil if callee names no such builtin. Static because the IREP2 adjuster calls it too: clang hands these builtins over body-less, so a pass that skips this leaves every atomic load returning nondet (ยง130).

◆ do_special_functions()

void clang_c_adjust::do_special_functions ( side_effect_expr_function_callt & expr)
protected

◆ finish_complex_lowering()

void clang_c_adjust::finish_complex_lowering ( exprt & expr,
exprt & result,
code_blockt & block )
protected

◆ has_single_arithmetic_argument()

bool clang_c_adjust::has_single_arithmetic_argument ( const side_effect_expr_function_callt & expr) const
protected

methods for symbol adjustment

The abs node lowers to (x >= 0) ?

True when the single argument is arithmetic, as the abs node requires.

x : -x, which is ill-typed for anything else – std::abs(complex) is why <complex> ships without it.

◆ instantiate_gcc_polymorphic_builtin()

code_blockt clang_c_adjust::instantiate_gcc_polymorphic_builtin ( const irep_idt & identifier,
const symbol_exprt & function_symbol,
contextt & context )
staticprotected

◆ is_gcc_polymorphic_builtin()

exprt clang_c_adjust::is_gcc_polymorphic_builtin ( const irep_idt & identifier,
const exprt::operandst & arguments )
staticprotected

◆ lower_complex_binary_arithmetic()

bool clang_c_adjust::lower_complex_binary_arithmetic ( exprt & expr)
protected

Rewrite a binary arithmetic expression over complex operands into the component-level form, in place.

Expects both operands already adjusted; returns false when neither is complex, leaving expr untouched.

◆ lower_complex_compound_assignment()

bool clang_c_adjust::lower_complex_compound_assignment ( exprt & expr)
protected

A compound assignment over a complex operand has to be expanded here.

goto_convert's remove_assignment rebuilds a op b long after adjustment, so the component-level lowering would never see it and the SMT layer would be handed a raw complex operator (#6713). An lvalue with its own side effect is left alone: expanding it would evaluate that effect twice, and a loud failure downstream beats a wrong answer.

◆ set_irep2_owns_arms()

void clang_c_adjust::set_irep2_owns_arms ( )
inline

Hand the index rewrite to the IREP2 adjuster.

Set only by the C driver: clang_cpp_adjust derives from this class, and the IREP2 pass is wired into clang_c_languaget::typecheck alone, so a global option check here would disable the rewrite for C++ with nothing to replace it.

◆ shadows_user_definition()

bool clang_c_adjust::shadows_user_definition ( const irep_idt & identifier,
const exprt & f_op ) const
protected

True when a name-matched builtin lowering would discard a definition the program supplies, in which case the definition wins.

True when lowering this call would throw away a definition the program supplies.

See #6904.

Libc's own declarations are bodiless and the <cmath> overloads forward to their __builtin_ spelling, so both still lower.

Member Data Documentation

◆ context

contextt& clang_c_adjust::context
protected

◆ irep2_owns_arms

bool clang_c_adjust::irep2_owns_arms = false
protected

◆ ns

namespacet clang_c_adjust::ns
protected

◆ tmp_symbol

symbol_generator clang_c_adjust::tmp_symbol {"clang_c_adjust::"}
protected

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