diff --git a/src/goto-programs/class_identifier.cpp b/src/goto-programs/class_identifier.cpp index bc4997df852..ace0626e317 100644 --- a/src/goto-programs/class_identifier.cpp +++ b/src/goto-programs/class_identifier.cpp @@ -30,7 +30,7 @@ static exprt build_class_identifier( const typet &type=ns.follow(e.type()); const struct_typet &struct_type=to_struct_type(type); const struct_typet::componentst &components=struct_type.components(); - assert(!components.empty()); + INVARIANT(!components.empty(), "class structs cannot be empty"); const auto &first_member_name=components.front().get_name(); member_exprt member_expr( @@ -61,10 +61,9 @@ exprt get_class_identifier_field( // Get a pointer from which we can extract a clsid. // If it's already a pointer to an object of some sort, just use it; // if it's void* then use the suggested type. + PRECONDITION(this_expr_in.type().id() == ID_pointer); exprt this_expr=this_expr_in; - assert(this_expr.type().id()==ID_pointer && - "Non-pointer this-arg in remove-virtuals?"); const auto &points_to=this_expr.type().subtype(); if(points_to==empty_typet()) this_expr=typecast_exprt(this_expr, pointer_type(suggested_type)); diff --git a/src/goto-programs/compute_called_functions.cpp b/src/goto-programs/compute_called_functions.cpp index 6592f603537..9c597760a43 100644 --- a/src/goto-programs/compute_called_functions.cpp +++ b/src/goto-programs/compute_called_functions.cpp @@ -21,14 +21,18 @@ void compute_address_taken_functions( forall_operands(it, src) compute_address_taken_functions(*it, address_taken); - if(src.id()==ID_address_of && - src.type().id()==ID_pointer && - src.type().subtype().id()==ID_code) + if(src.id() == ID_address_of) { - assert(src.operands().size()==1); - const exprt &op=src.op0(); - if(op.id()==ID_symbol) - address_taken.insert(to_symbol_expr(op).get_identifier()); + const address_of_exprt &address = to_address_of_expr(src); + + if( + address.type().id() == ID_pointer && + address.type().subtype().id() == ID_code) + { + const exprt &target = address.object(); + if(target.id() == ID_symbol) + address_taken.insert(to_symbol_expr(target).get_identifier()); + } } }