clang的scan-build不适用于简单的cpp文件 [英] clang's scan-build doesn't work for simple cpp file

查看:1006
本文介绍了clang的scan-build不适用于简单的cpp文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能得到clang的 c ++ - analyzer 来处理玩具C ++文件。

I can't get clang's c++-analyzer to work on a toy C++ file.

#include <iostream>

using namespace std;

int main()
{
    int t[4];
    int x,y;

    t[5]=1;
    if(x)
        y = 5;
    x = t[y];
}         

makefile只是

makefile is just

all: t.cpp
    $(CXX) t.cpp


b $ b

scan-build make 输出:

scan-build: 'clang' executable not found in '/usr/share/clang/scan-build/bin'.
scan-build: Using 'clang' from path: /usr/bin/clang
/usr/share/clang/scan-build/c++-analyzer t.cpp
scan-build: Removing directory '/tmp/scan-build-2012-06-14-6' because it contains no reports.

如何使c ++ - 分析器工作? Clang的版本是2.9在Ubuntu 11.10。

How to make c++-analyzer work? Clang's version is 2.9 on Ubuntu 11.10.

编辑:我知道代码不正确。关键是,Clang不抱怨明显的bug。如果我将上述代码粘贴到.c文件(没有 using ... ),clang会正确地发出警告。

I'm aware the code is incorrect. The point is that Clang does not complain about the obvious bugs. If I paste the above code to a .c file (without the using ...) clang correctly emits warnings.

推荐答案

原因如下:

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-September/011194.html

>>> When I run "clang --analyze" on my c++ source files individually I get reports,
>>> but none when using the scan-build tool.
>> 
>> This is intended behavior.  C++ support is still alpha and so it isn't enabled
>> by default in scan-build.  It's really only intended to be used by those
>> currently hacking on the analyzer.
>> 
>> If you want to enable C++ analysis, you must define the environment variable
>> CCC_ANALYZER_CPLUSPLUS.

这篇关于clang的scan-build不适用于简单的cpp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆