Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

there are several unused methods in the source which callcatcher doesn't catch. Two examples: 08b91c63131b7e625d2a2c489bc537dafe5c5963 and c12ab867f282e783507fcf74ab5c90e784681f65 which had only (virtual) definitions, but no calls.

The same applies to inlines like 646daee253b69404591c006ec6e717b6660af30b. 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/

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.