Open GoogleCodeExporter opened 9 years ago
Thanks for the report!
I'd love it if you could boil this down, I tried with a minimal repro with a .h
and a -inl.h, but it seems to just work.
I'm on Windows, and I haven't been able to force scons to use IWYU for
compiler, partly because I'm all new to scons :-) The toolchain search in your
SConstruct seems a little too eager to use MSVC on Windows.
Any more detail would be great!
Original comment by kim.gras...@gmail.com
on 13 Nov 2014 at 9:29
Hi! I've found a much smaller example that recreates this issue (without
scons!). The bottom line is that when include-what-you-use is run from a
different directory than the source files or is given the full path to the
source files, it ignores pragma export. The attached files use pragma export,
although we have tested with begin_exports/end_exports and have the same result.
From the directory with all the sample files, we ran:
"~/llvm/build/bin/include-what-you-use ~/Documents/workspace/export-test/main.cpp &> test.out"
The expected output is that anywhere a function defined in test-inl.h is used,
test.h is included instead. The exact results we are getting can be found in
test.out (attached). Essentially, include-what-you-use is recommending that
main.cpp include test-inl.h.
This example is using the most recent pull from svn on Mac OSX 10.9.5.
Thank you!
Original comment by anna.her...@10gen.com
on 14 Nov 2014 at 6:44
Attachments:
Great info! I might not be able to look at this for a few days, but I'll try
and reproduce and debug.
Original comment by kim.gras...@gmail.com
on 15 Nov 2014 at 8:51
I've now been able to take a quick look, and I know what's wrong, at least.
We have a heuristic function, ConvertToQuotedInclude, that attempts to map
backwards from a full path to the quoted include name we'd use to include it.
I'm beginning to think there is no good, general way to do that.
This is more or less the same as issue 5.
A workaround I found is to pass the path to test-inl.h on the command-line to
IWYU:
$ include-what-you-use ~/Documents/workspace/export-test/main.cpp -I
~/Documents/workspace/export-test
This worked for the reduced test case, but I have a hunch it might not work for
your in-tree problem with mongodb...?
FWIW, I'll keep looking at this off and on.
Original comment by kim.gras...@gmail.com
on 18 Nov 2014 at 8:13
Thank you for getting back to me!
Unfortunately linking the path to the inline files doesn't fix our in-tree
issue.
We are very interested in getting include-what-you-use to run on MongoDB, and I
was wondering if you had any ideas for how we could go in and fix this for our
use case. We have a fairly consistent include pattern and standardized headers
for most of our project. Any tips on how to get include-what-you-use
(specifically CovertToQuotedInclude?) the information it needs to recognize
inline files?
Thank you again!
Original comment by anna.her...@10gen.com
on 19 Nov 2014 at 5:05
Shame it didn't work...
Yes, we're very interested in getting IWYU working for profile open-source
projects (MongoDB being an obvious candidate) too! :-)
One idea I've had for ConvertToQuotedInclude is to also pass it the full path
or FileEntry of the includer. This would solve things (I hope), because a
quoted include's form depends directly on the path that includes it (this
differs a little between compilers, but is generally true).
Unfortunately, it's used in a lot of places where the includer isn't known
(pragma export handling being one example), so we lack the information we need
to calculate the quoted include.
But I also have a feeling that IWYU overuses quoted includes, so maybe a
majority of those cases can be eliminated altogether. For example, for pragma:
export both the exporting and the exported FileEntry are known, and we should
be able to store the export relationship without involving
ConvertToQuotedInclude at all (touch wood!)
Original comment by kim.gras...@gmail.com
on 19 Nov 2014 at 6:43
Original issue reported on code.google.com by
anna.her...@10gen.com
on 7 Nov 2014 at 10:07Attachments: