ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
clang_c_adjust_irep2.h
Go to the documentation of this file.
1#pragma once
2
5#include <irep2/irep2.h>
6#include <cstddef>
7#include <vector>
8
48template <class Pass>
50{
51 const char *name;
52 void (*run)(Pass &, expr2tc &);
53 bool (*when)(const expr2tc &);
54};
55
59template <class Pass, std::size_t N>
61 Pass &self,
62 const adjust_arm<Pass> (&arms)[N],
63 expr2tc &expr)
64{
65 for (const adjust_arm<Pass> &a : arms)
66 if (!a.when || a.when(expr))
67 a.run(self, expr);
68}
69
71{
72public:
87 contextt &_context,
88 bool sole_adjuster = false,
89 bool writeback_all = false)
90 : context(_context),
93 {
94 }
95
96 virtual ~clang_c_adjust_irep2() = default;
97
101 bool adjust();
102
103 void adjust_expr(expr2tc &expr);
104
110 struct arm_info
111 {
112 const char *name;
114 bool (*when)(const expr2tc &);
115 };
116
121 static std::vector<arm_info> arm_order();
122
123 // Everything below is reachable by a sibling frontend's pass, which orders
124 // these arms alongside its own in its own table
125 // (docs/roadmap/scope-clang-cpp-irep2.md §3.1). Not public: nothing outside
126 // an adjust pass has any business calling a single arm.
127protected:
132 virtual void adjust_reference(expr2tc &)
133 {
134 }
135
141
145 void adjust_index(expr2tc &expr);
146
149 void adjust_member(expr2tc &expr);
150
155 void declare_implicit_callee(const expr2tc &expr);
156
163
169 void adjust_call_callee(expr2tc &expr);
170
173 void adjust_call_signature(expr2tc &expr);
174
177 virtual void align_call_return_type(expr2tc &, const symbolt &)
178 {
179 }
180
187 void adjust_complex_arith(expr2tc &expr);
188
192 void adjust_complex_unary(expr2tc &expr);
193
198 void adjust_if_expr(expr2tc &expr);
199
206
213
217
219 void adjust_address_of(expr2tc &expr);
220
227 void adjust_ptr_mem(expr2tc &expr);
228
236
239 void adjust_struct(expr2tc &expr);
240 void adjust_array_subtype(expr2tc &expr);
241 void adjust_decl_init(expr2tc &expr);
242 void adjust_dereference(expr2tc &expr);
245 void hoist_for_init(expr2tc &expr);
246
248 void pad_type_symbol(symbolt &symbol);
254 void adjust_shift_operands(expr2tc &expr);
255
256 /// IREP2 form of clang_c_adjust::adjust_side_effect_assignment's plain
257 /// "assign" case: the node takes the target's type, and the source converts
258 /// to it.
260
274 expr2tc &expr,
275 const irep_idt &name,
276 const std::vector<expr2tc> &args);
277
281 void adjust_relational(expr2tc &expr);
282
286 void adjust_call_arguments(expr2tc &expr);
287
291
296 virtual void gen_symbol_code(symbolt &)
297 {
298 }
299
304 {
305 }
306
312 {
313 }
314
319 virtual void adjust_sole_arms(expr2tc &expr);
320
326 void adjust_comma_type(expr2tc &expr);
327
329
334 static const arm arms[];
335
337 const bool sole_adjuster;
338 const bool writeback_all;
343};
344
349void adjust_comma_at_dispatch(exprt &expr, const namespacet &ns);
void adjust_comma_at_dispatch(exprt &expr, const namespacet &ns)
Shape-2 probe (scope-clang-c-irep2.md §57): run the IREP2 comma rewrite at the point the legacy pass ...
Definition clang_c_adjust_irep2.cpp:1788
void run_adjust_arms(Pass &self, const adjust_arm< Pass >(&arms)[N], expr2tc &expr)
Apply a pass's arms to one node in table order.
Definition clang_c_adjust_irep2.h:60
void declare_polymorphic_builtin(expr2tc &expr)
The GCC __sync_* / C11 __c11_atomic_* half of clang_c_adjust::adjust_side_effect_function_call: clang...
Definition clang_c_adjust_irep2.cpp:1696
virtual void adjust_reference(expr2tc &)
Read a reference-typed operand through, where the operand is used as a value: r becomes *r.
Definition clang_c_adjust_irep2.h:132
namespacet ns
Definition clang_c_adjust_irep2.h:342
void adjust_compound_assignment(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_side_effect_assignment's tail: the compound operators take the u...
Definition clang_c_adjust_irep2.cpp:1019
adjust_arm< clang_c_adjust_irep2 > arm
Definition clang_c_adjust_irep2.h:328
void adjust_function_designators(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_symbol's function-designator sugar (§100).
Definition clang_c_adjust_irep2.cpp:1161
void adjust_binary_arith_operands(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_expr_binary_arithmetic's conversion half: the usual arithmetic c...
Definition clang_c_adjust_irep2.cpp:927
void adjust_derived_to_base(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_derived_to_base: displace a derived->base conversion onto the ba...
Definition clang_c_adjust_irep2.cpp:646
void promote_unary_bool_operand(expr2tc &expr)
C11 6.5.3.3: the operand of unary - and ~ undergoes integer promotion, so a boolean one – a compariso...
Definition clang_c_adjust_irep2.cpp:1660
void pad_type_symbol(symbolt &symbol)
Pad a complete struct or union type symbol to its ABI layout (§96).
Definition clang_c_adjust_irep2.cpp:81
void adjust_expr(expr2tc &expr)
Definition clang_c_adjust_irep2.cpp:201
void adjust_call_arguments(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_function_call_arguments' conversion half: convert each argument ...
Definition clang_c_adjust_irep2.cpp:1304
void adjust_ptr_mem(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_ptr_mem.
Definition clang_c_adjust_irep2.cpp:1428
void adjust_address_of(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_address_of's array decay (§105).
Definition clang_c_adjust_irep2.cpp:763
void adjust_struct(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_struct's insertion loop.
Definition clang_c_adjust_irep2.cpp:798
void adjust_index(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_index's rewrite.
Definition clang_c_adjust_irep2.cpp:1818
contextt & context
Definition clang_c_adjust_irep2.h:336
static const arm arms[]
The chain in application order.
Definition clang_c_adjust_irep2.h:256
void adjust_call_signature(expr2tc &expr)
Rebuild a call's callee from the symbol table when the converter left its type incomplete,...
Definition clang_c_adjust_irep2.cpp:1270
void adjust_member(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_member's rewrite: reach through a pointer base with a dereferenc...
Definition clang_c_adjust_irep2.cpp:1800
void declare_implicit_callee(const expr2tc &expr)
A call to a function with no visible declaration reaches here with no symbol in the context; clang_c_...
Definition clang_c_adjust_irep2.cpp:1744
void adjust_complex_arith(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_expr_binary_arithmetic's complex branch: decompose a op b over a...
Definition clang_c_adjust_irep2.cpp:1570
void adjust_vector_float_arith(expr2tc &expr)
clang emits ieee_* for scalar float arithmetic itself, but hands over a plain +/-/*// when the operan...
Definition clang_c_adjust_irep2.cpp:1547
void adjust_if_expr(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_if: a ternary's condition must be boolean before goto_convert lo...
Definition clang_c_adjust_irep2.cpp:1139
clang_c_adjust_irep2(contextt &_context, bool sole_adjuster=false, bool writeback_all=false)
Definition clang_c_adjust_irep2.h:86
void adjust_comma_type(expr2tc &expr)
A comma expression takes its right operand's type (C11 6.5.17p2).
Definition clang_c_adjust_irep2.cpp:237
void adjust_call_callee(expr2tc &expr)
IREP2 form of the "do implicit dereference" step of clang_c_adjust::adjust_side_effect_function_call:...
Definition clang_c_adjust_irep2.cpp:1179
void adjust_boolean_operands(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_expr_{unary,binary}_boolean's live half.
Definition clang_c_adjust_irep2.cpp:1360
void lower_complex_compound_assignment(expr2tc &expr)
IREP2 form of clang_c_adjust::lower_complex_compound_assignment.
Definition clang_c_adjust_irep2.cpp:1496
void adjust_relational(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_expr_rel's operand half: the usual arithmetic conversions over a...
Definition clang_c_adjust_irep2.cpp:1112
virtual void gen_symbol_code(symbolt &)
Per-symbol code the pass synthesises rather than rewrites, run before the value walk so what it emits...
Definition clang_c_adjust_irep2.h:296
static std::vector< arm_info > arm_order()
The arms in the order adjust_expr applies them.
Definition clang_c_adjust_irep2.cpp:300
virtual void adjust_before_operands(expr2tc &)
A rewrite whose result must be walked, so it cannot be an arm: the arms run after the operand walk.
Definition clang_c_adjust_irep2.h:311
virtual ~clang_c_adjust_irep2()=default
void adjust_plain_assignment(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_side_effect_assignment's plain "assign" case: the node takes the...
Definition clang_c_adjust_irep2.cpp:995
void adjust_expression_statement(expr2tc &expr)
An expression statement whose value has array type – y->ss; where y points at a struct with an array ...
Definition clang_c_adjust_irep2.cpp:1389
virtual void align_call_return_type(expr2tc &, const symbolt &)
The call's type follows its callee's return type in C++ but not in C, where clang_c_adjust::align_se_...
Definition clang_c_adjust_irep2.h:177
void adjust_array_subtype(expr2tc &expr)
adjust_struct retypes an element to its tag's padded layout, which leaves an enclosing array literal ...
Definition clang_c_adjust_irep2.cpp:854
const bool sole_adjuster
Definition clang_c_adjust_irep2.h:337
void adjust_increment_reference(expr2tc &expr)
clang_c_adjust adjusts references on an increment or decrement, whose operand it updates in place.
Definition clang_c_adjust_irep2.cpp:1107
bool adjust()
Walk every code symbol's IREP2 value.
Definition clang_c_adjust_irep2.cpp:18
void adjust_dereference(expr2tc &expr)
Definition clang_c_adjust_irep2.cpp:1467
virtual void adjust_symbol_type(symbolt &)
Per-symbol type work, run for every symbol including the value-less ones.
Definition clang_c_adjust_irep2.h:303
void adjust_statement_condition(expr2tc &expr)
IREP2 form of the gen_typecast_bool that adjust_ifthenelse, adjust_while and adjust_for apply to a st...
Definition clang_c_adjust_irep2.cpp:1063
void adjust_complex_unary(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_expr_unary_complex: -z negates both components,...
Definition clang_c_adjust_irep2.cpp:1675
locationt enclosing_location
Location of the innermost enclosing statement, for the nodes that carry none of their own.
Definition clang_c_adjust_irep2.h:341
const bool writeback_all
Definition clang_c_adjust_irep2.h:338
void adjust_base_to_derived(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_base_to_derived: re-base a downcast off the base subobject onto ...
Definition clang_c_adjust_irep2.cpp:709
void adjust_special_functions(expr2tc &expr)
IREP2 form of the __builtin_-prefixed half of clang_c_adjust::do_special_functions: fold a recognised...
Definition clang_c_adjust_irep2.cpp:555
void hoist_for_init(expr2tc &expr)
Definition clang_c_adjust_irep2.cpp:890
virtual void adjust_sole_arms(expr2tc &expr)
Arms that run only when this pass is the sole adjuster, applied in the order arms lists them.
Definition clang_c_adjust_irep2.cpp:309
void adjust_shift_operands(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_expr_shifts.
Definition clang_c_adjust_irep2.cpp:966
void adjust_decl_init(expr2tc &expr)
IREP2 form of clang_c_adjust::adjust_decl's trailing gen_typecast: a declaration's initialiser conver...
Definition clang_c_adjust_irep2.cpp:877
bool adjust_float_builtin(expr2tc &expr, const irep_idt &name, const std::vector< expr2tc > &args)
The name-matched half of do_special_functions: isnan, abs, sqrt, inf and friends.
Definition clang_c_adjust_irep2.cpp:492
Definition context.h:57
Definition expr.h:34
Definition irep_idt.h:12
Definition location.h:7
Definition namespace.h:10
Definition symbol.h:12
#define N
Definition exp2f.c:23
Classes and definitions for non-stringy internal representation.
irep_container< expr2t > expr2tc
Definition irep2.h:431
#define bool
Definition stdbool.h:9
Phase 6 (C.3) IREP2-native adjuster for the C frontend.
Definition clang_c_adjust_irep2.h:50
void(* run)(clang_c_adjust_irep2 &, expr2tc &)
Definition clang_c_adjust_irep2.h:52
bool(* when)(const expr2tc &)
Definition clang_c_adjust_irep2.h:53
const char * name
Definition clang_c_adjust_irep2.h:51
One arm of the dispatch, as much of it as a caller may see: what it is called, and the guard deciding...
Definition clang_c_adjust_irep2.h:111
const char * name
Definition clang_c_adjust_irep2.h:112
bool(* when)(const expr2tc &)
Null for an arm that is offered every node and guards itself.
Definition clang_c_adjust_irep2.h:114