Go to the documentation of this file.
84 if(
pos!=std::string::npos)
95 if(c_pos!=std::string::npos &&
96 dest.rfind(
"::")==c_pos)
97 dest.erase(0, c_pos+2);
98 else if(c_pos!=std::string::npos)
118 for(
const auto &symbol_id : symbols)
129 func = func.substr(0, func.rfind(
"::"));
139 if(!
shorthands.insert(std::make_pair(symbol_id, sh)).second)
143 for(
const auto &symbol_id : symbols)
159 has_collision=!
ns.
lookup(sh, symbol);
178 shorthands.insert(std::make_pair(symbol_id, sh));
190 const std::string &declarator)
192 std::unique_ptr<qualifierst> clone = qualifiers.
clone();
194 new_qualifiers.
read(src);
196 std::string q=new_qualifiers.
as_string();
198 std::string d = declarator.empty() ? declarator :
" " + declarator;
205 if(src.
id()==ID_bool)
209 else if(src.
id()==ID_c_bool)
213 else if(src.
id()==ID_string)
217 else if(src.
id()==ID_natural ||
218 src.
id()==ID_integer ||
219 src.
id()==ID_rational)
223 else if(src.
id()==ID_empty)
227 else if(src.
id()==ID_complex)
232 else if(src.
id()==ID_floatbv)
241 return q+
"long double"+d;
246 return q +
CPROVER_PREFIX +
"floatbv[" + swidth +
"][" + fwidth +
"]";
249 else if(src.
id()==ID_fixedbv)
257 else if(src.
id()==ID_c_bit_field)
262 else if(src.
id()==ID_signedbv ||
263 src.
id()==ID_unsignedbv)
269 if(c_type==ID_char &&
272 if(src.
id()==ID_signedbv)
273 return q+
"signed char"+d;
275 return q+
"unsigned char"+d;
277 else if(c_type!=ID_wchar_t && !c_type_str.
empty())
278 return q+c_type_str+d;
285 std::string sign_str=
is_signed?
"signed ":
"unsigned ";
291 return q+sign_str+
"int"+d;
297 return q+sign_str+
"long int"+d;
302 return q+sign_str+
"char"+d;
308 return q+sign_str+
"short int"+d;
314 return q+sign_str+
"long long int"+d;
320 return q + sign_str +
"__int128" + d;
328 else if(src.
id()==ID_struct)
332 else if(src.
id()==ID_union)
336 std::string dest=q+
"union";
360 else if(src.
id()==ID_c_enum)
387 for(c_enum_typet::memberst::const_iterator it = members.begin();
391 if(it != members.begin())
394 result +=
id2string(it->get_base_name());
405 else if(src.
id()==ID_c_enum_tag)
409 std::string result=q+
"enum";
414 else if(src.
id()==ID_pointer)
421 std::string new_declarator=
"*";
423 if(!q.empty() && (!declarator.empty() || subtype.
id() == ID_pointer))
425 new_declarator+=
" "+q;
428 new_declarator+=declarator;
432 subtype.
id() == ID_code ||
435 new_declarator=
"("+new_declarator+
")";
438 return convert_rec(subtype, sub_qualifiers, new_declarator);
440 else if(src.
id()==ID_array)
444 else if(src.
id()==ID_struct_tag)
449 std::string dest=q+
"struct";
457 else if(src.
id()==ID_union_tag)
462 std::string dest=q+
"union";
470 else if(src.
id()==ID_code)
476 std::string dest=declarator+
"(";
480 if(parameters.empty())
487 for(code_typet::parameterst::const_iterator
488 it=parameters.begin();
489 it!=parameters.end();
492 if(it!=parameters.begin())
495 if(it->get_identifier().empty())
499 std::string arg_declarator=
524 const typet *non_ptr_type = &return_type;
525 while(non_ptr_type->
id()==ID_pointer)
526 non_ptr_type = &(non_ptr_type->
subtype());
528 if(non_ptr_type->
id()==ID_code ||
529 non_ptr_type->
id()==ID_array)
530 dest=
convert_rec(return_type, ret_qualifiers, dest);
532 dest=
convert_rec(return_type, ret_qualifiers,
"")+
" "+dest;
538 if(dest[dest.size()-1]==
' ')
539 dest.resize(dest.size()-1);
544 else if(src.
id()==ID_vector)
548 const mp_integer size_int = numeric_cast_v<mp_integer>(vector_type.
size());
553 if(tmp==
"signed char" || tmp==
"char")
555 else if(tmp==
"signed short int")
557 else if(tmp==
"signed int")
559 else if(tmp==
"signed long long int")
561 else if(tmp==
"float")
563 else if(tmp==
"double")
569 dest+=
" __attribute__((vector_size (";
571 dest+=
"*sizeof("+subtype+
"))))";
576 else if(src.
id()==ID_constructor ||
577 src.
id()==ID_destructor)
579 return q+
"__attribute__(("+
id2string(src.
id())+
")) void"+d;
600 const std::string &qualifiers_str,
601 const std::string &declarator_str)
623 const std::string &qualifiers,
624 const std::string &declarator,
625 bool inc_struct_body,
626 bool inc_padding_components)
631 assert(inc_struct_body || !inc_padding_components);
635 std::string dest=qualifiers+
"struct";
648 if(
component.get_is_padding() && !inc_padding_components)
678 const std::string &declarator_str)
695 const std::string &declarator_str,
696 bool inc_size_if_possible)
699 std::string array_suffix;
701 if(
to_array_type(src).size().is_nil() || !inc_size_if_possible)
709 src.
subtype(), qualifiers, declarator_str+array_suffix);
714 unsigned &precedence)
724 if(to_type.
id()==ID_c_bool &&
728 if(to_type.
id()==ID_bool &&
732 std::string dest =
"(" +
convert(to_type) +
")";
748 const std::string &symbol1,
749 const std::string &symbol2,
795 const std::string &symbol,
807 std::string dest=symbol+
" { ";
837 for(
size_t i=1; i<src.
operands().size(); i+=2)
839 std::string op1, op2;
845 if(src.
operands()[i].id()==ID_member_name)
848 src.
operands()[i].get(ID_component_name);
863 display_component_name=component_name;
867 op1=
"."+
id2string(display_component_name);
895 std::string dest=
"LET ";
912 std::string op0, op1, op2;
926 const exprt &designator = src.
op1();
953 std::string dest=
"cond {\n";
970 condition=!condition;
980 const std::string &symbol,
982 bool full_parentheses)
1001 bool use_parentheses0=
1003 (precedence==p0 && full_parentheses) ||
1004 (precedence==p0 && src.
id()!=op0.
id());
1006 if(use_parentheses0)
1009 if(use_parentheses0)
1016 bool use_parentheses1=
1018 (precedence==p1 && full_parentheses) ||
1019 (precedence==p1 && src.
id()!=op1.
id());
1021 if(use_parentheses1)
1024 if(use_parentheses1)
1032 const std::string &symbol,
1033 unsigned precedence,
1034 bool full_parentheses)
1064 bool use_parentheses=
1066 (precedence==p && full_parentheses) ||
1067 (precedence==p && src.
id()!=it->id());
1081 const std::string &symbol,
1082 unsigned precedence)
1087 std::string dest=symbol;
1110 std::string dest =
"ALLOCATE";
1113 if(src.
type().
id()==ID_pointer &&
1120 dest += op0 +
", " + op1;
1128 unsigned &precedence)
1138 unsigned &precedence)
1153 unsigned &precedence)
1168 unsigned &precedence)
1171 return "PROB_UNIFORM(" +
convert(src.
type()) +
"," +
1179 std::string dest=name;
1200 unsigned precedence)
1207 if(*op0.rbegin()==
';')
1208 op0.resize(op0.size()-1);
1212 if(*op1.rbegin()==
';')
1213 op1.resize(op1.size()-1);
1215 std::string dest=op0;
1224 unsigned precedence)
1253 std::string dest=name;
1274 unsigned precedence)
1284 unsigned precedence)
1335 const std::string &symbol,
1336 unsigned precedence)
1357 unsigned precedence)
1380 const exprt &src,
unsigned &precedence)
1385 std::string dest=
"POINTER_ARITHMETIC(";
1417 const exprt &src,
unsigned &precedence)
1424 std::string dest=
"POINTER_DIFFERENCE(";
1429 op =
convert(binary_expr.op0().type());
1457 unsigned precedence;
1462 return "."+src.
get_string(ID_component_name);
1467 unsigned precedence;
1477 unsigned precedence)
1479 const auto &compound = src.
compound();
1484 if(compound.id() == ID_dereference)
1490 if(precedence > p || pointer.id() == ID_typecast)
1493 if(precedence > p || pointer.id() == ID_typecast)
1502 if(precedence > p || compound.id() == ID_typecast)
1505 if(precedence > p || compound.id() == ID_typecast)
1513 if(full_type.
id()!=ID_struct &&
1514 full_type.
id()!=ID_union)
1522 if(!component_name.
empty())
1529 if(!comp_expr.
get(ID_pretty_name).
empty())
1551 unsigned precedence)
1561 unsigned precedence)
1571 unsigned &precedence)
1587 to_unary_expr(src).op().
id() == ID_predicate_passive_symbol)
1593 std::unordered_map<irep_idt, irep_idt>::const_iterator entry =
1617 if(src.
id()==ID_next_symbol)
1618 dest=
"NEXT("+dest+
")";
1626 return "nondet_symbol("+
id2string(
id)+
")";
1631 const std::string &
id=src.
get_string(ID_identifier);
1632 return "ps("+
id+
")";
1637 const std::string &
id=src.
get_string(ID_identifier);
1638 return "pns("+
id+
")";
1643 const std::string &
id=src.
get_string(ID_identifier);
1644 return "pps("+
id+
")";
1649 const std::string &
id=src.
get_string(ID_identifier);
1655 return "nondet_bool()";
1660 unsigned &precedence)
1665 std::string result=
"<";
1684 unsigned &precedence)
1691 if(type.
id()==ID_integer ||
1692 type.
id()==ID_natural ||
1693 type.
id()==ID_rational)
1697 else if(type.
id()==ID_c_enum ||
1698 type.
id()==ID_c_enum_tag)
1704 if(c_enum_type.
id()!=ID_c_enum)
1718 for(
const auto &member : members)
1720 if(member.get_value() == int_value_string)
1721 return "/*enum*/" +
id2string(member.get_base_name());
1727 else if(type.
id()==ID_rational)
1729 else if(type.
id()==ID_bv)
1734 else if(type.
id()==ID_bool)
1738 else if(type.
id()==ID_unsignedbv ||
1739 type.
id()==ID_signedbv ||
1740 type.
id()==ID_c_bit_field ||
1741 type.
id()==ID_c_bool)
1749 type.
id()==ID_c_bit_field?type.
subtype().
get(ID_C_c_type):
1750 type.
get(ID_C_c_type);
1752 if(type.
id()==ID_c_bool)
1762 else if(int_value==
'\r')
1764 else if(int_value==
'\t')
1766 else if(int_value==
'\'')
1768 else if(int_value==
'\\')
1770 else if(int_value>=
' ' && int_value<126)
1773 dest += numeric_cast_v<char>(int_value);
1790 if(c_type==ID_unsigned_int)
1792 else if(c_type==ID_unsigned_long_int)
1794 else if(c_type==ID_signed_long_int)
1796 else if(c_type==ID_unsigned_long_long_int)
1798 else if(c_type==ID_signed_long_long_int)
1804 const auto sizeof_expr_opt =
1807 if(sizeof_expr_opt.has_value())
1810 dest =
convert(sizeof_expr_opt.value()) +
" /*" + dest +
"*/ ";
1816 else if(type.
id()==ID_floatbv)
1820 if(!dest.empty() && isdigit(dest[dest.size() - 1]))
1822 if(dest.find(
'.')==std::string::npos)
1832 else if(dest.size()==4 &&
1833 (dest[0]==
'+' || dest[0]==
'-'))
1839 else if(dest ==
"-inf")
1841 else if(dest ==
"+NaN")
1843 else if(dest ==
"-NaN")
1849 std::string suffix =
"";
1860 dest =
"(1.0" + suffix +
"/0.0" + suffix +
")";
1861 else if(dest ==
"-inf")
1862 dest =
"(-1.0" + suffix +
"/0.0" + suffix +
")";
1863 else if(dest ==
"+NaN")
1864 dest =
"(0.0" + suffix +
"/0.0" + suffix +
")";
1865 else if(dest ==
"-NaN")
1866 dest =
"(-0.0" + suffix +
"/0.0" + suffix +
")";
1870 else if(type.
id()==ID_fixedbv)
1874 if(!dest.empty() && isdigit(dest[dest.size() - 1]))
1882 else if(type.
id() == ID_array)
1886 else if(type.
id()==ID_pointer)
1897 dest=
"(("+
convert(type)+
")"+dest+
")";
1907 if(annotation.id() == ID_constant)
1911 if(op_value==
"INVALID" ||
1913 op_value==
"NULL+offset")
1922 else if(type.
id()==ID_string)
1946 unsigned &precedence)
1962 unsigned &precedence,
1963 bool include_padding_components)
1967 if(full_type.
id()!=ID_struct)
1976 if(components.size()!=src.
operands().size())
1979 std::string dest=
"{ ";
1981 exprt::operandst::const_iterator o_it=src.
operands().begin();
1989 if(o_it->type().id()==ID_code)
1992 if(
component.get_is_padding() && !include_padding_components)
2010 std::string tmp=
convert(*o_it);
2012 if(last_size+40<dest.size())
2015 last_size=dest.size();
2035 unsigned &precedence)
2039 if(type.
id() != ID_vector)
2042 std::string dest=
"{ ";
2064 if(last_size+40<dest.size())
2067 last_size=dest.size();
2082 unsigned &precedence)
2084 std::string dest=
"{ ";
2108 bool all_constant=
true;
2111 if(!it->is_constant())
2114 if(src.
get_bool(ID_C_string_constant) &&
2125 dest.reserve(dest.size()+1+src.
operands().size());
2127 bool last_was_hex=
false;
2148 case '\n': dest+=
"\\n";
break;
2149 case '\t': dest+=
"\\t";
break;
2150 case '\v': dest+=
"\\v";
break;
2151 case '\b': dest+=
"\\b";
break;
2152 case '\r': dest+=
"\\r";
break;
2153 case '\f': dest+=
"\\f";
break;
2154 case '\a': dest+=
"\\a";
break;
2155 case '\\': dest+=
"\\\\";
break;
2156 case '"': dest+=
"\\\"";
break;
2159 if(ch>=
' ' && ch!=127 && ch<0xff)
2160 dest+=
static_cast<char>(ch);
2163 std::ostringstream oss;
2164 oss <<
"\\x" << std::hex << ch;
2182 if(it->is_not_nil())
2202 unsigned &precedence)
2204 std::string dest=
"{ ";
2211 std::string tmp1=
convert(*it);
2215 std::string tmp2=
convert(*it);
2217 std::string tmp=
"["+tmp1+
"]="+tmp2;
2237 if(src.
id()!=ID_compound_literal)
2254 if(src.
id()!=ID_compound_literal)
2264 unsigned precedence;
2268 std::string dest=
".";
2336 unsigned &precedence)
2340 std::string dest=
"overflow(\"";
2367 return std::string(indent,
' ');
2382 if(!src.
operands()[1].operands().empty() ||
2383 !src.
operands()[2].operands().empty() ||
2384 !src.
operands()[3].operands().empty() ||
2385 !src.
operands()[4].operands().empty())
2393 if(it->operands().size()==2)
2408 if(it->operands().size()==2)
2425 if(it->id()==ID_gcc_asm_clobbered_register)
2454 unsigned precedence;
2480 unsigned precedence;
2509 unsigned precedence;
2546 unsigned precedence;
2588 unsigned precedence;
2604 const exprt &op=*it;
2606 if(op.
get(ID_statement)!=ID_block)
2608 unsigned precedence;
2642 unsigned precedence;
2650 const symbolt *symbol=
nullptr;
2661 dest +=
"__declspec(dllexport) ";
2664 if(symbol->
type.
id()==ID_code &&
2686 unsigned precedence;
2699 unsigned precedence;
2737 for(
const auto &statement : src.
statements())
2739 if(statement.get_statement() == ID_label)
2774 std::string expr_str;
2779 unsigned precedence;
2784 if(dest.empty() || *dest.rbegin()!=
';')
2794 static bool comment_done=
false;
2809 std::ostringstream oss;
2817 [](
const std::pair<irep_idt, irept> &p) { return p.first; });
2828 if(statement==ID_expression)
2831 if(statement==ID_block)
2834 if(statement==ID_switch)
2837 if(statement==ID_for)
2840 if(statement==ID_while)
2843 if(statement==ID_asm)
2846 if(statement==ID_skip)
2849 if(statement==ID_dowhile)
2852 if(statement==ID_ifthenelse)
2855 if(statement==ID_return)
2858 if(statement==ID_goto)
2861 if(statement==ID_printf)
2864 if(statement==ID_fence)
2873 if(statement==ID_assume)
2876 if(statement==ID_assert)
2879 if(statement==ID_break)
2882 if(statement==ID_continue)
2885 if(statement==ID_decl)
2888 if(statement==ID_decl_block)
2891 if(statement==ID_dead)
2894 if(statement==ID_assign)
2897 if(statement==
"lock")
2900 if(statement==
"unlock")
2903 if(statement==ID_atomic_begin)
2906 if(statement==ID_atomic_end)
2909 if(statement==ID_function_call)
2912 if(statement==ID_label)
2915 if(statement==ID_switch_case)
2918 if(statement==ID_array_set)
2921 if(statement==ID_array_copy)
2924 if(statement==ID_array_replace)
2927 if(statement == ID_set_may || statement == ID_set_must)
2931 unsigned precedence;
2949 unsigned precedence;
2962 unsigned precedence;
2975 unsigned precedence;
3006 if(it!=arguments.begin())
3021 std::string dest=
indent_str(indent)+
"printf(";
3043 std::string dest=
indent_str(indent)+
"FENCE(";
3046 { ID_WRfence, ID_RRfence, ID_RWfence, ID_WWfence,
3047 ID_RRcumul, ID_RWcumul, ID_WWcumul, ID_WRcumul,
3052 for(
unsigned i=0; !att[i].
empty(); i++)
3073 std::string dest=
indent_str(indent)+
"INPUT(";
3095 std::string dest=
indent_str(indent)+
"OUTPUT(";
3116 std::string dest=
indent_str(indent)+
"ARRAY_SET(";
3138 std::string dest=
indent_str(indent)+
"ARRAY_COPY(";
3160 std::string dest=
indent_str(indent)+
"ARRAY_REPLACE(";
3183 unsigned precedence;
3196 unsigned precedence;
3208 std::string labels_string;
3212 labels_string+=
"\n";
3215 labels_string+=
":\n";
3219 return labels_string+tmp;
3226 std::string labels_string;
3230 labels_string+=
"\n";
3232 labels_string+=
"default:\n";
3236 labels_string+=
"\n";
3238 labels_string+=
"case ";
3240 labels_string+=
":\n";
3243 unsigned next_indent=indent;
3249 return labels_string+tmp;
3259 unsigned precedence;
3267 static_cast<const codet &
>(src.
find(ID_code));
3269 std::string dest=
"\n";
3274 std::string assumption_str=
convert(assumption);
3276 dest+=assumption_str;
3289 std::string assertion_str=
convert(assertion);
3291 dest+=assertion_str;
3326 unsigned &precedence)
3331 std::string dest=
"sizeof(";
3340 unsigned &precedence)
3344 if(src.
id()==ID_plus)
3347 else if(src.
id()==ID_minus)
3350 else if(src.
id()==ID_unary_minus)
3353 else if(src.
id()==ID_unary_plus)
3356 else if(src.
id()==ID_floatbv_plus)
3359 else if(src.
id()==ID_floatbv_minus)
3362 else if(src.
id()==ID_floatbv_mult)
3365 else if(src.
id()==ID_floatbv_div)
3368 else if(src.
id()==ID_floatbv_rem)
3371 else if(src.
id()==ID_floatbv_typecast)
3375 std::string dest=
"FLOAT_TYPECAST(";
3404 else if(src.
id()==ID_sign)
3412 else if(src.
id()==ID_popcount)
3420 else if(src.
id() == ID_r_ok)
3423 else if(src.
id() == ID_w_ok)
3426 else if(src.
id() == ID_is_invalid_pointer)
3429 else if(src.
id()==ID_good_pointer)
3432 else if(src.
id()==ID_object_size)
3435 else if(src.
id()==
"pointer_arithmetic")
3438 else if(src.
id()==
"pointer_difference")
3441 else if(src.
id() == ID_null_object)
3442 return "NULL-object";
3444 else if(src.
id()==ID_integer_address ||
3445 src.
id()==ID_integer_address_object ||
3446 src.
id()==ID_stack_object ||
3447 src.
id()==ID_static_object)
3452 else if(src.
id()==ID_infinity)
3455 else if(src.
id()==
"builtin-function")
3458 else if(src.
id()==ID_pointer_object)
3461 else if(src.
id() == ID_get_must)
3464 else if(src.
id() == ID_get_may)
3467 else if(src.
id()==
"object_value")
3470 else if(src.
id()==ID_array_of)
3473 else if(src.
id()==ID_pointer_offset)
3476 else if(src.
id()==
"pointer_base")
3479 else if(src.
id()==
"pointer_cons")
3482 else if(src.
id() == ID_is_invalid_pointer)
3485 else if(src.
id() == ID_dynamic_object)
3488 else if(src.
id() == ID_is_dynamic_object)
3491 else if(src.
id()==
"is_zero_string")
3494 else if(src.
id()==
"zero_string")
3497 else if(src.
id()==
"zero_string_length")
3500 else if(src.
id()==
"buffer_size")
3503 else if(src.
id()==ID_isnan)
3506 else if(src.
id()==ID_isfinite)
3509 else if(src.
id()==ID_isinf)
3512 else if(src.
id()==ID_bswap)
3518 else if(src.
id()==ID_isnormal)
3521 else if(src.
id()==ID_builtin_offsetof)
3524 else if(src.
id()==ID_gcc_builtin_va_arg)
3527 else if(src.
id()==ID_alignof)
3537 else if(src.
id()==ID_address_of)
3541 if(
object.
id() == ID_label)
3542 return "&&" +
object.
get_string(ID_identifier);
3543 else if(
object.
id() == ID_index &&
to_index_expr(
object).index().is_zero())
3551 else if(src.
id()==ID_dereference)
3555 if(src.
type().
id() == ID_code)
3558 pointer.id() == ID_plus && pointer.operands().size() == 2 &&
3569 else if(src.
id()==ID_index)
3572 else if(src.
id()==ID_member)
3575 else if(src.
id()==
"array-member-value")
3578 else if(src.
id()==
"struct-member-value")
3581 else if(src.
id()==ID_function_application)
3584 else if(src.
id()==ID_side_effect)
3587 if(statement==ID_preincrement)
3589 else if(statement==ID_predecrement)
3591 else if(statement==ID_postincrement)
3593 else if(statement==ID_postdecrement)
3595 else if(statement==ID_assign_plus)
3597 else if(statement==ID_assign_minus)
3599 else if(statement==ID_assign_mult)
3601 else if(statement==ID_assign_div)
3603 else if(statement==ID_assign_mod)
3605 else if(statement==ID_assign_shl)
3607 else if(statement==ID_assign_shr)
3609 else if(statement==ID_assign_bitand)
3611 else if(statement==ID_assign_bitxor)
3613 else if(statement==ID_assign_bitor)
3615 else if(statement==ID_assign)
3617 else if(statement==ID_function_call)
3620 else if(statement == ID_allocate)
3622 else if(statement==ID_printf)
3624 else if(statement==ID_nondet)
3626 else if(statement==
"prob_coin")
3628 else if(statement==
"prob_unif")
3630 else if(statement==ID_statement_expression)
3632 else if(statement == ID_va_start)
3638 else if(src.
id()==ID_literal)
3641 else if(src.
id()==ID_not)
3644 else if(src.
id()==ID_bitnot)
3647 else if(src.
id()==ID_mult)
3650 else if(src.
id()==ID_div)
3653 else if(src.
id()==ID_mod)
3656 else if(src.
id()==ID_shl)
3659 else if(src.
id()==ID_ashr || src.
id()==ID_lshr)
3662 else if(src.
id()==ID_lt || src.
id()==ID_gt ||
3663 src.
id()==ID_le || src.
id()==ID_ge)
3669 else if(src.
id()==ID_notequal)
3672 else if(src.
id()==ID_equal)
3675 else if(src.
id()==ID_ieee_float_equal)
3678 else if(src.
id()==ID_width)
3681 else if(src.
id()==ID_concatenation)
3684 else if(src.
id()==ID_ieee_float_notequal)
3687 else if(src.
id()==ID_abs)
3690 else if(src.
id()==ID_complex_real)
3693 else if(src.
id()==ID_complex_imag)
3696 else if(src.
id()==ID_complex)
3699 else if(src.
id()==ID_bitand)
3702 else if(src.
id()==ID_bitxor)
3705 else if(src.
id()==ID_bitor)
3708 else if(src.
id()==ID_and)
3711 else if(src.
id()==ID_or)
3714 else if(src.
id()==ID_xor)
3717 else if(src.
id()==ID_implies)
3720 else if(src.
id()==ID_if)
3723 else if(src.
id()==ID_forall)
3727 else if(src.
id()==ID_exists)
3731 else if(src.
id()==ID_lambda)
3735 else if(src.
id()==ID_with)
3738 else if(src.
id()==ID_update)
3741 else if(src.
id()==ID_member_designator)
3744 else if(src.
id()==ID_index_designator)
3747 else if(src.
id()==ID_symbol)
3750 else if(src.
id()==ID_next_symbol)
3753 else if(src.
id()==ID_nondet_symbol)
3756 else if(src.
id()==ID_predicate_symbol)
3759 else if(src.
id()==ID_predicate_next_symbol)
3762 else if(src.
id()==ID_predicate_passive_symbol)
3765 else if(src.
id()==
"quant_symbol")
3768 else if(src.
id()==ID_nondet_bool)
3771 else if(src.
id()==ID_object_descriptor)
3774 else if(src.
id()==
"Hoare")
3777 else if(src.
id()==ID_code)
3780 else if(src.
id()==ID_constant)
3783 else if(src.
id()==ID_string_constant)
3787 else if(src.
id()==ID_struct)
3790 else if(src.
id()==ID_vector)
3793 else if(src.
id()==ID_union)
3796 else if(src.
id()==ID_array)
3799 else if(src.
id() == ID_array_list)
3802 else if(src.
id()==ID_typecast)
3805 else if(src.
id()==ID_comma)
3808 else if(src.
id()==ID_ptr_object)
3809 return "PTR_OBJECT("+
id2string(src.
get(ID_identifier))+
")";
3811 else if(src.
id()==ID_cond)
3815 src.
id() == ID_overflow_unary_minus || src.
id() == ID_overflow_minus ||
3816 src.
id() == ID_overflow_mult || src.
id() == ID_overflow_plus ||
3817 src.
id() == ID_overflow_shl)
3822 else if(src.
id()==ID_unknown)
3825 else if(src.
id()==ID_invalid)
3828 else if(src.
id()==ID_extractbit)
3831 else if(src.
id()==ID_extractbits)
3834 else if(src.
id()==ID_initializer_list ||
3835 src.
id()==ID_compound_literal)
3841 else if(src.
id()==ID_designated_initializer)
3847 else if(src.
id()==ID_sizeof)
3850 else if(src.
id()==ID_let)
3853 else if(src.
id()==ID_type)
3862 unsigned precedence;
3873 const std::string &identifier)
3885 expr2c.get_shorthands(expr);
3886 return expr2c.convert(expr);
3901 return expr2c.convert(type);
3911 const std::string &identifier,
3916 return expr2c.convert_with_identifier(type, identifier);
std::string MetaString(const std::string &in)
virtual void read(const typet &src) override
#define UNREACHABLE
This should be used to mark dead code.
const componentst & components() const
void irep2lisp(const irept &src, lispexprt &dest)
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
const exprt & case_op() const
const irep_idt & get_function() const
const irep_idt & get_comment() const
bool has_ellipsis() const
std::string convert_code_while(const code_whilet &src, unsigned indent)
A codet representing sequential composition of program statements.
const update_exprt & to_update_expr(const exprt &expr)
Cast an exprt to an update_exprt.
const char * c_str() const
std::string convert_prob_uniform(const exprt &src, unsigned &precedence)
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const typet & subtype() const
codet representation of a switch-case, i.e. a case statement within a switch.
std::string convert_code_fence(const codet &src, unsigned indent)
side_effect_expr_function_callt & to_side_effect_expr_function_call(exprt &expr)
const div_exprt & to_div_expr(const exprt &expr)
Cast an exprt to a div_exprt.
std::string convert_cond(const exprt &src, unsigned precedence)
bool can_cast_expr< code_inputt >(const exprt &base)
Expression corresponding to op() where the bytes starting at position offset (given in number of byte...
const exprt & cond() const
codet representing a while statement.
Expression to hold a nondeterministic choice.
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
std::string convert_union(const exprt &src, unsigned &precedence)
codet representation of an inline assembler statement.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
codet representation of a for statement.
const irep_idt & get_identifier() const
std::string convert_statement_expression(const exprt &src, unsigned &precendence)
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
The type of an expression, extends irept.
const irept::named_subt & get_pragmas() const
std::vector< parametert > parameterst
static std::string clean_identifier(const irep_idt &id)
const codet & then_case() const
An expression with three operands.
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
std::string convert_comma(const exprt &src, unsigned precedence)
std::string convert_pointer_arithmetic(const exprt &src, unsigned &precedence)
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
bool use_library_macros
This is the string that will be printed for null pointers.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
std::string convert_code_assert(const codet &src, unsigned indent)
Base type for structs and unions.
std::string convert_with_identifier(const typet &src, const std::string &identifier)
Build a declaration string, which requires converting both a type and putting an identifier in the sy...
typet type
Type of symbol.
floatbv_typet long_double_type()
std::string to_ansi_c_string() const
A side_effect_exprt representation of a function call side effect.
std::unordered_set< irep_idt > find_symbol_identifiers(const exprt &src)
Find identifiers of the sub expressions with id ID_symbol.
std::string convert_quantifier(const quantifier_exprt &, const std::string &symbol, unsigned precedence)
std::vector< c_enum_membert > memberst
bool is_signed(const typet &t)
Convenience function – is the type signed?
Various predicates over pointers in programs.
std::string convert_code_function_call(const code_function_callt &src, unsigned indent)
virtual std::string convert_constant(const constant_exprt &src, unsigned &precedence)
std::string convert_update(const update_exprt &, unsigned precedence)
std::string convert_let(const let_exprt &, unsigned precedence)
std::string convert_byte_extract(const byte_extract_exprt &, unsigned precedence)
const irept & find(const irep_namet &name) const
void replace(const union_find_replacet &replace_map, string_not_contains_constraintt &constraint)
std::string convert_code_decl(const codet &src, unsigned indent)
symbol_exprt & symbol()
convenience accessor for the symbol of a single binding
std::string convert_code_decl_block(const codet &src, unsigned indent)
std::string convert_nondet_bool()
const string_constantt & to_string_constant(const exprt &expr)
std::string convert_code_expression(const codet &src, unsigned indent)
Base class for all expressions.
const exprt & iter() const
std::string convert_quantified_symbol(const exprt &src)
std::vector< componentt > componentst
Generic base class for unary expressions.
std::string convert_array_list(const exprt &src, unsigned &precedence)
A base class for binary expressions.
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
irep_idt base_name
Base (non-scoped) name.
A struct tag type, i.e., struct_typet with an identifier.
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
std::string from_type(const namespacet &ns, const irep_idt &identifier, const typet &type)
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
static expr2c_configurationt default_configuration
This prints a human readable C like syntax that closely mirrors the internals of the GOTO program.
const code_whilet & to_code_while(const codet &code)
const irep_idt & get_pretty_name() const
std::string convert_code_input(const codet &src, unsigned indent)
A base class for quantifier expressions.
const exprt & cond() const
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
std::string convert_Hoare(const exprt &src)
std::string convert_code(const codet &src)
bool is_true() const
Return whether the expression is a constant representing true.
virtual std::string convert_constant_bool(bool boolean_value)
To get the C-like representation of a given boolean value.
std::string convert_array_of(const exprt &src, unsigned precedence)
std::string convert_unary_post(const exprt &src, const std::string &symbol, unsigned precedence)
struct configt::ansi_ct ansi_c
std::string convert_code_ifthenelse(const code_ifthenelset &src, unsigned indent)
Expression to hold a symbol (variable)
bool has_suffix(const std::string &s, const std::string &suffix)
virtual std::string convert_struct_type(const typet &src, const std::string &qualifiers_str, const std::string &declarator_str)
To generate C-like string for defining the given struct.
std::string convert_code_switch_case(const code_switch_caset &src, unsigned indent)
std::string convert_predicate_symbol(const exprt &src)
const code_fort & to_code_for(const codet &code)
std::unordered_map< irep_idt, irep_idt > shorthands
codet representation of an if-then-else statement.
A union tag type, i.e., union_typet with an identifier.
std::string convert_trinary(const ternary_exprt &src, const std::string &symbol1, const std::string &symbol2, unsigned precedence)
const codet & to_code(const exprt &expr)
std::string convert_code_assign(const code_assignt &src, unsigned indent)
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const code_switch_caset & to_code_switch_case(const codet &code)
std::string convert_overflow(const exprt &src, unsigned &precedence)
std::unordered_map< irep_idt, std::unordered_set< irep_idt > > ns_collision
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
code_operandst & statements()
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
const nondet_symbol_exprt & to_nondet_symbol_expr(const exprt &expr)
Cast an exprt to a nondet_symbol_exprt.
typet & type()
Return the type of the expression.
exprt & value()
convenience accessor for the value of a single binding
std::string convert_typecast(const typecast_exprt &src, unsigned &precedence)
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
codet representation of a function call statement.
bool get_bool(const irep_namet &name) const
std::string convert_predicate_passive_symbol(const exprt &src)
std::size_t get_component_number() const
virtual std::string convert(const typet &src)
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
codet representation of a do while statement.
std::string convert_code_array_set(const codet &src, unsigned indent)
std::string convert_code_for(const code_fort &src, unsigned indent)
std::string convert_member_designator(const exprt &src)
std::string convert_array_member_value(const exprt &src, unsigned precedence)
const exprt & init() const
const fixedbv_typet & to_fixedbv_type(const typet &type)
Cast a typet to a fixedbv_typet.
signedbv_typet signed_int_type()
std::string convert_nondet_symbol(const nondet_symbol_exprt &)
const mod_exprt & to_mod_expr(const exprt &expr)
Cast an exprt to a mod_exprt.
std::string convert_code_printf(const codet &src, unsigned indent)
std::string expr2string() const
bool has_operands() const
Return true if there is at least one operand.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
const std::string & id2string(const irep_idt &d)
static std::string indent_str(unsigned indent)
const exprt & compound() const
std::string to_ansi_c_string() const
#define forall_operands(it, expr)
const byte_update_exprt & to_byte_update_expr(const exprt &expr)
#define SYMEX_DYNAMIC_PREFIX
std::string convert_function(const exprt &src, const std::string &symbol)
std::string expr2c(const exprt &expr, const namespacet &ns, const expr2c_configurationt &configuration)
Stream & join_strings(Stream &&os, const It b, const It e, const Delimiter &delimiter, TransformFunc &&transform_func)
Prints items to an stream, separated by a constant delimiter.
const code_ifthenelset & to_code_ifthenelse(const codet &code)
codet representation of a label for branch targets.
virtual std::unique_ptr< qualifierst > clone() const =0
const irep_idt & get_identifier() const
optionalt< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
std::string convert_pointer_difference(const exprt &src, unsigned &precedence)
bitvector_typet wchar_t_type()
std::string convert_prob_coin(const exprt &src, unsigned &precedence)
const code_labelt & to_code_label(const codet &code)
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
floatbv_typet float_type()
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
bool include_struct_padding_components
When printing struct_typet or struct_exprt, include the artificial padding components introduced to k...
std::string convert_code_asm(const code_asmt &src, unsigned indent)
const std::string & id_string() const
Application of (mathematical) function.
const notequal_exprt & to_notequal_expr(const exprt &expr)
Cast an exprt to an notequal_exprt.
std::size_t long_long_int_width
const code_dowhilet & to_code_dowhile(const codet &code)
std::string convert_code_lock(const codet &src, unsigned indent)
std::string convert_code_label(const code_labelt &src, unsigned indent)
std::string convert_unary(const unary_exprt &, const std::string &symbol, unsigned precedence)
std::string convert_extractbits(const extractbits_exprt &src, unsigned precedence)
unsignedbv_typet unsigned_int_type()
std::string convert_array(const exprt &src)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const exprt & cond() const
std::string convert_code_goto(const codet &src, unsigned indent)
virtual std::string convert_symbol(const exprt &src)
const codet & body() const
const irep_idt & id() const
std::string convert_predicate_next_symbol(const exprt &src)
std::string convert_index(const exprt &src, unsigned precedence)
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
std::string convert_byte_update(const byte_update_exprt &, unsigned precedence)
const code_function_callt & to_code_function_call(const codet &code)
std::vector< exprt > operandst
std::string convert_code_assume(const codet &src, unsigned indent)
const code_returnt & to_code_return(const codet &code)
virtual std::string convert_struct(const exprt &src, unsigned &precedence)
std::string convert_initializer_list(const exprt &src)
const parameterst & parameters() const
std::string convert_side_effect_expr_function_call(const side_effect_expr_function_callt &src)
const expr2c_configurationt & configuration
const constant_exprt & size() const
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
Operator to update elements in structs and arrays.
std::string convert_code_continue(unsigned indent)
std::string convert_code_break(unsigned indent)
floatbv_typet double_type()
std::string convert_code_array_copy(const codet &src, unsigned indent)
std::string convert_extractbit(const extractbit_exprt &, unsigned precedence)
bitvector_typet char_type()
std::size_t get_width() const
const irep_idt & get_label() const
std::string convert_norep(const exprt &src, unsigned &precedence)
std::string convert_literal(const exprt &src)
code_asmt & to_code_asm(codet &code)
Extract member of struct or union.
const std::string & get_string(const irep_namet &name) const
std::string convert_function_application(const function_application_exprt &src)
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
std::string convert_with(const exprt &src, unsigned precedence)
bool can_cast_expr< code_outputt >(const exprt &base)
Structure type, corresponds to C style structs.
C enum tag type, i.e., c_enum_typet with an identifier.
std::string convert_code_block(const code_blockt &src, unsigned indent)
std::string c_type_as_string(const irep_idt &c_type)
optionalt< exprt > build_sizeof_expr(const constant_exprt &expr, const namespacet &ns)
std::size_t get_fraction_bits() const
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
const quantifier_exprt & to_quantifier_expr(const exprt &expr)
Cast an exprt to a quantifier_exprt.
std::string convert_code_array_replace(const codet &src, unsigned indent)
bool print_struct_body_in_type
When printing a struct_typet, should the components of the struct be printed inline.
const code_assignt & to_code_assign(const codet &code)
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
const irep_idt & get(const irep_namet &name) const
std::string convert_code_unlock(const codet &src, unsigned indent)
source_locationt location
Source code location of definition of symbol.
const floatbv_typecast_exprt & to_floatbv_typecast_expr(const exprt &expr)
Cast an exprt to a floatbv_typecast_exprt.
const implies_exprt & to_implies_expr(const exprt &expr)
Cast an exprt to a implies_exprt.
std::string convert_nondet(const exprt &src, unsigned &precedence)
void get_shorthands(const exprt &expr)
const codet & body() const
std::string convert_code_dowhile(const code_dowhilet &src, unsigned indent)
exprt::operandst & arguments()
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const codet & body() const
std::string convert_object_descriptor(const exprt &src, unsigned &precedence)
const codet & else_case() const
std::size_t long_double_width
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
std::string convert_sizeof(const exprt &src, unsigned &precedence)
virtual std::string convert_array_type(const typet &src, const qualifierst &qualifiers, const std::string &declarator_str)
To generate a C-like type declaration of an array.
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
std::size_t short_int_width
const bitnot_exprt & to_bitnot_expr(const exprt &expr)
Cast an exprt to a bitnot_exprt.
irep_idt id_shorthand(const irep_idt &identifier) const
const exprt & cond() const
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
const typet & return_type() const
const code_blockt & to_code_block(const codet &code)
static expr2c_configurationt clean_configuration
This prints compilable C that loses some of the internal details of the GOTO program.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
bool has_prefix(const std::string &s, const std::string &prefix)
irep_idt get_component_name() const
There are a large number of kinds of tree structured or tree-like data in CPROVER.
std::string convert_code_dead(const codet &src, unsigned indent)
bool include_array_size
When printing array_typet, should the size of the array be printed.
std::string type2c(const typet &type, const namespacet &ns, const expr2c_configurationt &configuration)
std::string convert_struct_member_value(const exprt &src, unsigned precedence)
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
#define forall_expr(it, expr)
virtual std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator)
std::string convert_index_designator(const exprt &src)
Used for configuring the behaviour of expr2c and type2c.
const irep_idt & get_flavor() const
Semantic type conversion.
std::string convert_code_switch(const codet &src, unsigned indent)
unsignedbv_typet size_type()
std::string convert_member(const member_exprt &src, unsigned precedence)
A codet representing an assignment in the program.
const irep_idt & get_statement() const
A constant literal expression.
std::string true_string
This is the string that will be printed for the true boolean expression.
virtual std::string convert_with_precedence(const exprt &src, unsigned &precedence)
virtual std::string as_string() const override
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
exprt & where()
convenience accessor for binding().where()
std::string convert_multi_ary(const exprt &src, const std::string &symbol, unsigned precedence, bool full_parentheses)
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
const irep_idt & get_value() const
const source_locationt & source_location() const
bool is_incomplete() const
A struct/union may be incomplete.
std::string convert_complex(const exprt &src, unsigned precedence)
std::string convert_code_output(const codet &src, unsigned indent)
const function_application_exprt & to_function_application_expr(const exprt &expr)
Cast an exprt to a function_application_exprt.
std::string convert_designated_initializer(const exprt &src)
std::string convert_vector(const exprt &src, unsigned &precedence)
std::string convert_binary(const binary_exprt &, const std::string &symbol, unsigned precedence, bool full_parentheses)
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
const shl_exprt & to_shl_expr(const exprt &expr)
Cast an exprt to a shl_exprt.
std::string false_string
This is the string that will be printed for the false boolean expression.
std::size_t long_int_width
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
const memberst & members() const
std::string convert_allocate(const exprt &src, unsigned &precedence)
std::string convert_code_return(const codet &src, unsigned indent)
Data structure for representing an arbitrary statement in a program.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const std::string integer2string(const mp_integer &n, unsigned base)