[cfe-dev] Clang Static Analyzer: how to use it for C++ application?

Liang Qi cavendish.qi at gmail.com
Tue Apr 26 13:08:12 PDT 2011


Hi, Kremenek,

Thanks a lot for your reply.

I tried to change my CMakeLists.txt to use ccc-analyzer/c++-analyzer
as compiler. And found they are not shipped in checker-256.

The output for c++-analyzer from clang-2.9, http://pastebin.com/6XJ64L1K
The output for c++-analyzer from clang-3.0(svn), http://pastebin.com/c9Ntm2Ze

Then I guess I need to set some parameters for scan-build or ++-analyzer, right?

Regards,
Liang

On 26 April 2011 19:59, Ted Kremenek <kremenek at apple.com> wrote:
> It looks like the Makefile generated by CMake hardcodes the compiler used.  scan-build tries to override the compiler used by the Makefile to be ccc-analyzer/c++-analyzer respectively.  This coincides with what is stated in the CMake documentation:
>
> http://www.itk.org/Wiki/CMake_Useful_Variables#Compilers_and_Tools
>
> I think the solution is to also run 'cmake' through scan-build as well, similarly to how one handles 'configure' based builds.  That should cause CMake to use ccc-analyzer/c++-analyzer for the compiler.
>
> On Apr 26, 2011, at 2:40 AM, Liang Qi wrote:
>
>> Hi, all,
>>
>> I am just a newbie for Clang Static Analyzer. Then my question is not
>> that complex for you. I am using checker-256 on a Snow Leopard.
>>
>> Here is my test source code, main.cpp: http://pastebin.com/AarMPKbs
>> And I have this CMakeLists.txt: http://pastebin.com/4B1e785d
>> After "cmake ." to generate Makefile, I called "scan-build" and get
>> this output: http://pastebin.com/f0GzQi3m
>>
>> Could you give me any hint, for example, how to enable the checker for
>> cplusplus.experimental.Iterators?
>>
>> Regards,
>> Liang

-- 
http://www.qiliang.net




More information about the cfe-dev mailing list