yodamaster / include-what-you-use

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

IWYU suggests removal of origin headers for used macros. #99

Closed GoogleCodeExporter closed 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. Run IWYU over the following trivial file
#include <cstdlib>

int main(int argc, char* argv[]) {
    return EXIT_SUCCESS;
}

$ ./include-what-you-use ./exit_success.cpp

exit_success.cpp should add these lines:

exit_success.cpp should remove these lines:
- #include <cstdlib>  // lines 1-1

The full include-list for exit_success.cpp:

---

What is the expected output? What do you see instead?
I would not expect that it would tell me to remove the header file that defines 
a used macro. I've also seen it suggest removing other headers when macros 
defined in those headers are used, for macros that I define in my own headers. 
In the codebase with which I am working, IWYU is recommending the removal of 
the header that defines the local analogue to DISALLOW_EVIL_CONSTRUCTORS.

What version of the product are you using? On what operating system?
r472 on OS X Mountain Lion

Please provide any additional information below.

Original issue reported on code.google.com by andrew.c.morrow@gmail.com on 28 Jun 2013 at 11:40

GoogleCodeExporter commented 9 years ago
I forgot to mention which clang/llvm I built against. I'm using MacPorts 
clang/llvm 3.3 prerelease: 

➜  build  port list clang-3.3 llvm-3.3
clang-3.3                      @3.3-r180025    lang/llvm-3.3
llvm-3.3                       @3.3-r180025    lang/llvm-3.3

Build process:

➜  include-what-you-use-read-only  \rm -rf build
➜  include-what-you-use-read-only  mkdir build
➜  include-what-you-use-read-only  cd build
➜  build  cmake -G Ninja .. -DLLVM_PATH=/opt/local/libexec/llvm-3.3
-- The C compiler identification is Clang 4.2.0
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- The CXX compiler identification is Clang 4.2.0
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- IWYU out-of-tree configuration
-- Configuring done
-- Generating done
-- Build files have been written to: 
/Users/andrew/Documents/10gen/dev/oss/include-what-you-use-read-only/build
➜  build  ninja all
[14/14] Linking CXX executable include-what-you-use

Original comment by andrew.c.morrow@gmail.com on 29 Jun 2013 at 5:41

GoogleCodeExporter commented 9 years ago
Can you please run IWYU with -Xiwyu --verbose=6 and attach the log? For example,
  include-what-you-use -Xiwyu --verbose=6 ./exit_success.cpp

For me IWYU doesn't recommend to remove #include <cstdlib>. I am looking for a 
message like
  [ Use macro   ] exit_success.cpp:4:12: EXIT_SUCCESS (from /usr/include/stdlib.h:119:9)
  Marked full-info use of symbol EXIT_SUCCESS (from /usr/include/stdlib.h) at exit_success.cpp:4:12

Original comment by vsap...@gmail.com on 30 Jun 2013 at 6:38

GoogleCodeExporter commented 9 years ago
Same on my Windows build, IWYU doesn't complain.

$ include-what-you-use tests\exit_success.cc

(tests/exit_success.cc has correct #includes/fwd-decls)

It'd be interesting to hear if the --verbose output gives any more clues.

Original comment by kim.gras...@gmail.com on 30 Jun 2013 at 6:54

GoogleCodeExporter commented 9 years ago
I just rebuilt against the recently released stable version of LLVM-3.3 that 
MacPorts pushed over the weekend. It now no longer suggests removing cstdlib, 
so I think this was a (now fixed) bug in LLVM, not IWYU. Please close, sorry 
for the confusion.

Original comment by andrew.c.morrow@gmail.com on 1 Jul 2013 at 1:55

GoogleCodeExporter commented 9 years ago
Glad to hear it's working, thanks!

Original comment by kim.gras...@gmail.com on 1 Jul 2013 at 2:26