abduld / include-what-you-use

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

windows.h breaks iwyu in certain cases #183

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?  Give the *exact* arguments passed
to include-what-you-use, and attach the input source file that gives the
problem (minimal test-cases are much appreciated!)
1. include windows.h before an associated header file for a c file
2. iwyu will no longer recognize the c file as requiring any function 
prototypes declared in the associated header file

Arguments:
-Xiwyu --mapping_file=win32.imp -fmsc-version=1800 -ferror-limit=1 
-Wno-deprecated-declarations -Wno-format -Wno-incompatible-pointer-types 
-Wno-ignored-attributes -Wmissing-declarations -Wimplicit-function-declaration 
-Werror

What is the expected output? What do you see instead?

Expected output:
(foo.h has correct #includes/fwd-decls)

(foo.c has correct #includes/fwd-decls)

Actual output:
foo.c should add these lines:

foo.c should remove these lines:
- #include "foo.h"  // lines 5-5

The full include-list for foo.c:
#include <windows.h>                    // for HANDLE

What version of the product are you using? On what operating system?
iwyu 0.3 compatible with llvm+clang 3.5, running on Windows 7 64-bit with VS2013

Please provide any additional information below.
To reproduce the problem, uncomment out the first line in foo.c (I've reduced 
all the attached files to minimal test case). This is the only issue I've had 
with windows.h on a fairly large codebase. (Everything other than prototypes 
seems to be picked up okay)

Original issue reported on code.google.com by david.om...@gmail.com on 13 Apr 2015 at 3:27

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the report!

I can't reproduce with trunk IWYU (Windows 7 64-bit + VS2012 built from source 
in LLVM/Clang tree), it keeps foo.h happily.

We haven't posted a Clang 3.6-compatible release yet, ping me privately if you 
want a trunk build to test with.

Original comment by kim.gras...@gmail.com on 13 Apr 2015 at 7:54

GoogleCodeExporter commented 9 years ago
I just built trunk with VS2013, and the problem is still reproducible. 
include-what-you-use 0.4 (609) based on clang version 3.7.0 (trunk 234797) 
(llvm/trunk 234796)

Did you uncomment out the first line of the file to reproduce? Otherwise it may 
be only reproducible on VS2013 or the Windows SDK for Windows 8.1 (VS2012 I 
believe uses Windows SDK for Windows 8, I do not have VS2012 installed)

Original comment by david.om...@gmail.com on 13 Apr 2015 at 10:03

GoogleCodeExporter commented 9 years ago
I did uncomment the first line, I even removed the conditional entirely to make 
sure it wasn't confusing IWYU somehow.

But wait a minute -- Clang only builds with VS2013, so I must've built IWYU 
with it too. I double-checked by adding -H to your command-line, and it's 
including SDK headers from the 8.1 SDK.

Weird...

Original comment by kim.gras...@gmail.com on 14 Apr 2015 at 4:19

GoogleCodeExporter commented 9 years ago
Sorry about that, looks like there's more to the reproduction that I originally 
reported.

Arguments:
-Xiwyu --mapping_file=win32.imp -fmsc-version=1800 -ferror-limit=1 
-Wno-deprecated-declarations -Wno-format -Wno-incompatible-pointer-types 
-Wno-ignored-attributes -Wmissing-declarations -Wimplicit-function-declaration 
-Werror -I. <absolute_path>\foo.c

Turns out IWYU keeps foo.h if -I. is not passed in as an argument, keeps foo.h 
if the absolute path is not specified, and keeps foo.h if run from outside the 
directory containing foo.c and foo.h. Finally, it keeps foo.h if foo.h is 
included before windows.h

Original comment by david.om...@gmail.com on 14 Apr 2015 at 1:39