engmsaleh / include-what-you-use

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

header file are not checked correctly #187

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I just began to use iwyu. It seems to be the only free software in this purpose.
I just wrote several test cases and found 2 of them failed. I use only compiled 
include-what-you-use directly, no other flags. Please check the attached 
source. It is very simple. There is also a README file for the failure. 

For example4, I hope iwyu to indicate hello_world1.h should include  
hello_world2.h

I am using include-what-you-use-3.4.src.tar.gz from 
https://code.google.com/p/include-what-you-use/

Please provide any additional information below.

Original issue reported on code.google.com by zhanglii...@gmail.com on 14 May 2015 at 3:24

Attachments:

GoogleCodeExporter commented 9 years ago
IWYU only analyzes compilation-unit-at-a-time; a .c/.cpp file and its 
associated header file. If it analyzed and made changes to *all* headers it 
wouldn't work with parallellizing build systems. But it can only associate 
header and source file if they have the same basename.

So for example4, if I rename hello_world_header_missing_header.c to 
hello_world.c and hello_world1.h to hello_world.h (and fixing up include lines) 
they will be recognized as a unit, and IWYU will actually suggest that 
hello_world.h should include hello_world2.h

And the same thing goes for example5 -- by renaming the .c file and the 
hello_world1.h header to hello_world.*, IWYU will understand that they should 
be analyzed together and suggest that .c removes the include of hello_world2.h

You can express this explicitly as well with the --check_also switch:

$ include-what-you-use.exe -Xiwyu --check_also=hello_world1.h 
hello_world_header_missing_header.c

Original comment by kim.gras...@gmail.com on 14 May 2015 at 8:47

GoogleCodeExporter commented 9 years ago
Thanks. It is very useful for me. Maybe such important info should be added to 
the page 
https://code.google.com/p/include-what-you-use/wiki/InstructionsForUsers

Original comment by zhanglii...@gmail.com on 15 May 2015 at 6:18