[fpc-pascal] Remove unused functions in a class

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Apr 5 17:27:02 CEST 2009


On 05 Apr 2009, at 17:12, JoshyFun wrote:

> TCustomFoo=class(TObject);
> TDerivedFoo=class(TCustomFoo)
> procedure Myprocedure(); virtual;
> end;
> TDeDerivedFoo=class(TDerivedFoo)
> procedure MyProcedure(); override;
> end;
>
> And in the code:
>
> var
>  MyObj: TCustomFoo;
> begin
>  MyObj:=TDeDerivedFoo.Create();
>  TDerivedFoo(MyObj).Myprocedure();
> end;
>
> Something like this could kill the dead code detection ? A simple
> yes/no is enoght :)

Not in case of whole-program optimization:

--- dead.sorg   2009-04-05 17:24:25.000000000 +0200
+++ dead.s      2009-04-05 17:24:32.000000000 +0200
@@ -91,10 +91,7 @@
  # [29] TDerivedFoo(MyObj).Myprocedure();
         movl    L_U_P$PROGRAM_MYOBJ$non_lazy_ptr-Lj2(%ebx),%eax
         movl    (%eax),%eax
-       movl    L_U_P$PROGRAM_MYOBJ$non_lazy_ptr-Lj2(%ebx),%edx
-       movl    (%edx),%edx
-       movl    (%edx),%edx
-       call    *80(%edx)
+       call    L_P$PROGRAM_TDEDERIVEDFOO_$__MYPROCEDURE$stub

I'm not sure about -dvtentry.


Jonas



More information about the fpc-pascal mailing list