ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
clang_c_adjust_guards.h
Go to the documentation of this file.
1#ifndef ESBMC_CLANG_C_FRONTEND_CLANG_C_ADJUST_GUARDS_H
2#define ESBMC_CLANG_C_FRONTEND_CLANG_C_ADJUST_GUARDS_H
3
4#include <irep2/irep2_expr.h>
5#include <irep2/irep2_utils.h>
6
10
13inline bool is_binary_arith(const expr2tc &expr)
14{
15 return is_add2t(expr) || is_sub2t(expr) || is_mul2t(expr) || is_div2t(expr);
16}
17
20inline bool is_complex_unary(const expr2tc &expr)
21{
22 return (is_neg2t(expr) || is_bitnot2t(expr)) && is_complex_type(expr->type);
23}
24
26inline bool is_arith_or_bitwise(const expr2tc &expr)
27{
28 return is_binary_arith(expr) || is_modulus2t(expr) || is_bitand2t(expr) ||
29 is_bitor2t(expr) || is_bitxor2t(expr);
30}
31
36inline bool is_shift(const expr2tc &expr)
37{
38 return is_shl2t(expr) || is_ashr2t(expr) || is_lshr2t(expr);
39}
40
44inline bool is_statement_with_condition(const expr2tc &expr)
45{
46 return is_code_ifthenelse2t(expr) || is_code_while2t(expr) ||
47 is_code_dowhile2t(expr) || is_code_for2t(expr);
48}
49
52inline bool is_relational(const expr2tc &expr)
53{
54 return is_equality2t(expr) || is_notequal2t(expr) || is_lessthan2t(expr) ||
55 is_lessthanequal2t(expr) || is_greaterthan2t(expr) ||
56 is_greaterthanequal2t(expr);
57}
58
61inline bool is_short_circuit(const expr2tc &expr)
62{
63 return is_and2t(expr) || is_or2t(expr) || is_not2t(expr);
64}
65
69inline bool is_reference_type(const type2tc &type)
70{
71 return is_pointer_type(type) &&
73}
74
78inline bool is_increment_sideeffect(const expr2tc &expr)
79{
80 if (!is_sideeffect2t(expr))
81 return false;
82
83 switch (to_sideeffect2t(expr).kind)
84 {
85 case sideeffect2t::allockind::preincrement:
86 case sideeffect2t::allockind::postincrement:
87 case sideeffect2t::allockind::predecrement:
88 case sideeffect2t::allockind::postdecrement:
89 return true;
90 default:
91 return false;
92 }
93}
94
99inline bool is_alloc_sideeffect(const expr2tc &expr)
100{
101 if (!is_sideeffect2t(expr))
102 return false;
103
104 switch (to_sideeffect2t(expr).kind)
105 {
106 case sideeffect2t::allockind::cpp_new:
107 case sideeffect2t::allockind::cpp_new_arr:
108 case sideeffect2t::allockind::cpp_delete:
109 case sideeffect2t::allockind::cpp_delete_array:
110 return true;
111 default:
112 return false;
113 }
114}
115
118inline bool is_call_site(const expr2tc &expr)
119{
120 return is_code_function_call2t(expr) || is_sideeffect2t(expr);
121}
122
129inline bool is_promotable_unary(const expr2tc &expr)
130{
131 return (is_neg2t(expr) || is_bitnot2t(expr)) && !is_complex_type(expr->type);
132}
133
137inline bool is_derived_to_base_cast(const expr2tc &expr)
138{
139 return is_typecast2t(expr) && !to_typecast2t(expr).derived_to_base.empty();
140}
141
143inline bool is_base_to_derived_cast(const expr2tc &expr)
144{
145 return is_typecast2t(expr) && to_typecast2t(expr).base_to_derived;
146}
147
148#endif
bool is_increment_sideeffect(const expr2tc &expr)
x++, ++x, x--, --x.
Definition clang_c_adjust_guards.h:78
bool is_binary_arith(const expr2tc &expr)
The guards the IREP2 adjust arm tables dispatch on.
Definition clang_c_adjust_guards.h:13
bool is_call_site(const expr2tc &expr)
Both spellings of a call: a bare f(x); statement is a sideeffect2t of kind function_call rather than ...
Definition clang_c_adjust_guards.h:118
bool is_reference_type(const type2tc &type)
A C++ reference: IREP2 spells one as a pointer carrying a reference kind (scope-clang-cpp-irep2....
Definition clang_c_adjust_guards.h:69
bool is_derived_to_base_cast(const expr2tc &expr)
A cast the frontend marked as a derived->base conversion it could not route through a "@base@" compon...
Definition clang_c_adjust_guards.h:137
bool is_arith_or_bitwise(const expr2tc &expr)
The operators clang_c_adjust routes through adjust_expr_binary_arithmetic.
Definition clang_c_adjust_guards.h:26
bool is_promotable_unary(const expr2tc &expr)
The unary operators promote_unary_bool_operand claims: the complement of is_complex_unary within the ...
Definition clang_c_adjust_guards.h:129
bool is_statement_with_condition(const expr2tc &expr)
The statements whose controlling expression clang_c_adjust converts to bool (adjust_ifthenelse,...
Definition clang_c_adjust_guards.h:44
bool is_alloc_sideeffect(const expr2tc &expr)
An allocation side effect: new, new[], delete, delete[].
Definition clang_c_adjust_guards.h:99
bool is_base_to_derived_cast(const expr2tc &expr)
The mirror: a downcast whose operand points at a base subobject (#1866).
Definition clang_c_adjust_guards.h:143
bool is_short_circuit(const expr2tc &expr)
The short-circuit operators, whose operands goto_convert's lowering rejects unless they are boolean.
Definition clang_c_adjust_guards.h:61
bool is_relational(const expr2tc &expr)
The comparisons clang_c_adjust routes through adjust_expr_rel.
Definition clang_c_adjust_guards.h:52
bool is_complex_unary(const expr2tc &expr)
-z and GNU ~z (conjugation) are the only unary operators clang leaves carrying a complex type.
Definition clang_c_adjust_guards.h:20
bool is_shift(const expr2tc &expr)
The shifts clang_c_adjust routes through adjust_expr_shifts.
Definition clang_c_adjust_guards.h:36
const type2tc type
Type of this expr.
Definition irep2.h:910
irep_container< type2t > type2tc
Definition irep2.h:430
irep_container< expr2t > expr2tc
Definition irep2.h:431
@ NONE
Definition irep2_type.h:557
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
Definition std_types.h:460
bool is_complex_type(const typet &type)
Definition type_handler.h:39