[cfe-dev] Cannot run Clang Analyzer
as at hacks.yi.org
Tue Jul 5 11:32:43 PDT 2011
Right now the recommended way to run the checkers for external
projects is using the 'scan-build' tool (located under
./llvm/tools/clang/tools/scan-build, and its cousin, scan-view for
viewing reports.) It's basically a hack^H^H^H^H perl script that
transposes the clang analyzer into your build, followed by running
your real compiler (like gcc) over it. So it really makes the analysis
'transparent' to your regular build system. You can effectively just
put the 'scan-build' command in front of your regular build system
command, and the script will 'do the rest' (by properly setting CC
The situation isn't optimal since scan-build isn't full proof, but it
works in a surprising amount of situations (I've had success with
make, xcodebuild, waf, etc etc.) There are outstanding bugs on the
tracker related to moving scan-build functionality into the clang
driver, but I there are probably still some issues to work out
relating to the design before that can be done (like how the user
should invoke the driver, should compilation proceed with the
analyzer, or do you only want to run the analyzer and abandon actual
scan-build also does not enable all checkers (such as experimental
ones) by default. If you run 'scan-build -h' you can see the list of
available checkers and what's enabled by default, and you can use
'-enable-checker <name>' to enable an extra one.
If you're curious, you can also invoke 'scan-build -v' when you run it
and it'll show you the list of arguments it directly passes to the
clang -cc1 driver during the compilation, so you can see the 'real'
command line needed to invoke the analyzer. Last time I tried this the
arguments were somewhat involved, so if possible it'd probably be best
to just use scan-build and save yourself the trouble (or if that
doesn't work, perhaps help move scan-build into the compiler
On Tue, Jul 5, 2011 at 1:20 PM, bigeric144 <bigeric144 at gmail.com> wrote:
> Hi All,
> I am new to the development side of Clang, I have built from source and am
> trying to run the static analyzer on the test files included in the clang
> source. I'm using the arguments within each test file but I am not able to
> get anything specific to work.
> Example: I run the following command
> clang -cc1 -analyze -analyzer-checker=core,core.experimental.CastToStruct
> And get this error in return:
> Argument unused during compilation: '-analyze'
> Argument unused during compilation: '-analyze-checker'
> It appears to me that the checkers are not being ran at all. Any advice on
> how to rectify this problem? Thank you for your time!
> View this message in context: http://clang-developers.42468.n3.nabble.com/Cannot-run-Clang-Analyzer-tp3141859p3141859.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
More information about the cfe-dev