zcourts / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

Do no include "detail" headers #70

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Boost often separates out implementation details into a "detail" folder, e.g. 
<boost/thread/detail/thread.hpp>. It would be nice if iwyu did not suggest 
these detail headers.

Original issue reported on code.google.com by leszek.s...@gmail.com on 18 Jun 2012 at 11:47

GoogleCodeExporter commented 9 years ago
+1. I have up on IWYU after manually fixing hundreds of instances of boost 
private header include replacements that ultimately didn't compile, and having 
no proper way to exclude the inclusion/inlining of certain headers via regex 
(*\/private\/*, *\/detail\/*). It would be even nicer if IWYU had these 
exclusions by default, in addition to being able to specify a list.

Original comment by plaztiks...@gmail.com on 16 Jul 2012 at 8:49

GoogleCodeExporter commented 9 years ago
I agree with the sentiment, but there's a wrinkle: it's not as simple as 
excluding "private" or "detail" -- IWYU needs to know where to look instead.

The only current mechanism for this is IWYU pragmas 
(http://code.google.com/p/include-what-you-use/wiki/IWYUPragmas), but that 
requires changes to the headers in question, which is rarely workable.

I have a plan for external mapping of (symbol -> public include) and (private 
include -> public include) but it's not done yet. Once the mechanism is in 
place, a lot of work remains to set up the mappings for Boost, though some of 
it can probably be automated.

Original comment by kim.gras...@gmail.com on 16 Sep 2012 at 4:12

GoogleCodeExporter commented 9 years ago
For what it's worth, external mapping is now implemented. leszek.swirski or 
plaztiksyke, you should be able to create one or more mapping files for Boost 
to run alongside the IWYU default. Please ping back if something can't be 
solved with this infrastructure.

Original comment by kim.gras...@gmail.com on 27 Dec 2012 at 6:37

GoogleCodeExporter commented 9 years ago
I took a shot at boost and qt4:

boost is a mess, there is no standard. These worked for my project, but i can 
guarantee they are buggy. Hopefully this can spark figuring out better 
solutions:

https://github.com/maqifrnswa/openmw/blob/include-what-you-use/boost-all-private
.imp
https://github.com/maqifrnswa/openmw/blob/include-what-you-use/boost-all.imp

you can make a collective .imp
[
{ ref: boost-all-private.imp },
{ ref: boost-all.imp }
]

I tried to find who calls all in /detail/ and make mappings accordingly

I'm a little more confident about qt4 mappings:
https://github.com/maqifrnswa/openmw/blob/include-what-you-use/qt4.imp

Original comment by showard...@gmail.com on 4 Feb 2015 at 5:36

GoogleCodeExporter commented 9 years ago
Nice! Would you consider donating these so we can ship them with IWYU?

I'm not sure how we'd package them, yet, but we'll figure something out.

Bonus points for including the shell scripts to generate mappings!

Original comment by kim.gras...@gmail.com on 4 Feb 2015 at 8:22

GoogleCodeExporter commented 9 years ago
Yes, I can donate them. Please use them however you like in whatever forms you 
like.

both can be improved
boost: I really only address the problem of /detail/ files that was mentioned 
in this bug report. That first stanza should be longer and include all the 
headers where both boost/headername.h and boost/headername/* exist, most 
likely. There isn't a standard, so I only did the ones I explicitly 
investigated to build the project I was working.

qt: really basic implementation, lots of redundancies, but it works

Original comment by showard...@gmail.com on 4 Feb 2015 at 9:18