diff --git a/src/ansi-c/c_typecheck_expr.cpp b/src/ansi-c/c_typecheck_expr.cpp index b21c7792a82..b78050306e6 100644 --- a/src/ansi-c/c_typecheck_expr.cpp +++ b/src/ansi-c/c_typecheck_expr.cpp @@ -836,7 +836,7 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr) if(expr.type().id()==ID_code) // function designator { // special case: this is sugar for &f address_of_exprt tmp(expr, pointer_type(expr.type())); - tmp.set("#implicit", true); + tmp.set(ID_C_implicit, true); tmp.add_source_location()=expr.source_location(); expr=tmp; } diff --git a/src/cpp/cpp_constructor.cpp b/src/cpp/cpp_constructor.cpp index 419b5d1a382..dd69741ff12 100644 --- a/src/cpp/cpp_constructor.cpp +++ b/src/cpp/cpp_constructor.cpp @@ -46,7 +46,7 @@ codet cpp_typecheckt::cpp_constructor( // The purpose of the tag #array_ini is to rule out ill-formed // programs. - if(!operands.empty() && !operands.front().get_bool("#array_ini")) + if(!operands.empty() && !operands.front().get_bool(ID_C_array_ini)) { error().source_location=source_location; error() << "bad array initializer" << eom; @@ -65,7 +65,7 @@ codet cpp_typecheckt::cpp_constructor( const exprt &size_expr= to_array_type(tmp_type).size(); - if(size_expr.id()=="infinity") + if(size_expr.id() == ID_infinity) { // don't initialize codet nil; @@ -91,8 +91,8 @@ codet cpp_typecheckt::cpp_constructor( exprt op_tc=operands.front(); typecheck_expr(op_tc); // Override constantness - object_tc.type().set("#constant", false); - object_tc.set("#lvalue", true); + object_tc.type().set("ID_C_constant", false); + object_tc.set("ID_C_lvalue", true); side_effect_exprt assign("assign"); assign.add_source_location()=source_location; assign.copy_to_operands(object_tc, op_tc); diff --git a/src/cpp/cpp_declarator_converter.cpp b/src/cpp/cpp_declarator_converter.cpp index df74fa22206..880d05fe2ef 100644 --- a/src/cpp/cpp_declarator_converter.cpp +++ b/src/cpp/cpp_declarator_converter.cpp @@ -200,7 +200,7 @@ symbolt &cpp_declarator_convertert::convert( if(!storage_spec.is_extern()) symbol.is_extern = false; - if(declarator.get_bool("#template_case")) + if(declarator.get_bool(ID_C_template_case)) return symbol; combine_types(declarator.name().source_location(), final_type, symbol); @@ -258,7 +258,7 @@ void cpp_declarator_convertert::combine_types( if(decl_parameter.type()!=symbol_parameter.type()) { // The 'this' parameter of virtual functions mismatches - if(i!=0 || !symbol_code_type.get_bool("#is_virtual")) + if(i != 0 || !symbol_code_type.get_bool(ID_C_is_virtual)) { cpp_typecheck.error().source_location=source_location; cpp_typecheck.error() << "symbol `" << symbol.display_name() diff --git a/src/cpp/cpp_typecheck_code.cpp b/src/cpp/cpp_typecheck_code.cpp index 866a7fbd14a..634e4c76b97 100644 --- a/src/cpp/cpp_typecheck_code.cpp +++ b/src/cpp/cpp_typecheck_code.cpp @@ -178,10 +178,10 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) // Let's first typecheck the operands. Forall_operands(it, code) { - const bool has_array_ini = it->get_bool("#array_ini"); + const bool has_array_ini = it->get_bool(ID_C_array_ini); typecheck_expr(*it); if(has_array_ini) - it->set("#array_ini", true); + it->set(ID_C_array_ini, true); } // The initializer may be a data member (non-type) @@ -228,7 +228,7 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) // done building the expression, check the argument types typecheck_function_call_arguments(function_call); - if(symbol_expr.get_bool("#not_accessible")) + if(symbol_expr.get_bool(ID_C_not_accessible)) { irep_idt access = symbol_expr.get(ID_C_access); @@ -312,9 +312,9 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) reference_initializer(code.op0(), symbol_expr.type()); // assign the pointers - symbol_expr.type().remove("#reference"); - symbol_expr.set("#lvalue", true); - code.op0().type().remove("#reference"); + symbol_expr.type().remove(ID_C_reference); + symbol_expr.set(ID_C_lvalue, true); + code.op0().type().remove(ID_C_reference); side_effect_exprt assign(ID_assign); assign.add_source_location() = code.source_location(); diff --git a/src/cpp/cpp_typecheck_compound_type.cpp b/src/cpp/cpp_typecheck_compound_type.cpp index e59a8b9421c..f89ca87cc55 100644 --- a/src/cpp/cpp_typecheck_compound_type.cpp +++ b/src/cpp/cpp_typecheck_compound_type.cpp @@ -426,7 +426,7 @@ void cpp_typecheckt::typecheck_compound_declarator( if(cpp_name.is_operator()) { component.set("is_operator", true); - component.type().set("#is_operator", true); + component.type().set(ID_C_is_operator, true); } if(is_cast_operator) @@ -442,7 +442,7 @@ void cpp_typecheckt::typecheck_compound_declarator( if(is_static) { component.set(ID_is_static, true); - component.type().set("#is_static", true); + component.type().set(ID_C_is_static, true); } if(is_typedef) @@ -517,7 +517,7 @@ void cpp_typecheckt::typecheck_compound_declarator( else // virtual { component.type().set(ID_C_is_virtual, true); - component.type().set("#virtual_name", virtual_name); + component.type().set(ID_C_virtual_name, virtual_name); // Check if it is a pure virtual method if(value.is_not_nil() && value.id() == ID_constant) @@ -888,9 +888,9 @@ void cpp_typecheckt::typecheck_friend_declaration( // typecheck ftype // TODO -// typecheck_type(ftype); -// assert(ftype.id()==ID_symbol); -// symbol.type.add("#friends").move_to_sub(ftype); + // typecheck_type(ftype); + // assert(ftype.id()==ID_symbol); + // symbol.type.add("ID_C_friends").move_to_sub(ftype); return; } @@ -914,7 +914,7 @@ void cpp_typecheckt::typecheck_friend_declaration( declaration.type(), declaration.storage_spec(), declaration.member_spec(), sub_it); exprt symb_expr=cpp_symbol_expr(conv_symb); - symbol.type.add("#friends").move_to_sub(symb_expr); + symbol.type.add(ID_C_friends).move_to_sub(symb_expr); } else { @@ -929,7 +929,7 @@ void cpp_typecheckt::typecheck_friend_declaration( exprt symb_expr=cpp_symbol_expr(conv_symb); - symbol.type.add("#friends").move_to_sub(symb_expr); + symbol.type.add(ID_C_friends).move_to_sub(symb_expr); } } } @@ -1462,7 +1462,7 @@ void cpp_typecheckt::convert_anon_struct_union_member( put_compound_into_scope(component); - struct_union_symbol.type.set("#unnamed_object", base_name); + struct_union_symbol.type.set(ID_C_unnamed_object, base_name); } bool cpp_typecheckt::get_component( @@ -1496,7 +1496,7 @@ bool cpp_typecheckt::get_component( { if(disable_access_control) { - member.set("#not_accessible", true); + member.set(ID_C_not_accessible, true); member.set(ID_C_access, component.get(ID_access)); } else @@ -1520,8 +1520,7 @@ bool cpp_typecheckt::get_component( return true; // component found } - else if( - follow(component.type()).find("#unnamed_object").is_not_nil()) + else if(follow(component.type()).find(ID_C_unnamed_object).is_not_nil()) { // could be anonymous union or struct @@ -1597,8 +1596,7 @@ bool cpp_typecheckt::check_component_access( } // check friendship - const irept::subt &friends= - struct_union_type.find("#friends").get_sub(); + const irept::subt &friends = struct_union_type.find(ID_C_friends).get_sub(); forall_irep(f_it, friends) { diff --git a/src/cpp/cpp_typecheck_constructor.cpp b/src/cpp/cpp_typecheck_constructor.cpp index a101618da61..b89b7460a39 100644 --- a/src/cpp/cpp_typecheck_constructor.cpp +++ b/src/cpp/cpp_typecheck_constructor.cpp @@ -344,7 +344,7 @@ void cpp_typecheckt::default_cpctor( memberexpr.add_source_location()=source_location; if(mem_it->type().id()==ID_array) - memberexpr.set("#array_ini", true); + memberexpr.set(ID_C_array_ini, true); mem_init.move_to_operands(memberexpr); initializers.move_to_sub(mem_init); @@ -386,7 +386,7 @@ void cpp_typecheckt::default_assignop( declarator_type.id(ID_function_type); declarator_type.subtype()=reference_type(nil_typet()); - declarator_type.subtype().add("#qualifier").make_nil(); + declarator_type.subtype().add(ID_C_qualifier).make_nil(); exprt &args=static_cast(declarator.type().add(ID_parameters)); args.add_source_location()=source_location; diff --git a/src/cpp/cpp_typecheck_conversions.cpp b/src/cpp/cpp_typecheck_conversions.cpp index e665265dce3..3ae9219fde7 100644 --- a/src/cpp/cpp_typecheck_conversions.cpp +++ b/src/cpp/cpp_typecheck_conversions.cpp @@ -1258,9 +1258,9 @@ bool cpp_typecheckt::reference_binding( expr.set(ID_C_lvalue, true); else if(expr.get(ID_statement)==ID_function_call) expr.set(ID_C_lvalue, true); - else if(expr.get_bool("#temporary_avoided")) + else if(expr.get_bool(ID_C_temporary_avoided)) { - expr.remove("#temporary_avoided"); + expr.remove(ID_C_temporary_avoided); exprt temporary; new_temporary(expr.source_location(), expr.type(), expr, temporary); expr.swap(temporary); @@ -1965,7 +1965,7 @@ bool cpp_typecheckt::static_typecast( else { // try to avoid temporary - new_expr.set("#temporary_avoided", true); + new_expr.set(ID_C_temporary_avoided, true); if(new_expr.get_bool(ID_C_lvalue)) new_expr.remove(ID_C_lvalue); } diff --git a/src/cpp/cpp_typecheck_declaration.cpp b/src/cpp/cpp_typecheck_declaration.cpp index f6033d91f63..9c6fc9b9e9f 100644 --- a/src/cpp/cpp_typecheck_declaration.cpp +++ b/src/cpp/cpp_typecheck_declaration.cpp @@ -98,8 +98,8 @@ void cpp_typecheckt::convert_anonymous_union( id.is_member=true; } - symbol_table.get_writeable_ref(union_symbol.name).type.set( - "#unnamed_object", symbol.base_name); + symbol_table.get_writeable_ref(union_symbol.name) + .type.set(ID_C_unnamed_object, symbol.base_name); code.swap(new_code); } diff --git a/src/cpp/cpp_typecheck_expr.cpp b/src/cpp/cpp_typecheck_expr.cpp index 9153c0fd4c0..33378fb3429 100644 --- a/src/cpp/cpp_typecheck_expr.cpp +++ b/src/cpp/cpp_typecheck_expr.cpp @@ -2017,8 +2017,8 @@ void cpp_typecheckt::typecheck_side_effect_function_call( { if(expr.function().type().find("to-member").is_not_nil()) { - const exprt &bound= - static_cast(expr.function().type().find("#bound")); + const exprt &bound = + static_cast(expr.function().type().find(ID_C_bound)); if(bound.is_nil()) { @@ -2032,7 +2032,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call( expr.arguments().insert(expr.arguments().begin(), bound); // we don't need the object any more - expr.function().type().remove("#bound"); + expr.function().type().remove(ID_C_bound); } // do implicit dereference @@ -2060,8 +2060,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call( } else if(expr.function().type().id()==ID_code) { - if(expr.function().type().get_bool("#is_virtual") && - !is_qualified) + if(expr.function().type().get_bool(ID_C_is_virtual) && !is_qualified) { exprt vtptr_member; if(op0.id()==ID_member || op0.id()==ID_ptrmember) @@ -2093,9 +2092,9 @@ void cpp_typecheckt::typecheck_side_effect_function_call( vtptr_member.set(ID_component_name, vtable_name); // look for the right entry - irep_idt vtentry_component_name= - vt_compo.type().subtype().get_string(ID_identifier)+"::"+ - expr.function().type().get_string("#virtual_name"); + irep_idt vtentry_component_name = + vt_compo.type().subtype().get_string(ID_identifier) + + "::" + expr.function().type().get_string(ID_C_virtual_name); exprt vtentry_member(ID_ptrmember); vtentry_member.copy_to_operands(vtptr_member); @@ -2190,10 +2189,10 @@ void cpp_typecheckt::typecheck_side_effect_function_call( member); // special case for the initialization of parents - if(member.get_bool("#not_accessible")) + if(member.get_bool(ID_C_not_accessible)) { assert(member.get(ID_C_access)!=""); - tmp_object_expr.set("#not_accessible", true); + tmp_object_expr.set(ID_C_not_accessible, true); tmp_object_expr.set(ID_C_access, member.get(ID_C_access)); } @@ -2307,7 +2306,7 @@ void cpp_typecheckt::typecheck_function_call_arguments( exprt::operandst::iterator arg_it=expr.arguments().begin(); for(const auto ¶meter : parameters) { - if(parameter.get_bool("#call_by_value")) + if(parameter.get_bool(ID_C_call_by_value)) { assert(is_reference(parameter.type())); @@ -2383,7 +2382,7 @@ void cpp_typecheckt::typecheck_method_application( const symbolt &symbol=lookup(member_expr.get(ID_component_name)); symbolt &method_symbol=symbol_table.get_writeable_ref(symbol.name); - const symbolt &tag_symbol=lookup(symbol.type.get("#member_name")); + const symbolt &tag_symbol = lookup(symbol.type.get(ID_C_member_name)); // build the right template map // if this is an instantiated template class method @@ -2409,7 +2408,7 @@ void cpp_typecheckt::typecheck_method_application( new_function.add_source_location()=member_expr.source_location(); expr.function().swap(new_function); - if(!expr.function().type().get_bool("#is_static")) + if(!expr.function().type().get_bool(ID_C_is_static)) { const code_typet &func_type=to_code_type(symbol.type); typet this_type=func_type.parameters().front().type(); @@ -2417,7 +2416,7 @@ void cpp_typecheckt::typecheck_method_application( // Special case. Make it a reference. assert(this_type.id()==ID_pointer); this_type.set(ID_C_reference, true); - this_type.set("#this", true); + this_type.set(ID_C_this, true); if(expr.arguments().size()==func_type.parameters().size()) { @@ -2690,7 +2689,7 @@ void cpp_typecheckt::convert_pmop(exprt &expr) } exprt tmp(expr.op1()); - tmp.type().set("#bound", expr.op0()); + tmp.type().set(ID_C_bound, expr.op0()); expr.swap(tmp); return; } @@ -2714,8 +2713,7 @@ void cpp_typecheckt::typecheck_expr_function_identifier(exprt &expr) void cpp_typecheckt::typecheck_expr(exprt &expr) { - bool override_constantness= - expr.get_bool("#override_constantness"); + bool override_constantness = expr.get_bool(ID_C_override_constantness); // We take care of an ambiguity in the C++ grammar. // Needs to be done before the operands! diff --git a/src/cpp/cpp_typecheck_fargs.cpp b/src/cpp/cpp_typecheck_fargs.cpp index 623f786b1c7..b4ca6915ab0 100644 --- a/src/cpp/cpp_typecheck_fargs.cpp +++ b/src/cpp/cpp_typecheck_fargs.cpp @@ -107,7 +107,7 @@ bool cpp_typecheck_fargst::match( if(it==ops.begin() && parameter.get(ID_C_base_name)==ID_this) { type.set(ID_C_reference, true); - type.set("#this", true); + type.set(ID_C_this, true); } unsigned rank=0; diff --git a/src/cpp/cpp_typecheck_resolve.cpp b/src/cpp/cpp_typecheck_resolve.cpp index 0eba1d0765d..484fc458712 100644 --- a/src/cpp/cpp_typecheck_resolve.cpp +++ b/src/cpp/cpp_typecheck_resolve.cpp @@ -1697,7 +1697,7 @@ exprt cpp_typecheck_resolvet::resolve( } // we do some checks before we return - if(result.get_bool("#not_accessible")) + if(result.get_bool(ID_C_not_accessible)) { #if 0 if(!fail_with_exception) @@ -2223,8 +2223,9 @@ bool cpp_typecheck_resolvet::disambiguate_functions( } else { - if(expr.type().get_bool("#is_operator") && - fargs.operands.size() == parameters.size()) + if( + expr.type().get_bool(ID_C_is_operator) && + fargs.operands.size() == parameters.size()) { return fargs.match(type, args_distance, cpp_typecheck); } diff --git a/src/goto-programs/builtin_functions.cpp b/src/goto-programs/builtin_functions.cpp index 4960c54602f..0d5284d6cf6 100644 --- a/src/goto-programs/builtin_functions.cpp +++ b/src/goto-programs/builtin_functions.cpp @@ -654,7 +654,7 @@ void goto_convertt::do_function_call_symbol( const exprt::operandst &arguments, goto_programt &dest) { - if(function.get_bool("#invalid_object")) + if(function.get_bool(ID_C_invalid_object)) return; // ignore // lookup symbol diff --git a/src/goto-symex/build_goto_trace.cpp b/src/goto-symex/build_goto_trace.cpp index 648583605af..86e22818fa6 100644 --- a/src/goto-symex/build_goto_trace.cpp +++ b/src/goto-symex/build_goto_trace.cpp @@ -114,7 +114,7 @@ void set_internal_dynamic_object( const symbolt *symbol; if(!ns.lookup(id, symbol)) { - bool result=symbol->type.get_bool("#dynamic"); + bool result = symbol->type.get_bool(ID_C_dynamic); if(result) goto_trace_step.internal=true; } diff --git a/src/goto-symex/symex_builtin_functions.cpp b/src/goto-symex/symex_builtin_functions.cpp index 7b4be956854..34a26fa1846 100644 --- a/src/goto-symex/symex_builtin_functions.cpp +++ b/src/goto-symex/symex_builtin_functions.cpp @@ -153,7 +153,7 @@ void goto_symext::symex_allocate( value_symbol.name="symex_dynamic::"+id2string(value_symbol.base_name); value_symbol.is_lvalue=true; value_symbol.type=object_type; - value_symbol.type.set("#dynamic", true); + value_symbol.type.set(ID_C_dynamic, true); value_symbol.mode = mode; state.symbol_table.add(value_symbol); @@ -432,7 +432,7 @@ void goto_symext::symex_cpp_new( else symbol.type=code.type().subtype(); - symbol.type.set("#dynamic", true); + symbol.type.set(ID_C_dynamic, true); state.symbol_table.add(symbol); diff --git a/src/goto-symex/symex_dereference_state.cpp b/src/goto-symex/symex_dereference_state.cpp index d0e00b0ce7d..f1d43c7713c 100644 --- a/src/goto-symex/symex_dereference_state.cpp +++ b/src/goto-symex/symex_dereference_state.cpp @@ -36,8 +36,7 @@ bool symex_dereference_statet::has_failed_symbol( const symbolt &ptr_symbol= ns.lookup(to_ssa_expr(expr).get_object_name()); - const irep_idt &failed_symbol= - ptr_symbol.type.get("#failed_symbol"); + const irep_idt &failed_symbol = ptr_symbol.type.get(ID_C_failed_symbol); if(failed_symbol!="" && !ns.lookup(failed_symbol, symbol)) @@ -57,8 +56,7 @@ bool symex_dereference_statet::has_failed_symbol( const symbolt &ptr_symbol= ns.lookup(to_symbol_expr(expr).get_identifier()); - const irep_idt &failed_symbol= - ptr_symbol.type.get("#failed_symbol"); + const irep_idt &failed_symbol = ptr_symbol.type.get(ID_C_failed_symbol); if(failed_symbol!="" && !ns.lookup(failed_symbol, symbol)) diff --git a/src/pointer-analysis/goto_program_dereference.cpp b/src/pointer-analysis/goto_program_dereference.cpp index f8a395f5246..476f2168e94 100644 --- a/src/pointer-analysis/goto_program_dereference.cpp +++ b/src/pointer-analysis/goto_program_dereference.cpp @@ -25,13 +25,12 @@ bool goto_program_dereferencet::has_failed_symbol( { if(expr.id()==ID_symbol) { - if(expr.get_bool("#invalid_object")) + if(expr.get_bool(ID_C_invalid_object)) return false; const symbolt &ptr_symbol = ns.lookup(to_symbol_expr(expr)); - const irep_idt &failed_symbol= - ptr_symbol.type.get("#failed_symbol"); + const irep_idt &failed_symbol = ptr_symbol.type.get(ID_C_failed_symbol); if(failed_symbol.empty()) return false; diff --git a/src/solvers/flattening/pointer_logic.cpp b/src/solvers/flattening/pointer_logic.cpp index d0a2a866903..ffc2eae4755 100644 --- a/src/solvers/flattening/pointer_logic.cpp +++ b/src/solvers/flattening/pointer_logic.cpp @@ -22,7 +22,7 @@ Author: Daniel Kroening, kroening@kroening.com bool pointer_logict::is_dynamic_object(const exprt &expr) const { - if(expr.type().get_bool("#dynamic")) + if(expr.type().get_bool(ID_C_dynamic)) return true; if(expr.id()==ID_symbol) diff --git a/src/util/irep_ids.def b/src/util/irep_ids.def index 43a74e9e8c2..57f5751eb38 100644 --- a/src/util/irep_ids.def +++ b/src/util/irep_ids.def @@ -417,6 +417,7 @@ IREP_ID_ONE(template_parameter) IREP_ID_ONE(template_parameters) IREP_ID_TWO(C_template, #template) IREP_ID_TWO(C_template_arguments, #template_arguments) +IREP_ID_TWO(C_template_case, #template_case) IREP_ID_ONE(typename) IREP_ID_ONE(C) IREP_ID_ONE(cpp) @@ -447,6 +448,7 @@ IREP_ID_TWO(overflow_mult, overflow-*) IREP_ID_TWO(overflow_unary_minus, overflow-unary-) IREP_ID_ONE(object_descriptor) IREP_ID_ONE(dynamic_object) +IREP_ID_TWO(C_dynamic, #dynamic) IREP_ID_ONE(object_size) IREP_ID_ONE(good_pointer) IREP_ID_ONE(integer_address) @@ -458,6 +460,7 @@ IREP_ID_TWO(C_is_failed_symbol, #is_failed_symbol) IREP_ID_TWO(C_failed_symbol, #failed_symbol) IREP_ID_ONE(set) IREP_ID_ONE(friend) +IREP_ID_TWO(C_friends, #friends) IREP_ID_ONE(explicit) IREP_ID_ONE(storage_spec) IREP_ID_ONE(member_spec) @@ -677,6 +680,17 @@ IREP_ID_ONE(is_inner_class) IREP_ID_ONE(is_anonymous) IREP_ID_ONE(outer_class) IREP_ID_ONE(is_bridge_method) +IREP_ID_TWO(C_is_operator, #is_operator) +IREP_ID_TWO(C_not_accessible, #not_accessible) +IREP_ID_TWO(C_override_constantness, #override_constantness) +IREP_ID_TWO(C_bound, #bound) +IREP_ID_TWO(C_is_static, #is_static) +IREP_ID_TWO(C_call_by_value, #call_by_value) +IREP_ID_TWO(C_virtual_name, #virtual_name) +IREP_ID_TWO(C_unnamed_object, #unnamed_object) +IREP_ID_TWO(C_temporary_avoided, #temporary_avoided) +IREP_ID_TWO(C_qualifier, #qualifier) +IREP_ID_TWO(C_array_ini, #array_ini) // Projects depending on this code base that wish to extend the list of // available ids should provide a file local_irep_ids.h in their source tree and