@@ -706,7 +706,7 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr)
706
706
code_typet &code_type=to_code_type (op.type ().subtype ());
707
707
708
708
code_typet::parameterst &args=code_type.parameters ();
709
- if (args.size () > 0 && args[0 ].get (ID_C_base_name)== ID_this)
709
+ if (! args.empty () && args[0 ].get_base_name () == ID_this)
710
710
{
711
711
// it's a pointer to member function
712
712
const struct_tag_typet symbol (code_type.get (ID_C_member_name));
@@ -2192,21 +2192,23 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
2192
2192
// we are willing to add an "address_of"
2193
2193
// for the sake of operator overloading
2194
2194
2195
- const irept::subt &arguments =
2196
- expr.function ().type (). find (ID_arguments). get_sub ();
2195
+ const code_typet::parameterst ¶meters =
2196
+ to_code_type ( expr.function ().type ()). parameters ();
2197
2197
2198
- if (arguments. size ()>= 1 &&
2199
- arguments .front ().get (ID_C_base_name)== ID_this &&
2200
- expr.arguments ().size ()>= 1 )
2198
+ if (
2199
+ !parameters. empty () && parameters .front ().get_base_name () == ID_this &&
2200
+ ! expr.arguments ().empty () )
2201
2201
{
2202
- const exprt &argument=
2203
- static_cast <const exprt &>(arguments.front ());
2202
+ const code_typet::parametert ¶meter = parameters.front ();
2204
2203
2205
- exprt &operand=expr.op1 ();
2206
- assert (argument.type ().id ()==ID_pointer);
2204
+ exprt &operand = expr.arguments ().front ();
2205
+ INVARIANT (
2206
+ parameter.type ().id () == ID_pointer,
2207
+ " `this' parameter should be a pointer" );
2207
2208
2208
- if (operand.type ().id ()!=ID_pointer &&
2209
- operand.type ()==argument.type ().subtype ())
2209
+ if (
2210
+ operand.type ().id () != ID_pointer &&
2211
+ operand.type () == parameter.type ().subtype ())
2210
2212
{
2211
2213
address_of_exprt tmp (operand, pointer_type (operand.type ()));
2212
2214
tmp.add_source_location ()=operand.source_location ();
0 commit comments