unusedcode some step further

Noel Grandin noelgrandin at gmail.com
Mon Apr 1 07:04:31 PDT 2013


Another way is to use a clang plugin to generate a more accurate list of
definitions and call sites.
That's what I would do, because clang would handle all of the macro and
language parsing.

On Monday, 1 April 2013, Thomas Arnhold wrote:

> Hi,
>
> there are several unused methods in the source which callcatcher doesn't
> catch. Two examples: 08b91c63131b7e625d2a2c489bc537**dafe5c5963 and
> c12ab867f282e783507fcf74ab5c90**e784681f65 which had only (virtual)
> definitions, but no calls.
>
> The same applies to inlines like 646daee253b69404591c006ec6e717**b6660af30b.
> Defined, but no calls.
>
> So the idea is to get something like a list of all methods in the project.
> First counting (virtual) definitions and second counting all calls.
>
> Counting the calls is not as easy as it seems. So I had the idea to
> preprocess the source files with -fpreprocessed -dD -E to get source files
> without comments and much other cruft removed (which may lead to
> false-positives). Counting in those files seems easier. So it would be 1st
> count definitions, 2nd count all occurrences. If they are equal there are
> no calls.
>
> This would be a way to find possible candidates for removal (excluding
> DLLPUBLIC stuff). Pros: platform independent. Cons: No macro expansion, if
> there are several independent methods which have the same name, but one is
> unused it's not possible to identify the unused one. So it will only
> identify a fraction of all unused stuff. The question is how big is this
> fraction ;)
>
> So my question: Is it worth doing this (because it's not the cleanest
> way)? Or did I miss something, especially the point "no calls, no users"?
>
>
> Another possible way: gcc with -fdata-sections and -ffunction-sections
> [1]. Where both results could be compared and unused methods could be
> identified. But I didn't try that. Did anyone do such thing?
>
> Thomas
>
>
> [1] http://embeddedfreak.**wordpress.com/2009/02/10/**
> removing-unused-functionsdead-**codes-with-gccgnu-ld/<http://embeddedfreak.wordpress.com/2009/02/10/removing-unused-functionsdead-codes-with-gccgnu-ld/>
> ______________________________**_________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/**mailman/listinfo/libreoffice<http://lists.freedesktop.org/mailman/listinfo/libreoffice>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20130401/30664631/attachment-0001.html>


More information about the LibreOffice mailing list