LukasScheucher / include-what-you-use

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

Response file support #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
iwyu doesn't support response files (aka '@files'). Support for these were 
added to clang in r108697 
(http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20100719/032322.html
), but iwyu doesn't seem to have picked up this change.

Here's a simple test to demonstrate this behaviour:

---test.cpp---
#ifndef RSP_SAYS_HELLO
#error Didn't see the .rsp file
#endif

int main()
{
  return 0;
}

---test.rsp---
-DRSP_SAYS_HELLO

C:\dev\test_rsp>include-what-you-use @test.rsp test.cpp
error: no such file or directory: '@test.rsp'
test.cpp(4) :  error: #error Didn't see the .rsp file
#error Didn't see the .rsp file
 ^

(test.cpp has correct #includes/fwd-decls)

The same files compile without error via clang:

C:\dev\test_rsp>clang -fsyntax-only @test.rsp test.cpp

The attached patch resolves this. I've lifted the response file handling from 
<clang>\tools\driver\driver.cpp and applied to iwyu.cc. Ideally there'd be some 
shared code that we could use to avoid the copy-pasta; I'll look into raising a 
patch against Clang to address this.

(BTW the patch below contains a slightly tweaked version of the code from 
driver.cpp. The original code aggressively strips backslashes, regardless of 
whether they're actually part of a recognised escape sequence - 
backslash-backslash or backslash-space. I've made a change to make this 
slightly more lenient, which I believe is closer to how GCC handles response 
files. )

Original issue reported on code.google.com by paul.hol...@gmail.com on 20 Feb 2011 at 7:09

Attachments:

GoogleCodeExporter commented 8 years ago
I've been testing a bit more to see how Clang and GCC handle backslashes in 
response files, and it seems that Clang actually exhibits the same behaviour as 
newer versions of GCC. The version of GCC I had been testing with (part of a 
large toolchain) must have some tweaks.

So this updated patch uses identical logic to <clang>\tools\driver\driver.cpp, 
which is probably a safer bet.

Original comment by paul.hol...@gmail.com on 20 Feb 2011 at 7:53

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the patch!  Committed in r32.

Original comment by csilv...@gmail.com on 23 Feb 2011 at 2:16