| Caolán McNamara | fe630f3 | 2012-04-04 10:24:36 +0100 | [diff] [blame] | 1 | unusedcode.easy is generated via callcatcher[1] and filtered to remove some |
| 2 | tricky edge-cases (see Makefile), e.g. anything which could plausibly be |
| 3 | dlsymed or any symbol defined in an external library bundled into LibreOffice |
| 4 | which doesn't happen to get used by LibreOffice. |
| 5 | |
| 6 | unusedcode.easy is generated on an x86_64 --enable-debug --enable-dbgutil |
| 7 | configuration. |
| 8 | |
| 9 | Code listed as unused is code that gcc outputs but that nothing calls |
| 10 | (or takes the address of). |
| 11 | |
| 12 | a) It's possible that some other platform or configuration uses the code, |
| 13 | so manual inspection is always required. |
| 14 | b) At the time of writing the majority of unused code now originates via |
| 15 | macros, mostly from pre-STL containers, see [2] for killing two birds |
| Caolán McNamara | 1d8cc54 | 2012-06-19 09:41:00 +0100 | [diff] [blame] | 16 | with one stone. These are typically methods of signatures... |
| 17 | *::Insert |
| 18 | *::Remove |
| 19 | *::DeleteAndDestroy |
| Caolán McNamara | 1d8cc54 | 2012-06-19 09:41:00 +0100 | [diff] [blame] | 20 | *::Replace |
| Caolán McNamara | fe630f3 | 2012-04-04 10:24:36 +0100 | [diff] [blame] | 21 | c) callcatcher ignores virtuals. But implementations of "pure virtuals" |
| 22 | are not actually virtual methods. If something is declared pure virtual |
| 23 | and provides an impl and that base-class impl is not explicitly called |
| 24 | anywhere, then that impl can go away. |
| 25 | d) gcc will only emit code for inlines if those inlines are used, so |
| 26 | sometimes something is listed correctly as unused but some inline |
| 27 | code takes a pointer or reference to something which cannot be |
| 28 | instantiated so removal of some method/class fails at build time because |
| 29 | gcc never emits any code for the the unused inline but trips over it at |
| 30 | compile time after an attempt at removal. i.e. generally the inline method |
| 31 | can go as well because nothing calls it either, a double win. |
| 32 | e) if a constructor is listed as unused, and it's the *only* ctor in the class, |
| Julien Nabet | 7b84d0f | 2012-05-02 11:07:29 +0200 | [diff] [blame] | 33 | then no object of that class can be constructed, so the whole thing is |
| Caolán McNamara | fe630f3 | 2012-04-04 10:24:36 +0100 | [diff] [blame] | 34 | unused, which can lead to a whole cascade of tricky but logical fallout. |
| Caolán McNamara | dd20a8c | 2012-04-04 11:53:34 +0100 | [diff] [blame] | 35 | f) if a destructor is listed as unused, and a constructor isn't, then there's |
| 36 | a leak somewhere, and the destructor most likely *should* be called. |
| 37 | g) there's more actually unused code then what's listed. The idea is that what's |
| Caolán McNamara | fe630f3 | 2012-04-04 10:24:36 +0100 | [diff] [blame] | 38 | listed is definitely unused under the generation configuration, not that |
| 39 | it's a list of all unused code. If the count of unused easy hits 0 then |
| 40 | we can have a look at the non-easy and if that hits 0, then strip out |
| 41 | code from the "release" binaries which only makes sense in debug/dbgutil |
| 42 | configurations, and then tackle unused virtual method slots :-) |
| 43 | |
| 44 | [1] http://www.skynet.ie/~caolan/Packages/callcatcher.html |
| 45 | [2] https://bugs.freedesktop.org/show_bug.cgi?id=38832 |