[cfe-dev] Help required to use clang analyzer

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 4 09:42:13 PST 2019


Hi,

Using -cc1 disables the clang Driver. The Driver is responsible for gcc 
compatibility, which, apart from being able to translate gcc flags to 
clang flags, adds support for finding system headers in places where gcc 
usually looks for them. There are other drivers, such as clang-cl which 
turns clang into a drop-in replacement for the Visual Studio's cl.exe.

Running without the driver is not recommended for everyday use, only for 
development of clang itself.

If you want to run the Static Analyzer on a single file, you can do

     clang --analyze test.c

But even better, you should use the scan-build tool to analyze the 
entire project, for example:

     scan-build clang test.c

or

     scan-build gcc test.c

or

     scan-build make -j4

etc. See https://clang-analyzer.llvm.org/scan-build.html for more details.


On 3/3/19 10:41 PM, Arnab Kumar Biswas via cfe-dev wrote:
> Hi,
> I am trying to use clang analyzer using the below command.
>
> clang -cc1 -analyze -analyzer-checker=alpha.core test.c
>
> I am getting the following error.
>
> test.c:1:10: fatal error: 'sys/stat.h' file not found
> #include <sys/stat.h>
>          ^~~~~~~~~~~~
> 1 error generated.
>
> If I use the command,
> clang test.c
> there is no error.
>
> Please help me to solve the error.
>
> Arnab
>
>
> ------------------------------------------------------------------------
>
> Important: This email is confidential and may be privileged. If you 
> are not the intended recipient, please delete it and notify us 
> immediately; you should not copy or use it for any purpose, nor 
> disclose its contents to any other person. Thank you.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list