File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -187,10 +187,11 @@ void remove_virtual_functionst::remove_virtual_function(
187
187
// Cast the `this` pointer to the correct type for the new callee:
188
188
const auto &callee_type=
189
189
to_code_type (ns.lookup (fun.symbol_expr .get_identifier ()).type );
190
+ const code_typet::parametert *this_param = callee_type.get_this ();
190
191
INVARIANT (
191
- callee_type. has_this () ,
192
+ this_param != nullptr ,
192
193
" Virtual function callees must have a `this` argument" );
193
- typet need_type=callee_type. parameters ()[ 0 ]. type ();
194
+ typet need_type=this_param-> type ();
194
195
if (!type_eq (newcall.arguments ()[0 ].type (), need_type, ns))
195
196
newcall.arguments ()[0 ].make_typecast (need_type);
196
197
}
Original file line number Diff line number Diff line change @@ -817,9 +817,17 @@ class code_typet:public typet
817
817
}
818
818
819
819
bool has_this () const
820
+ {
821
+ return get_this () != nullptr ;
822
+ }
823
+
824
+ const parametert *get_this () const
820
825
{
821
826
const parameterst &p=parameters ();
822
- return !p.empty () && p.front ().get_this ();
827
+ if (!p.empty () && p.front ().get_this ())
828
+ return &p.front ();
829
+ else
830
+ return nullptr ;
823
831
}
824
832
825
833
bool is_KnR () const
You can’t perform that action at this time.
0 commit comments