weixin_39822993 2020-11-30 11:25
浏览 0

IWYU suggests removal of origin headers for used macros.

Originally reported on Google Code with ID 99


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.

</cstdlib></cstdlib>

Reported by andrew.c.morrow on 2013-06-28 23:40:14

该提问来源于开源项目:include-what-you-use/include-what-you-use

  • 写回答

5条回答 默认 最新

  • weixin_39822993 2020-11-30 11:25
    关注
    
    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-r180025    lang/llvm-3.3
    llvm-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
    
    

    Reported by andrew.c.morrow on 2013-06-29 17:41:16

    评论

报告相同问题?