[PATCH] D10356: scan-build: Add --analyzer-target option

Ted Kremenek kremenek at apple.com
Mon Aug 3 14:19:53 PDT 2015


krememek added a comment.

In http://reviews.llvm.org/D10356#186078, @honggyu.kim wrote:

> Hi all,
>
> I wrote this patch because I had some problem generating a clang static analysis report for ARM Linux kernel code. Since it uses
>  some target specific flags for ARM, I got the following error message during analysis.
>
> error: unknown target CPU 'armv7-a'
>
> I have checked scan-build script, but there was no way to pass target triple information to clang, so clang thinks that the source
>  code can be compiled for host machine, x86_64. This patch adds --triple option to fix this problem.
>
> With this patch, I was able to generate clang static analysis report for ARM Linux kernel code with the following command:
>  $ scan-build --use-cc=arm-linux-gcc --triple=arm-linux-gnueabi make ARCH=arm CROSS_COMPILE=arm-linux-
>
> Please let me know your opinion.
>  I appreciate all your comment.
>
> Thanks,
> Honggyu


Is this an issue that the clang used for static analysis does not understand the target triple used to build Linux (i.e., "'armv7-a")?  Shouldn't we just fix that by adding that target triple to Clang?

I also don't understand this point:

> I have checked scan-build script, but there was no way to pass target triple information to clang, so clang thinks that the source

>  code can be compiled for host machine, x86_64. This patch adds --triple option to fix this problem.


Which 'clang' are you talking about?  The clang used for static analysis?  Are you saying because clang doesn't recognize the target it tries to compile for the host machine instead, and thus the analysis is wrong?


http://reviews.llvm.org/D10356







More information about the cfe-commits mailing list