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

Manuel Klimek klimek at google.com
Tue Apr 26 12:45:00 PDT 2011


On Tue, Apr 26, 2011 at 10:59 AM, 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.

FYI, we will soon have a way to run tools (like the static analyzer)
over code without running it in a build. The idea is to have cmake
write a compile command database (currently in review in cmake
upstream) and reconstruct the compile command for a source file from
that (see http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-April/014684.html
for the patch to clang).

Cheers,
/Manuel

> 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
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list