File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 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(
187187 // Cast the `this` pointer to the correct type for the new callee:
188188 const auto &callee_type=
189189 to_code_type (ns.lookup (fun.symbol_expr .get_identifier ()).type );
190+ const code_typet::parametert *this_param = callee_type.get_this ();
190191 INVARIANT (
191- callee_type. has_this () ,
192+ this_param != nullptr ,
192193 " Virtual function callees must have a `this` argument" );
193- typet need_type=callee_type. parameters ()[ 0 ]. type ();
194+ typet need_type=this_param-> type ();
194195 if (!type_eq (newcall.arguments ()[0 ].type (), need_type, ns))
195196 newcall.arguments ()[0 ].make_typecast (need_type);
196197 }
Original file line number Diff line number Diff line change @@ -817,9 +817,17 @@ class code_typet:public typet
817817 }
818818
819819 bool has_this () const
820+ {
821+ return get_this () != nullptr ;
822+ }
823+
824+ const parametert *get_this () const
820825 {
821826 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 ;
823831 }
824832
825833 bool is_KnR () const
You can’t perform that action at this time.
0 commit comments