cprover
simplify_expr_pointer.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #include "simplify_expr_class.h"
10 
11 #include "arith_tools.h"
12 #include "c_types.h"
13 #include "config.h"
14 #include "expr_util.h"
15 #include "namespace.h"
16 #include "pointer_expr.h"
17 #include "pointer_offset_size.h"
18 #include "pointer_predicates.h"
19 #include "prefix.h"
20 #include "std_expr.h"
21 #include "string_constant.h"
22 
24  const exprt &expr,
25  mp_integer &address)
26 {
27  if(expr.id() == ID_dereference)
28  {
29  const auto &pointer = to_dereference_expr(expr).pointer();
30 
31  if(
32  pointer.id() == ID_typecast &&
33  to_typecast_expr(pointer).op().is_constant() &&
34  !to_integer(to_constant_expr(to_typecast_expr(pointer).op()), address))
35  {
36  return true;
37  }
38 
39  if(pointer.is_constant())
40  {
41  const constant_exprt &constant = to_constant_expr(pointer);
42 
43  if(constant.get_value() == ID_NULL && config.ansi_c.NULL_is_zero) // NULL
44  {
45  address=0;
46  return true;
47  }
48  else if(!to_integer(constant, address))
49  return true;
50  }
51  }
52 
53  return false;
54 }
55 
58 {
59  if(expr.id()==ID_index)
60  {
61  auto new_index_expr = to_index_expr(expr);
62 
63  bool no_change = true;
64 
65  auto array_result = simplify_address_of_arg(new_index_expr.array());
66 
67  if(array_result.has_changed())
68  {
69  no_change = false;
70  new_index_expr.array() = array_result.expr;
71  }
72 
73  auto index_result = simplify_rec(new_index_expr.index());
74 
75  if(index_result.has_changed())
76  {
77  no_change = false;
78  new_index_expr.index() = index_result.expr;
79  }
80 
81  // rewrite (*(type *)int) [index] by
82  // pushing the index inside
83 
84  mp_integer address;
85  if(is_dereference_integer_object(new_index_expr.array(), address))
86  {
87  // push index into address
88  auto step_size = pointer_offset_size(new_index_expr.type(), ns);
89 
90  if(step_size.has_value())
91  {
92  const auto index = numeric_cast<mp_integer>(new_index_expr.index());
93 
94  if(index.has_value())
95  {
97  to_dereference_expr(new_index_expr.array()).pointer().type());
98  pointer_type.subtype() = new_index_expr.type();
99 
100  typecast_exprt typecast_expr(
101  from_integer((*step_size) * (*index) + address, index_type()),
102  pointer_type);
103 
104  return dereference_exprt{typecast_expr};
105  }
106  }
107  }
108 
109  if(!no_change)
110  return new_index_expr;
111  }
112  else if(expr.id()==ID_member)
113  {
114  auto new_member_expr = to_member_expr(expr);
115 
116  bool no_change = true;
117 
118  auto struct_op_result =
119  simplify_address_of_arg(new_member_expr.struct_op());
120 
121  if(struct_op_result.has_changed())
122  {
123  new_member_expr.struct_op() = struct_op_result.expr;
124  no_change = false;
125  }
126 
127  const typet &op_type = ns.follow(new_member_expr.struct_op().type());
128 
129  if(op_type.id() == ID_struct)
130  {
131  // rewrite NULL -> member by
132  // pushing the member inside
133 
134  mp_integer address;
135  if(is_dereference_integer_object(new_member_expr.struct_op(), address))
136  {
137  const irep_idt &member = to_member_expr(expr).get_component_name();
138  auto offset = member_offset(to_struct_type(op_type), member, ns);
139  if(offset.has_value())
140  {
142  to_dereference_expr(new_member_expr.struct_op()).pointer().type());
143  pointer_type.subtype() = new_member_expr.type();
144  typecast_exprt typecast_expr(
145  from_integer(address + *offset, index_type()), pointer_type);
146  return dereference_exprt{typecast_expr};
147  }
148  }
149  }
150 
151  if(!no_change)
152  return new_member_expr;
153  }
154  else if(expr.id()==ID_dereference)
155  {
156  auto new_expr = to_dereference_expr(expr);
157  auto r_pointer = simplify_rec(new_expr.pointer());
158  if(r_pointer.has_changed())
159  {
160  new_expr.pointer() = r_pointer.expr;
161  return std::move(new_expr);
162  }
163  }
164  else if(expr.id()==ID_if)
165  {
166  auto new_if_expr = to_if_expr(expr);
167 
168  bool no_change = true;
169 
170  auto r_cond = simplify_rec(new_if_expr.cond());
171  if(r_cond.has_changed())
172  {
173  new_if_expr.cond() = r_cond.expr;
174  no_change = false;
175  }
176 
177  auto true_result = simplify_address_of_arg(new_if_expr.true_case());
178  if(true_result.has_changed())
179  {
180  new_if_expr.true_case() = true_result.expr;
181  no_change = false;
182  }
183 
184  auto false_result = simplify_address_of_arg(new_if_expr.false_case());
185 
186  if(false_result.has_changed())
187  {
188  new_if_expr.false_case() = false_result.expr;
189  no_change = false;
190  }
191 
192  // condition is a constant?
193  if(new_if_expr.cond().is_true())
194  {
195  return new_if_expr.true_case();
196  }
197  else if(new_if_expr.cond().is_false())
198  {
199  return new_if_expr.false_case();
200  }
201 
202  if(!no_change)
203  return new_if_expr;
204  }
205 
206  return unchanged(expr);
207 }
208 
211 {
212  if(expr.type().id() != ID_pointer)
213  return unchanged(expr);
214 
215  auto new_object = simplify_address_of_arg(expr.object());
216 
217  if(new_object.expr.id() == ID_index)
218  {
219  auto index_expr = to_index_expr(new_object.expr);
220 
221  if(!index_expr.index().is_zero())
222  {
223  // we normalize &a[i] to (&a[0])+i
224  exprt offset = index_expr.op1();
225  index_expr.op1()=from_integer(0, offset.type());
226  auto new_address_of_expr = expr;
227  new_address_of_expr.object() = std::move(index_expr);
228  return plus_exprt(std::move(new_address_of_expr), offset);
229  }
230  }
231  else if(new_object.expr.id() == ID_dereference)
232  {
233  // simplify &*p to p
234  return to_dereference_expr(new_object.expr).pointer();
235  }
236 
237  if(new_object.has_changed())
238  {
239  auto new_expr = expr;
240  new_expr.object() = new_object;
241  return new_expr;
242  }
243  else
244  return unchanged(expr);
245 }
246 
249 {
250  const exprt &ptr = expr.op();
251 
252  if(ptr.id()==ID_if && ptr.operands().size()==3)
253  {
254  if_exprt if_expr=lift_if(expr, 0);
255  if_expr.true_case() =
257  if_expr.false_case() =
259  return changed(simplify_if(if_expr));
260  }
261 
262  if(ptr.type().id()!=ID_pointer)
263  return unchanged(expr);
264 
265  if(ptr.id()==ID_address_of)
266  {
267  auto offset = compute_pointer_offset(to_address_of_expr(ptr).object(), ns);
268 
269  if(offset.has_value())
270  return from_integer(*offset, expr.type());
271  }
272  else if(ptr.id()==ID_typecast) // pointer typecast
273  {
274  const auto &op = to_typecast_expr(ptr).op();
275  const typet &op_type = op.type();
276 
277  if(op_type.id()==ID_pointer)
278  {
279  // Cast from pointer to pointer.
280  // This just passes through, remove typecast.
281  auto new_expr = expr;
282  new_expr.op() = op;
283 
284  return changed(simplify_node(new_expr)); // recursive call
285  }
286  else if(op_type.id()==ID_signedbv ||
287  op_type.id()==ID_unsignedbv)
288  {
289  // Cast from integer to pointer, say (int *)x.
290 
291  if(op.is_constant())
292  {
293  // (T *)0x1234 -> 0x1234
294  exprt tmp = typecast_exprt(op, expr.type());
295  return changed(simplify_node(tmp));
296  }
297  else
298  {
299  // We do a bit of special treatment for (TYPE *)(a+(int)&o),
300  // which is re-written to 'a'.
301 
302  typet type = expr.type();
303  exprt tmp = op;
304  if(tmp.id()==ID_plus && tmp.operands().size()==2)
305  {
306  const auto &plus_expr = to_plus_expr(tmp);
307 
308  if(
309  plus_expr.op0().id() == ID_typecast &&
310  to_typecast_expr(plus_expr.op0()).op().id() == ID_address_of)
311  {
312  auto new_expr =
313  typecast_exprt::conditional_cast(plus_expr.op1(), type);
314 
315  return changed(simplify_node(new_expr));
316  }
317  else if(
318  plus_expr.op1().id() == ID_typecast &&
319  to_typecast_expr(plus_expr.op1()).op().id() == ID_address_of)
320  {
321  auto new_expr =
322  typecast_exprt::conditional_cast(plus_expr.op0(), type);
323 
324  return changed(simplify_node(new_expr));
325  }
326  }
327  }
328  }
329  }
330  else if(ptr.id()==ID_plus) // pointer arithmetic
331  {
332  exprt::operandst ptr_expr;
333  exprt::operandst int_expr;
334 
335  for(const auto &op : ptr.operands())
336  {
337  if(op.type().id()==ID_pointer)
338  ptr_expr.push_back(op);
339  else if(!op.is_zero())
340  {
341  exprt tmp=op;
342  if(tmp.type()!=expr.type())
343  tmp = simplify_node(typecast_exprt(tmp, expr.type()));
344 
345  int_expr.push_back(tmp);
346  }
347  }
348 
349  if(ptr_expr.size()!=1 || int_expr.empty())
350  return unchanged(expr);
351 
352  typet pointer_sub_type=ptr_expr.front().type().subtype();
353  if(pointer_sub_type.id()==ID_empty)
354  pointer_sub_type=char_type();
355 
356  auto element_size = pointer_offset_size(pointer_sub_type, ns);
357 
358  if(!element_size.has_value())
359  return unchanged(expr);
360 
361  // this might change the type of the pointer!
362  exprt pointer_offset_expr = simplify_node(pointer_offset(ptr_expr.front()));
363 
364  exprt sum;
365 
366  if(int_expr.size()==1)
367  sum=int_expr.front();
368  else
369  {
370  sum=exprt(ID_plus, expr.type());
371  sum.operands()=int_expr;
372  }
373 
374  sum = simplify_node(sum);
375 
376  exprt size_expr = from_integer(*element_size, expr.type());
377 
378  exprt product = mult_exprt(sum, size_expr);
379 
380  product = simplify_node(product);
381 
382  auto new_expr = plus_exprt(pointer_offset_expr, product);
383 
384  return changed(simplify_node(new_expr));
385  }
386  else if(ptr.id()==ID_constant)
387  {
388  const constant_exprt &c_ptr = to_constant_expr(ptr);
389 
390  if(c_ptr.get_value()==ID_NULL ||
391  c_ptr.value_is_zero_string())
392  {
393  auto new_expr = from_integer(0, expr.type());
394  return changed(simplify_node(new_expr));
395  }
396  else
397  {
398  // this is a pointer, we can't use to_integer
399  const auto width = to_pointer_type(ptr.type()).get_width();
400  mp_integer number = bvrep2integer(c_ptr.get_value(), width, false);
401  // a null pointer would have been caught above, return value 0
402  // will indicate that conversion failed
403  if(number==0)
404  return unchanged(expr);
405 
406  // The constant address consists of OBJECT-ID || OFFSET.
407  mp_integer offset_bits =
409  number%=power(2, offset_bits);
410 
411  auto new_expr = from_integer(number, expr.type());
412 
413  return changed(simplify_node(new_expr));
414  }
415  }
416 
417  return unchanged(expr);
418 }
419 
421  const binary_relation_exprt &expr)
422 {
423  // the operands of the relation are both either one of
424  // a) an address_of_exprt
425  // b) a typecast_exprt with an address_of_exprt operand
426 
427  PRECONDITION(expr.id() == ID_equal || expr.id() == ID_notequal);
428 
429  exprt tmp0=expr.op0();
430 
431  // skip over the typecast
432  if(tmp0.id()==ID_typecast)
433  tmp0 = to_typecast_expr(tmp0).op();
434 
435  PRECONDITION(tmp0.id() == ID_address_of);
436 
437  auto &tmp0_address_of = to_address_of_expr(tmp0);
438 
439  if(
440  tmp0_address_of.object().id() == ID_index &&
441  to_index_expr(tmp0_address_of.object()).index().is_zero())
442  {
443  tmp0_address_of =
444  address_of_exprt(to_index_expr(tmp0_address_of.object()).array());
445  }
446 
447  exprt tmp1=expr.op1();
448 
449  // skip over the typecast
450  if(tmp1.id()==ID_typecast)
451  tmp1 = to_typecast_expr(tmp1).op();
452 
453  PRECONDITION(tmp1.id() == ID_address_of);
454 
455  auto &tmp1_address_of = to_address_of_expr(tmp1);
456 
457  if(
458  tmp1_address_of.object().id() == ID_index &&
459  to_index_expr(tmp1_address_of.object()).index().is_zero())
460  {
461  tmp1 = address_of_exprt(to_index_expr(tmp1_address_of.object()).array());
462  }
463 
464  const auto &tmp0_object = tmp0_address_of.object();
465  const auto &tmp1_object = tmp1_address_of.object();
466 
467  if(tmp0_object.id() == ID_symbol && tmp1_object.id() == ID_symbol)
468  {
469  bool equal = to_symbol_expr(tmp0_object).get_identifier() ==
470  to_symbol_expr(tmp1_object).get_identifier();
471 
472  return make_boolean_expr(expr.id() == ID_equal ? equal : !equal);
473  }
474  else if(
475  tmp0_object.id() == ID_dynamic_object &&
476  tmp1_object.id() == ID_dynamic_object)
477  {
478  bool equal = to_dynamic_object_expr(tmp0_object).get_instance() ==
479  to_dynamic_object_expr(tmp1_object).get_instance();
480 
481  return make_boolean_expr(expr.id() == ID_equal ? equal : !equal);
482  }
483  else if(
484  (tmp0_object.id() == ID_symbol && tmp1_object.id() == ID_dynamic_object) ||
485  (tmp0_object.id() == ID_dynamic_object && tmp1_object.id() == ID_symbol))
486  {
487  return make_boolean_expr(expr.id() != ID_equal);
488  }
489 
490  return unchanged(expr);
491 }
492 
494  const binary_relation_exprt &expr)
495 {
496  PRECONDITION(expr.id() == ID_equal || expr.id() == ID_notequal);
497  PRECONDITION(expr.type().id() == ID_bool);
498 
499  exprt::operandst new_inequality_ops;
500  forall_operands(it, expr)
501  {
502  PRECONDITION(it->id() == ID_pointer_object);
503  const exprt &op = to_unary_expr(*it).op();
504 
505  if(op.id()==ID_address_of)
506  {
507  const auto &op_object = to_address_of_expr(op).object();
508 
509  if((op_object.id() != ID_symbol && op_object.id() != ID_dynamic_object &&
510  op_object.id() != ID_string_constant))
511  {
512  return unchanged(expr);
513  }
514  }
515  else if(op.id() != ID_constant || !op.is_zero())
516  {
517  return unchanged(expr);
518  }
519 
520  if(new_inequality_ops.empty())
521  new_inequality_ops.push_back(op);
522  else
523  {
524  new_inequality_ops.push_back(
526  op, new_inequality_ops.front().type())));
527  }
528  }
529 
530  auto new_expr = expr;
531 
532  new_expr.operands() = std::move(new_inequality_ops);
533 
534  return changed(simplify_inequality(new_expr));
535 }
536 
539 {
540  const exprt &op = expr.op();
541 
542  auto op_result = simplify_object(op);
543 
544  if(op_result.expr.id() == ID_if)
545  {
546  const if_exprt &if_expr = to_if_expr(op_result.expr);
547  exprt cond=if_expr.cond();
548 
549  auto p_o_false = expr;
550  p_o_false.op() = if_expr.false_case();
551 
552  auto p_o_true = expr;
553  p_o_true.op() = if_expr.true_case();
554 
555  auto new_expr = if_exprt(cond, p_o_true, p_o_false, expr.type());
556  return changed(simplify_rec(new_expr));
557  }
558 
559  if(op_result.has_changed())
560  {
561  auto new_expr = expr;
562  new_expr.op() = op_result;
563  return std::move(new_expr);
564  }
565  else
566  return unchanged(expr);
567 }
568 
571 {
572  auto new_expr = expr;
573  exprt &op = new_expr.op();
574 
575  if(op.id()==ID_if && op.operands().size()==3)
576  {
577  if_exprt if_expr=lift_if(expr, 0);
578  if_expr.true_case() =
580  if_expr.false_case() =
582  return changed(simplify_if(if_expr));
583  }
584 
585  bool no_change = true;
586 
587  auto op_result = simplify_object(op);
588 
589  if(op_result.has_changed())
590  {
591  op = op_result.expr;
592  no_change = false;
593  }
594 
595  // NULL is not dynamic
596  if(op.id() == ID_constant && op.get(ID_value) == ID_NULL)
597  return false_exprt();
598 
599  // &something depends on the something
600  if(op.id() == ID_address_of)
601  {
602  const auto &op_object = to_address_of_expr(op).object();
603 
604  if(op_object.id() == ID_symbol)
605  {
606  const irep_idt identifier = to_symbol_expr(op_object).get_identifier();
607 
608  // this is for the benefit of symex
609  return make_boolean_expr(
611  }
612  else if(op_object.id() == ID_string_constant)
613  {
614  return false_exprt();
615  }
616  else if(op_object.id() == ID_array)
617  {
618  return false_exprt();
619  }
620  }
621 
622  if(no_change)
623  return unchanged(expr);
624  else
625  return std::move(new_expr);
626 }
627 
630 {
631  auto new_expr = expr;
632  exprt &op = new_expr.op();
633  bool no_change = true;
634 
635  auto op_result = simplify_object(op);
636 
637  if(op_result.has_changed())
638  {
639  op = op_result.expr;
640  no_change = false;
641  }
642 
643  // NULL is not invalid
644  if(op.id()==ID_constant && op.get(ID_value)==ID_NULL)
645  {
646  return false_exprt();
647  }
648 
649  // &anything is not invalid
650  if(op.id()==ID_address_of)
651  {
652  return false_exprt();
653  }
654 
655  if(no_change)
656  return unchanged(expr);
657  else
658  return std::move(new_expr);
659 }
660 
663 {
664  auto new_expr = expr;
665  bool no_change = true;
666  exprt &op = new_expr.op();
667  auto op_result = simplify_object(op);
668 
669  if(op_result.has_changed())
670  {
671  op = op_result.expr;
672  no_change = false;
673  }
674 
675  if(op.id() == ID_address_of)
676  {
677  const auto &op_object = to_address_of_expr(op).object();
678 
679  if(op_object.id() == ID_symbol)
680  {
681  // just get the type
682  auto size_opt = size_of_expr(op_object.type(), ns);
683 
684  if(size_opt.has_value())
685  {
686  const typet &expr_type = expr.type();
687  exprt size = size_opt.value();
688 
689  if(size.type() != expr_type)
690  {
691  size = typecast_exprt(size, expr_type);
692  size = simplify_node(size);
693  }
694 
695  return size;
696  }
697  }
698  else if(op_object.id() == ID_string_constant)
699  {
700  typet type=expr.type();
701  return from_integer(
702  to_string_constant(op_object).get_value().size() + 1, type);
703  }
704  }
705 
706  if(no_change)
707  return unchanged(expr);
708  else
709  return std::move(new_expr);
710 }
711 
714 {
715  // we expand the definition
716  exprt def = good_pointer_def(expr.op(), ns);
717 
718  // recursive call
719  return changed(simplify_node(def));
720 }
mp_integer bvrep2integer(const irep_idt &src, std::size_t width, bool is_signed)
convert a bit-vector representation (possibly signed) to integer
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Definition: arith_tools.cpp:99
bool to_integer(const constant_exprt &expr, mp_integer &int_value)
Convert a constant expression expr to an arbitrary-precision integer.
Definition: arith_tools.cpp:19
mp_integer power(const mp_integer &base, const mp_integer &exponent)
A multi-precision implementation of the power operator.
bitvector_typet index_type()
Definition: c_types.cpp:16
pointer_typet pointer_type(const typet &subtype)
Definition: c_types.cpp:243
bitvector_typet char_type()
Definition: c_types.cpp:114
Operator to return the address of an object.
Definition: pointer_expr.h:200
exprt & object()
Definition: pointer_expr.h:209
exprt & op1()
Definition: expr.h:106
exprt & op0()
Definition: expr.h:103
A base class for relations, i.e., binary predicates whose two operands have the same type.
Definition: std_expr.h:675
std::size_t get_width() const
Definition: std_types.h:1048
struct configt::bv_encodingt bv_encoding
struct configt::ansi_ct ansi_c
A constant literal expression.
Definition: std_expr.h:2668
const irep_idt & get_value() const
Definition: std_expr.h:2676
bool value_is_zero_string() const
Definition: std_expr.cpp:23
Operator to dereference a pointer.
Definition: pointer_expr.h:256
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
unsigned int get_instance() const
Base class for all expressions.
Definition: expr.h:54
std::vector< exprt > operandst
Definition: expr.h:56
exprt & op1()
Definition: expr.h:106
bool is_zero() const
Return whether the expression is a constant representing 0.
Definition: expr.cpp:78
typet & type()
Return the type of the expression.
Definition: expr.h:82
operandst & operands()
Definition: expr.h:96
The Boolean constant false.
Definition: std_expr.h:2726
The trinary if-then-else operator.
Definition: std_expr.h:2087
exprt & true_case()
Definition: std_expr.h:2114
exprt & false_case()
Definition: std_expr.h:2124
exprt & cond()
Definition: std_expr.h:2104
exprt & array()
Definition: std_expr.h:1259
exprt & index()
Definition: std_expr.h:1269
const irep_idt & id() const
Definition: irep.h:407
const irep_idt & get(const irep_namet &name) const
Definition: irep.cpp:51
irep_idt get_component_name() const
Definition: std_expr.h:2542
Binary multiplication Associativity is not specified.
Definition: std_expr.h:936
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
Definition: namespace.cpp:51
The plus expression Associativity is not specified.
Definition: std_expr.h:831
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Definition: std_types.h:1495
const namespacet & ns
resultt simplify_inequality_address_of(const binary_relation_exprt &)
resultt simplify_good_pointer(const unary_exprt &)
static resultt changed(resultt<> result)
resultt simplify_address_of(const address_of_exprt &)
resultt simplify_if(const if_exprt &)
resultt simplify_pointer_offset(const unary_exprt &)
resultt simplify_rec(const exprt &)
resultt simplify_object(const exprt &)
resultt simplify_address_of_arg(const exprt &)
resultt simplify_inequality(const binary_relation_exprt &)
simplifies inequalities !=, <=, <, >=, >, and also ==
resultt simplify_object_size(const unary_exprt &)
resultt simplify_inequality_pointer_object(const binary_relation_exprt &)
static resultt unchanged(exprt expr)
resultt simplify_is_invalid_pointer(const unary_exprt &)
resultt simplify_is_dynamic_object(const unary_exprt &)
resultt simplify_node(exprt)
resultt simplify_pointer_object(const unary_exprt &)
const irep_idt & get_identifier() const
Definition: std_expr.h:110
Semantic type conversion.
Definition: std_expr.h:1781
static exprt conditional_cast(const exprt &expr, const typet &type)
Definition: std_expr.h:1789
The type of an expression, extends irept.
Definition: type.h:28
const typet & subtype() const
Definition: type.h:47
Generic base class for unary expressions.
Definition: std_expr.h:282
const exprt & op() const
Definition: std_expr.h:294
configt config
Definition: config.cpp:24
bool has_prefix(const std::string &s, const std::string &prefix)
Definition: converter.cpp:13
#define forall_operands(it, expr)
Definition: expr.h:18
constant_exprt make_boolean_expr(bool value)
returns true_exprt if given true and false_exprt otherwise
Definition: expr_util.cpp:284
if_exprt lift_if(const exprt &src, std::size_t operand_number)
lift up an if_exprt one level
Definition: expr_util.cpp:202
Deprecated expression utility functions.
const std::string & id2string(const irep_idt &d)
Definition: irep.h:49
BigInt mp_integer
Definition: mp_arith.h:19
API to expression classes for Pointers.
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
Definition: pointer_expr.h:312
const dynamic_object_exprt & to_dynamic_object_expr(const exprt &expr)
Cast an exprt to a dynamic_object_exprt.
Definition: pointer_expr.h:151
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
Definition: pointer_expr.h:237
optionalt< exprt > size_of_expr(const typet &type, const namespacet &ns)
optionalt< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
optionalt< mp_integer > member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
optionalt< mp_integer > compute_pointer_offset(const exprt &expr, const namespacet &ns)
optionalt< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
Pointer Logic.
exprt pointer_offset(const exprt &pointer)
exprt good_pointer_def(const exprt &pointer, const namespacet &ns)
Various predicates over pointers in programs.
#define SYMEX_DYNAMIC_PREFIX
static bool is_dereference_integer_object(const exprt &expr, mp_integer &address)
#define PRECONDITION(CONDITION)
Definition: invariant.h:464
API to expression classes.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Definition: std_expr.h:2152
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Definition: std_expr.h:2701
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition: std_expr.h:190
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
Definition: std_expr.h:1815
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
Definition: std_expr.h:870
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
Definition: std_expr.h:2612
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition: std_expr.h:329
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
Definition: std_expr.h:1297
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition: std_types.h:303
bool is_constant(const typet &type)
This method tests, if the given typet is a constant.
Definition: std_types.h:30
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
Definition: std_types.h:1533
const string_constantt & to_string_constant(const exprt &expr)
bool NULL_is_zero
Definition: config.h:168
std::size_t object_bits
Definition: config.h:256