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

Command line help for include-what-you-use requires knowing the -Xiwyu flag

Originally reported on Google Code with ID 85


When passing --help to the include-what-you-use binary, we get what looks like a clang
usage message, followed by:

error: unable to handle compilation, expected exactly one compiler job in ''
/home/rpavlik/src/third-party/llvm/tools/clang/tools/include-what-you-use/iwyu.cc:3704:
Assertion failed: compiler && "Failed to process argv"
Aborted

When passing -h, the clang usage message isn't printed, but this error message is:

error: no input files
error: unable to handle compilation, expected exactly one compiler job in ''
/home/rpavlik/src/third-party/llvm/tools/clang/tools/include-what-you-use/iwyu.cc:3704:
Assertion failed: compiler && "Failed to process argv"
Aborted

The only way I could get the help to display was to call something like "include-what-you-use
-Xiwyu -h"  which gave two errors around the usage info:

include-what-you-use: invalid option -- 'h'
USAGE: iwyu [-Xiwyu --iwyu_opt]... <clang opts> <source file>
Here are the <opts> you can specify:
   --check_also=<glob>: tells iwyu to print iwyu-violation info
        for all files matching the given glob pattern (in addition
        to the default of reporting for the input .cc file and its
        associated .h files).  This flag may be specified multiple
        times to specify multiple glob patterns.
   --cwd=<dir>: tells iwyu what the current working directory is.
   --help: prints this help and exits.
   --howtodebug[=<filename>]: with no arg, prints instructions on
        how to run iwyu under gdb for the input file, and exits.
        With an arg, prints only when input file matches the arg.
   --mapping_file=<filename>: gives iwyu a mapping file.
   --transitive_includes_only: do not suggest that a file add
        foo.h unless foo.h is already visible in the file's
        transitive includes.
   --verbose=<level>: the higher the level, the more output.

FATAL ERROR: unknown flag.


Alternately -Xiwyu --help displayed the usage text without the two errors.
</level></filename></filename></dir></glob></opts></source></clang>

Reported by ryan.pavlik on 2012-11-20 20:08:49

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

  • 写回答

13条回答 默认 最新

  • weixin_39822993 2020-11-30 11:25
    关注
    
    Yes, I think there are (at least :-) two issues here:
    
    1) Handle --help and -h in a reasonable way
    2) What happens when no input file is provided -- it drives me crazy that IWYU aborts
    here.
    
    I don't know if it's critical that we can display Clang's help text.
    

    Reported by kim.grasman on 2012-11-21 06:12:06

    评论

报告相同问题?