[PATCH] D10356: scan-build: Add --analyzer-target option
hong.gyu.kim at lge.com
Sun Aug 2 23:59:48 PDT 2015
honggyu.kim added a comment.
I have updated the new patchset with more information in help message and changed the option name to —analyser-target.
If you think the "extra flags to pass to the compiler” is still needed, I will write another patch for that.
I appreciate your comment and suggestion.
Comment at: tools/scan-build/scan-build:1156
@@ +1155,3 @@
+ This provides target triple information to clang.
> This is the only real documentation provided to the user to understand what this option does. It is a completely optional option, and I feel it needs a bit more clarification. Perhaps just a second sentence to say "use this when you want to analyze for a different architecture than the default". Also, it isn't clear to the user if this effects both static analysis and compilation, or just compilation. For example, is the expectation that compilation gets the normal flags without this trip, and that static analysis gets this triple?
> There's also many cases where this flag won't work. Instead of having a specific flag for target triple, maybe just an "extra flags to pass to the compiler" would be sufficient (and more general).
As you know, the basic sequence of scan-build comprises into analysis and compilation.
To properly analyse the source code, it is required to use the same target for analysis and compilation.
Otherwise, build scripts wouldn’t work in some cases due to target specific flags and some code couldn’t be compiled if the code contains target specific inline assembly code.
Ideally, I hope to automatically extract the target triple from the actual compiler, but it seems that there’s no standard way to extract the target triple from all the existing compilers including clang, gcc, icc, etc.
I added this option explaining target information for analysis has to be provided explicitly.
We can also consider to add --extra-clang-flags option in a general way, but users may not notice that they have to actually provide the target information only for analysis when they do cross compilation. I was also very confused at first.
More information about the cfe-commits