unusedcode some step further

Lubos Lunak l.lunak at suse.cz
Mon Apr 22 09:03:01 PDT 2013


On Tuesday 02 of April 2013, Michael Meeks wrote:
> On Mon, 2013-04-01 at 16:04 +0200, Noel Grandin wrote:
> > 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.
>
> 	Completely agreed; I imagine it would be necessary to write some
> intermediate format out from each clang compile - and then crunch those
> together afterwards to see what was actually used.
>
> 	Hopefully - given the level of context that clang has - it'd be
> reasonably easy to identify and elide virtual methods even DLLPUBLIC
> ones - though we would presumably want to white-list any UNO interfaces'
> virtual methods - which may well never be called; yet can't be removed.
>
> 	The compilerplugins/ directory has some nice README about plugins and
> all the good things they can do :-) Potentially with a double pass
> through the code - clang could auto-generate diffs of things o
> remove ;->

 If somebody wants to play with this, there is a base for such a compiler 
check in compilerplugins/clang/store/unusedcode.cxx . It only checks whether 
all functions encountered are used or not (and it should handle both inline 
and virtuals correctly). It doesn't do anything more with it, but there are 
comments about what should be done with the data, which I expect should be 
fairly easy to do and just needs somebody to do it. It it to be used like 
other rewriters (see the README), expect it won't rewrite anything and only 
generate the data.

 There's no white-listing either, but that shouldn't be difficult, and the 
code could be similarly extended to also check for unused structs/classes, 
enums, etc.

-- 
 Lubos Lunak
 l.lunak at suse.cz


More information about the LibreOffice mailing list