CBMC
format_expr.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Expression Pretty Printing
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #include "format_expr.h"
13 
14 #include "arith_tools.h"
15 #include "bitvector_expr.h"
16 #include "byte_operators.h"
17 #include "expr_util.h"
18 #include "floatbv_expr.h"
19 #include "format_type.h"
20 #include "ieee_float.h"
21 #include "mathematical_expr.h"
22 #include "mp_arith.h"
23 #include "pointer_expr.h"
24 #include "string_utils.h"
25 
26 #include <map>
27 #include <ostream>
28 
29 // expressions that are rendered with infix operators
30 struct infix_opt
31 {
32  const char *rep;
33 };
34 
35 const std::map<irep_idt, infix_opt> infix_map = {
36  {ID_plus, {"+"}},
37  {ID_minus, {"-"}},
38  {ID_mult, {"*"}},
39  {ID_div, {"/"}},
40  {ID_equal, {"="}},
41  {ID_notequal, {u8"\u2260"}}, // /=, U+2260
42  {ID_and, {u8"\u2227"}}, // wedge, U+2227
43  {ID_or, {u8"\u2228"}}, // vee, U+2228
44  {ID_xor, {u8"\u2295"}}, // + in circle, U+2295
45  {ID_implies, {u8"\u21d2"}}, // =>, U+21D2
46  {ID_le, {u8"\u2264"}}, // <=, U+2264
47  {ID_ge, {u8"\u2265"}}, // >=, U+2265
48  {ID_lt, {"<"}},
49  {ID_gt, {">"}},
50 };
51 
55 static bool bracket_subexpression(const exprt &sub_expr, const exprt &expr)
56 {
57  // no need for parentheses whenever the subexpression
58  // doesn't have operands
59  if(!sub_expr.has_operands())
60  return false;
61 
62  // no need if subexpression isn't an infix operator
63  if(infix_map.find(sub_expr.id()) == infix_map.end())
64  return false;
65 
66  // * and / bind stronger than + and -
67  if(
68  (sub_expr.id() == ID_mult || sub_expr.id() == ID_div) &&
69  (expr.id() == ID_plus || expr.id() == ID_minus))
70  return false;
71 
72  // ==, !=, <, <=, >, >= bind stronger than && and ||
73  if(
74  (sub_expr.id() == ID_equal || sub_expr.id() == ID_notequal ||
75  sub_expr.id() == ID_lt || sub_expr.id() == ID_gt ||
76  sub_expr.id() == ID_le || sub_expr.id() == ID_ge) &&
77  (expr.id() == ID_and || expr.id() == ID_or))
78  return false;
79 
80  // +, -, *, / bind stronger than ==, !=, <, <=, >, >=
81  if(
82  (sub_expr.id() == ID_plus || sub_expr.id() == ID_minus ||
83  sub_expr.id() == ID_mult || sub_expr.id() == ID_div) &&
84  (expr.id() == ID_equal || expr.id() == ID_notequal || expr.id() == ID_lt ||
85  expr.id() == ID_gt || expr.id() == ID_le || expr.id() == ID_ge))
86  {
87  return false;
88  }
89 
90  return true;
91 }
92 
95 static std::ostream &format_rec(std::ostream &os, const multi_ary_exprt &src)
96 {
97  bool first = true;
98 
99  std::string operator_str = id2string(src.id()); // default
100 
101  if(src.id() == ID_equal && to_equal_expr(src).op0().is_boolean())
102  {
103  operator_str = u8"\u21d4"; // <=>, U+21D4
104  }
105  else
106  {
107  auto infix_map_it = infix_map.find(src.id());
108  if(infix_map_it != infix_map.end())
109  operator_str = infix_map_it->second.rep;
110  }
111 
112  for(const auto &op : src.operands())
113  {
114  if(first)
115  first = false;
116  else
117  os << ' ' << operator_str << ' ';
118 
119  const bool need_parentheses = bracket_subexpression(op, src);
120 
121  if(need_parentheses)
122  os << '(';
123 
124  os << format(op);
125 
126  if(need_parentheses)
127  os << ')';
128  }
129 
130  return os;
131 }
132 
135 static std::ostream &format_rec(std::ostream &os, const binary_exprt &src)
136 {
137  return format_rec(os, to_multi_ary_expr(src));
138 }
139 
142 static std::ostream &format_rec(std::ostream &os, const unary_exprt &src)
143 {
144  if(src.id() == ID_not)
145  os << u8"\u00ac"; // neg, U+00AC
146  else if(src.id() == ID_unary_minus)
147  os << '-';
148  else if(src.id() == ID_count_leading_zeros)
149  os << "clz";
150  else if(src.id() == ID_count_trailing_zeros)
151  os << "ctz";
152  else if(src.id() == ID_find_first_set)
153  os << "ffs";
154  else
155  return os << src.pretty();
156 
157  if(src.op().has_operands())
158  return os << '(' << format(src.op()) << ')';
159  else
160  return os << format(src.op());
161 }
162 
164 static std::ostream &format_rec(std::ostream &os, const ternary_exprt &src)
165 {
166  os << src.id() << '(' << format(src.op0()) << ", " << format(src.op1())
167  << ", " << format(src.op2()) << ')';
168  return os;
169 }
170 
172 static std::ostream &format_rec(std::ostream &os, const constant_exprt &src)
173 {
174  auto type = src.type().id();
175 
176  if(type == ID_bool)
177  {
178  if(src.is_true())
179  return os << "true";
180  else if(src.is_false())
181  return os << "false";
182  else
183  return os << src.pretty();
184  }
185  else if(
186  type == ID_unsignedbv || type == ID_signedbv || type == ID_c_bool ||
187  type == ID_c_bit_field)
188  return os << *numeric_cast<mp_integer>(src);
189  else if(type == ID_integer || type == ID_natural)
190  return os << src.get_value();
191  else if(type == ID_string)
192  return os << '"' << escape(id2string(src.get_value())) << '"';
193  else if(type == ID_floatbv)
194  return os << ieee_floatt(src);
195  else if(type == ID_pointer)
196  {
197  if(is_null_pointer(src))
198  return os << ID_NULL;
199  else if(
200  src.get_value() == "INVALID" || src.get_value().starts_with("INVALID-"))
201  {
202  return os << "INVALID-POINTER";
203  }
204  else
205  {
206  const auto &pointer_type = to_pointer_type(src.type());
207  const auto width = pointer_type.get_width();
208  auto int_value = bvrep2integer(src.get_value(), width, false);
209  return os << "pointer(0x" << integer2string(int_value, 16) << ", "
210  << format(pointer_type.base_type()) << ')';
211  }
212  }
213  else if(type == ID_c_enum_tag)
214  {
215  return os << string2integer(id2string(src.get_value()), 16);
216  }
217  else
218  return os << src.pretty();
219 }
220 
221 std::ostream &fallback_format_rec(std::ostream &os, const exprt &expr)
222 {
223  os << expr.id();
224 
225  for(const auto &s : expr.get_named_sub())
226  if(s.first != ID_type && s.first != ID_C_source_location)
227  os << ' ' << s.first << "=\"" << s.second.id() << '"';
228 
229  if(expr.has_operands())
230  {
231  os << '(';
232  bool first = true;
233 
234  for(const auto &op : expr.operands())
235  {
236  if(first)
237  first = false;
238  else
239  os << ", ";
240 
241  os << format(op);
242  }
243 
244  os << ')';
245  }
246 
247  return os;
248 }
249 
251 {
252 public:
254  {
255  setup();
256  }
257 
258  using formattert =
259  std::function<std::ostream &(std::ostream &, const exprt &)>;
260  using expr_mapt = std::unordered_map<irep_idt, formattert>;
261 
263 
265  const formattert &find_formatter(const exprt &);
266 
267 private:
269  void setup();
270 
272 };
273 
274 // The below generates textual output in a generic syntax
275 // that is inspired by C/C++/Java, and is meant for debugging
276 // purposes.
278 {
279  auto multi_ary_expr =
280  [](std::ostream &os, const exprt &expr) -> std::ostream & {
281  return format_rec(os, to_multi_ary_expr(expr));
282  };
283 
284  expr_map[ID_plus] = multi_ary_expr;
285  expr_map[ID_mult] = multi_ary_expr;
286  expr_map[ID_and] = multi_ary_expr;
287  expr_map[ID_or] = multi_ary_expr;
288  expr_map[ID_xor] = multi_ary_expr;
289 
290  auto binary_infix_expr =
291  [](std::ostream &os, const exprt &expr) -> std::ostream & {
292  return format_rec(os, to_binary_expr(expr));
293  };
294 
295  expr_map[ID_lt] = binary_infix_expr;
296  expr_map[ID_gt] = binary_infix_expr;
297  expr_map[ID_ge] = binary_infix_expr;
298  expr_map[ID_le] = binary_infix_expr;
299  expr_map[ID_div] = binary_infix_expr;
300  expr_map[ID_minus] = binary_infix_expr;
301  expr_map[ID_implies] = binary_infix_expr;
302  expr_map[ID_equal] = binary_infix_expr;
303  expr_map[ID_notequal] = binary_infix_expr;
304 
305  auto binary_prefix_expr =
306  [](std::ostream &os, const exprt &expr) -> std::ostream & {
307  os << expr.id() << '(' << format(to_binary_expr(expr).op0()) << ", "
308  << format(to_binary_expr(expr).op1()) << ')';
309  return os;
310  };
311 
312  expr_map[ID_ieee_float_equal] = binary_prefix_expr;
313  expr_map[ID_ieee_float_notequal] = binary_prefix_expr;
314 
315  auto unary_expr = [](std::ostream &os, const exprt &expr) -> std::ostream & {
316  return format_rec(os, to_unary_expr(expr));
317  };
318 
319  expr_map[ID_not] = unary_expr;
320  expr_map[ID_unary_minus] = unary_expr;
321 
322  auto unary_with_parentheses_expr =
323  [](std::ostream &os, const exprt &expr) -> std::ostream & {
324  return os << expr.id() << '(' << format(to_unary_expr(expr).op()) << ')';
325  };
326 
327  expr_map[ID_isnan] = unary_with_parentheses_expr;
328  expr_map[ID_isinf] = unary_with_parentheses_expr;
329  expr_map[ID_isfinite] = unary_with_parentheses_expr;
330  expr_map[ID_isnormal] = unary_with_parentheses_expr;
331 
332  auto ternary_expr =
333  [](std::ostream &os, const exprt &expr) -> std::ostream & {
334  return format_rec(os, to_ternary_expr(expr));
335  };
336 
337  expr_map[ID_floatbv_plus] = ternary_expr;
338  expr_map[ID_floatbv_minus] = ternary_expr;
339  expr_map[ID_floatbv_mult] = ternary_expr;
340  expr_map[ID_floatbv_div] = ternary_expr;
341  expr_map[ID_floatbv_mod] = ternary_expr;
342 
343  expr_map[ID_constant] =
344  [](std::ostream &os, const exprt &expr) -> std::ostream & {
345  return format_rec(os, to_constant_expr(expr));
346  };
347 
348  expr_map[ID_address_of] =
349  [](std::ostream &os, const exprt &expr) -> std::ostream & {
350  const auto &address_of = to_address_of_expr(expr);
351  return os << "address_of(" << format(address_of.object()) << ')';
352  };
353 
354  expr_map[ID_annotated_pointer_constant] =
355  [](std::ostream &os, const exprt &expr) -> std::ostream & {
356  const auto &annotated_pointer = to_annotated_pointer_constant_expr(expr);
357  return os << format(annotated_pointer.symbolic_pointer());
358  };
359 
360  expr_map[ID_typecast] =
361  [](std::ostream &os, const exprt &expr) -> std::ostream & {
362  return os << "cast(" << format(to_typecast_expr(expr).op()) << ", "
363  << format(expr.type()) << ')';
364  };
365 
366  expr_map[ID_floatbv_typecast] =
367  [](std::ostream &os, const exprt &expr) -> std::ostream & {
368  const auto &floatbv_typecast_expr = to_floatbv_typecast_expr(expr);
369  return os << "floatbv_typecast(" << format(floatbv_typecast_expr.op())
370  << ", " << format(floatbv_typecast_expr.type()) << ", "
371  << format(floatbv_typecast_expr.rounding_mode()) << ')';
372  };
373 
374  auto byte_extract =
375  [](std::ostream &os, const exprt &expr) -> std::ostream & {
376  const auto &byte_extract_expr = to_byte_extract_expr(expr);
377  return os << expr.id() << '(' << format(byte_extract_expr.op()) << ", "
378  << format(byte_extract_expr.offset()) << ", "
379  << format(byte_extract_expr.type()) << ')';
380  };
381 
382  expr_map[ID_byte_extract_little_endian] = byte_extract;
383  expr_map[ID_byte_extract_big_endian] = byte_extract;
384 
385  auto byte_update = [](std::ostream &os, const exprt &expr) -> std::ostream & {
386  const auto &byte_update_expr = to_byte_update_expr(expr);
387  return os << expr.id() << '(' << format(byte_update_expr.op()) << ", "
388  << format(byte_update_expr.offset()) << ", "
389  << format(byte_update_expr.value()) << ", "
390  << format(byte_update_expr.type()) << ')';
391  };
392 
393  expr_map[ID_byte_update_little_endian] = byte_update;
394  expr_map[ID_byte_update_big_endian] = byte_update;
395 
396  expr_map[ID_member] =
397  [](std::ostream &os, const exprt &expr) -> std::ostream & {
398  return os << format(to_member_expr(expr).op()) << '.'
400  };
401 
402  expr_map[ID_symbol] =
403  [](std::ostream &os, const exprt &expr) -> std::ostream & {
404  return os << to_symbol_expr(expr).get_identifier();
405  };
406 
407  expr_map[ID_index] =
408  [](std::ostream &os, const exprt &expr) -> std::ostream & {
409  const auto &index_expr = to_index_expr(expr);
410  return os << format(index_expr.array()) << '[' << format(index_expr.index())
411  << ']';
412  };
413 
414  expr_map[ID_type] =
415  [](std::ostream &os, const exprt &expr) -> std::ostream & {
416  return format_rec(os, expr.type());
417  };
418 
419  expr_map[ID_forall] =
420  [](std::ostream &os, const exprt &expr) -> std::ostream & {
421  os << u8"\u2200 ";
422  bool first = true;
423  for(const auto &symbol : to_quantifier_expr(expr).variables())
424  {
425  if(first)
426  first = false;
427  else
428  os << ", ";
429  os << format(symbol) << " : " << format(symbol.type());
430  }
431  return os << " . " << format(to_quantifier_expr(expr).where());
432  };
433 
434  expr_map[ID_exists] =
435  [](std::ostream &os, const exprt &expr) -> std::ostream & {
436  os << u8"\u2203 ";
437  bool first = true;
438  for(const auto &symbol : to_quantifier_expr(expr).variables())
439  {
440  if(first)
441  first = false;
442  else
443  os << ", ";
444  os << format(symbol) << " : " << format(symbol.type());
445  }
446  return os << " . " << format(to_quantifier_expr(expr).where());
447  };
448 
449  expr_map[ID_let] = [](std::ostream &os, const exprt &expr) -> std::ostream & {
450  const auto &let_expr = to_let_expr(expr);
451 
452  os << "LET ";
453 
454  bool first = true;
455 
456  const auto &values = let_expr.values();
457  auto values_it = values.begin();
458  for(auto &v : let_expr.variables())
459  {
460  if(first)
461  first = false;
462  else
463  os << ", ";
464 
465  os << format(v) << " = " << format(*values_it);
466  ++values_it;
467  }
468 
469  return os << " IN " << format(let_expr.where());
470  };
471 
472  expr_map[ID_lambda] =
473  [](std::ostream &os, const exprt &expr) -> std::ostream & {
474  const auto &lambda_expr = to_lambda_expr(expr);
475 
476  os << u8"\u03bb ";
477 
478  bool first = true;
479 
480  for(auto &v : lambda_expr.variables())
481  {
482  if(first)
483  first = false;
484  else
485  os << ", ";
486 
487  os << format(v);
488  }
489 
490  return os << " . " << format(lambda_expr.where());
491  };
492 
493  auto compound = [](std::ostream &os, const exprt &expr) -> std::ostream & {
494  os << "{ ";
495 
496  bool first = true;
497 
498  for(const auto &op : expr.operands())
499  {
500  if(first)
501  first = false;
502  else
503  os << ", ";
504 
505  os << format(op);
506  }
507 
508  return os << " }";
509  };
510 
511  expr_map[ID_array] = compound;
512  expr_map[ID_struct] = compound;
513 
514  expr_map[ID_array_of] =
515  [](std::ostream &os, const exprt &expr) -> std::ostream & {
516  const auto &array_of_expr = to_array_of_expr(expr);
517  return os << "array_of(" << format(array_of_expr.what()) << ')';
518  };
519 
520  expr_map[ID_if] = [](std::ostream &os, const exprt &expr) -> std::ostream & {
521  const auto &if_expr = to_if_expr(expr);
522  return os << '(' << format(if_expr.cond()) << " ? "
523  << format(if_expr.true_case()) << " : "
524  << format(if_expr.false_case()) << ')';
525  };
526 
527  expr_map[ID_string_constant] =
528  [](std::ostream &os, const exprt &expr) -> std::ostream & {
529  return os << '"' << expr.get_string(ID_value) << '"';
530  };
531 
532  expr_map[ID_function_application] =
533  [](std::ostream &os, const exprt &expr) -> std::ostream & {
534  const auto &function_application_expr = to_function_application_expr(expr);
535  os << format(function_application_expr.function()) << '(';
536  bool first = true;
537  for(auto &argument : function_application_expr.arguments())
538  {
539  if(first)
540  first = false;
541  else
542  os << ", ";
543  os << format(argument);
544  }
545  os << ')';
546  return os;
547  };
548 
549  expr_map[ID_dereference] =
550  [](std::ostream &os, const exprt &expr) -> std::ostream & {
551  const auto &dereference_expr = to_dereference_expr(expr);
552  os << '*';
553  if(dereference_expr.pointer().id() != ID_symbol)
554  os << '(' << format(dereference_expr.pointer()) << ')';
555  else
556  os << format(dereference_expr.pointer());
557  return os;
558  };
559 
560  expr_map[ID_saturating_minus] =
561  [](std::ostream &os, const exprt &expr) -> std::ostream & {
562  const auto &saturating_minus = to_saturating_minus_expr(expr);
563  return os << "saturating-(" << format(saturating_minus.lhs()) << ", "
564  << format(saturating_minus.rhs()) << ')';
565  };
566 
567  expr_map[ID_saturating_plus] =
568  [](std::ostream &os, const exprt &expr) -> std::ostream & {
569  const auto &saturating_plus = to_saturating_plus_expr(expr);
570  return os << "saturating+(" << format(saturating_plus.lhs()) << ", "
571  << format(saturating_plus.rhs()) << ')';
572  };
573 
574  expr_map[ID_object_address] =
575  [](std::ostream &os, const exprt &expr) -> std::ostream & {
576  const auto &object_address_expr = to_object_address_expr(expr);
577  return os << u8"\u275d" << object_address_expr.object_identifier()
578  << u8"\u275e";
579  };
580 
581  expr_map[ID_object_size] =
582  [](std::ostream &os, const exprt &expr) -> std::ostream & {
583  const auto &object_size_expr = to_object_size_expr(expr);
584  return os << "object_size(" << format(object_size_expr.op()) << ')';
585  };
586 
587  expr_map[ID_pointer_offset] =
588  [](std::ostream &os, const exprt &expr) -> std::ostream & {
589  const auto &pointer_offset_expr = to_pointer_offset_expr(expr);
590  return os << "pointer_offset(" << format(pointer_offset_expr.op()) << ')';
591  };
592 
593  expr_map[ID_field_address] =
594  [](std::ostream &os, const exprt &expr) -> std::ostream & {
595  const auto &field_address_expr = to_field_address_expr(expr);
596  return os << format(field_address_expr.base()) << u8".\u275d"
597  << field_address_expr.component_name() << u8"\u275e";
598  };
599 
600  fallback = [](std::ostream &os, const exprt &expr) -> std::ostream & {
601  return fallback_format_rec(os, expr);
602  };
603 }
604 
607 {
608  auto m_it = expr_map.find(expr.id());
609  if(m_it == expr_map.end())
610  return fallback;
611  else
612  return m_it->second;
613 }
614 
616 
618 {
619  format_expr_config.expr_map[id] = std::move(formatter);
620 }
621 
622 std::ostream &format_rec(std::ostream &os, const exprt &expr)
623 {
624  auto &formatter = format_expr_config.find_formatter(expr);
625  return formatter(os, expr);
626 }
mp_integer bvrep2integer(const irep_idt &src, std::size_t width, bool is_signed)
convert a bit-vector representation (possibly signed) to integer
API to expression classes for bitvectors.
const saturating_plus_exprt & to_saturating_plus_expr(const exprt &expr)
Cast an exprt to a saturating_plus_exprt.
const saturating_minus_exprt & to_saturating_minus_expr(const exprt &expr)
Cast an exprt to a saturating_minus_exprt.
Expression classes for byte-level operators.
const byte_update_exprt & to_byte_update_expr(const exprt &expr)
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
uint64_t u8
Definition: bytecode_info.h:58
pointer_typet pointer_type(const typet &subtype)
Definition: c_types.cpp:235
A base class for binary expressions.
Definition: std_expr.h:638
variablest & variables()
Definition: std_expr.h:3120
std::size_t get_width() const
Definition: std_types.h:920
A constant literal expression.
Definition: std_expr.h:2987
const irep_idt & get_value() const
Definition: std_expr.h:2995
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
bool starts_with(const char *s) const
equivalent of as_string().starts_with(s)
Definition: dstring.h:95
Base class for all expressions.
Definition: expr.h:56
bool has_operands() const
Return true if there is at least one operand.
Definition: expr.h:91
bool is_true() const
Return whether the expression is a constant representing true.
Definition: expr.cpp:27
bool is_false() const
Return whether the expression is a constant representing false.
Definition: expr.cpp:34
typet & type()
Return the type of the expression.
Definition: expr.h:84
operandst & operands()
Definition: expr.h:94
std::function< std::ostream &(std::ostream &, const exprt &)> formattert
void setup()
setup the expressions we can format
std::unordered_map< irep_idt, formattert > expr_mapt
const formattert & find_formatter(const exprt &)
find the formatter for a given expression
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
Definition: irep.cpp:482
named_subt & get_named_sub()
Definition: irep.h:446
const irep_idt & id() const
Definition: irep.h:384
irep_idt get_component_name() const
Definition: std_expr.h:2863
A base class for multi-ary expressions Associativity is not specified.
Definition: std_expr.h:912
const typet & base_type() const
The type of the data what we point to.
Definition: pointer_expr.h:35
const irep_idt & get_identifier() const
Definition: std_expr.h:160
An expression with three operands.
Definition: std_expr.h:67
exprt & op1()
Definition: expr.h:136
exprt & op2()
Definition: expr.h:139
exprt & op0()
Definition: expr.h:133
Generic base class for unary expressions.
Definition: std_expr.h:361
const exprt & op() const
Definition: std_expr.h:391
bool is_null_pointer(const constant_exprt &expr)
Returns true if expr has a pointer type and a value NULL; it also returns true when expr has value ze...
Definition: expr_util.cpp:369
Deprecated expression utility functions.
API to expression classes for floating-point arithmetic.
const floatbv_typecast_exprt & to_floatbv_typecast_expr(const exprt &expr)
Cast an exprt to a floatbv_typecast_exprt.
Definition: floatbv_expr.h:68
static format_containert< T > format(const T &o)
Definition: format.h:37
static bool bracket_subexpression(const exprt &sub_expr, const exprt &expr)
We use the precendences that most readers expect (i.e., the ones you learn in primary school),...
Definition: format_expr.cpp:55
static std::ostream & format_rec(std::ostream &os, const multi_ary_exprt &src)
This formats a multi-ary expression, adding parentheses where indicated by bracket_subexpression.
Definition: format_expr.cpp:95
format_expr_configt format_expr_config
const std::map< irep_idt, infix_opt > infix_map
Definition: format_expr.cpp:35
void add_format_hook(irep_idt id, format_expr_configt::formattert formatter)
std::ostream & fallback_format_rec(std::ostream &os, const exprt &expr)
const std::string & id2string(const irep_idt &d)
Definition: irep.h:40
API to expression classes for 'mathematical' expressions.
const lambda_exprt & to_lambda_expr(const exprt &expr)
Cast an exprt to a lambda_exprt.
const function_application_exprt & to_function_application_expr(const exprt &expr)
Cast an exprt to a function_application_exprt.
const quantifier_exprt & to_quantifier_expr(const exprt &expr)
Cast an exprt to a quantifier_exprt.
const mp_integer string2integer(const std::string &n, unsigned base)
Definition: mp_arith.cpp:54
const std::string integer2string(const mp_integer &n, unsigned base)
Definition: mp_arith.cpp:103
API to expression classes for Pointers.
const object_size_exprt & to_object_size_expr(const exprt &expr)
Cast an exprt to a object_size_exprt.
const annotated_pointer_constant_exprt & to_annotated_pointer_constant_expr(const exprt &expr)
Cast an exprt to an annotated_pointer_constant_exprt.
const pointer_offset_exprt & to_pointer_offset_expr(const exprt &expr)
Cast an exprt to a pointer_offset_exprt.
const field_address_exprt & to_field_address_expr(const exprt &expr)
Cast an exprt to an field_address_exprt.
Definition: pointer_expr.h:727
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
Definition: pointer_expr.h:890
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
Definition: pointer_expr.h:93
const object_address_exprt & to_object_address_expr(const exprt &expr)
Cast an exprt to an object_address_exprt.
Definition: pointer_expr.h:643
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
Definition: pointer_expr.h:577
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Definition: std_expr.h:2450
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
Definition: std_expr.h:3320
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Definition: std_expr.h:3037
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition: std_expr.h:272
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
Definition: std_expr.h:2102
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
Definition: std_expr.h:987
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition: std_expr.h:715
const ternary_exprt & to_ternary_expr(const exprt &expr)
Cast an exprt to a ternary_exprt.
Definition: std_expr.h:116
const array_of_exprt & to_array_of_expr(const exprt &expr)
Cast an exprt to an array_of_exprt.
Definition: std_expr.h:1598
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
Definition: std_expr.h:1402
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
Definition: std_expr.h:2933
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition: std_expr.h:426
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
Definition: std_expr.h:1533
std::string escape(const std::string &s)
Generic escaping of strings; this is not meant to be a particular programming language.
const char * rep
Definition: format_expr.cpp:32