[cfe-dev] Clang 3.3: --analyze produces object file full of XML (plist)

Jeffrey Walton noloader at gmail.com
Mon Sep 23 09:57:12 PDT 2013


On Mon, Sep 23, 2013 at 4:05 AM, Jonathan Sauer <jonathan.sauer at gmx.de> wrote:
> Hello,
>
>>> What is the result you expect?
>> Well, I wanted to invoke the analyzer while building the library (or
>> in this case, compiling a source file). I wanted the results to go to
>> stdout (its easier to file bug reports based on the findings).
>>
>> $ /usr/local/bin/clang --analyze -analyzer-output stdout t.c -o t.exe
>> clang: warning: argument unused during compilation: '-analyzer-output stdout'
>>
>> So I guess I should ask: how do I run the analyzer, build the object
>> files, and print the analyzer's results to the terminal?
>
> From what I know the analyzer cannot be run at the same time as compiling the
> program; you have to do a separate run. This page describes how it's done:
> <http://clang-analyzer.llvm.org/scan-build.html>.
Ah, OK. I've been using scan-build. But the last project I acceptance
tested had an upload limit in its bug reporter, so I could not upload
the scan-build results (even after tar'ing).

I think I allowed Microsoft's Visual Studio cross-pollinate here. They
have an /analyze switch too, and it invokes a heavier-weight analysis
during compilation. Microsoft's analyzer is called Enterprise Code
Analysis (http://msdn.microsoft.com/en-us/library/ms173498(v=vs.90).aspx),
and I thought Clang's analyzer worked the same.

> Given that the static analyzer is much slower than compilation I don't think
> it's wise to run it every time. But you could set it up so it runs e.g. as part
> of your unit tests.
I grinned when I read that. It reminds me of Dr. Jon Bentley's saying:
If it does not have to be correct, I can make it as fast as you'd like
it to be.

When building an external library for possible use, I really don't
care how long it takes to compile and link. But I do care about the
hidden problems uncovered by Clang. (Not meant to be rude - it just my
thinking).

Jeff



More information about the cfe-dev mailing list