我无法让clang的c++-analyzer在玩具C++文件上工作。
#include <iostream>
using namespace std;
int main()
{
int t[4];
int x,y;
t[5]=1;
if(x)
y = 5;
x = t[y];
} makefile只是
all: t.cpp
$(CXX) t.cppscan-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在Ubuntu 11.10上的版本是2.9。
编辑:我知道代码是不正确的。关键是Clang并没有抱怨明显的bug。如果我将上面的代码粘贴到一个.c文件中(没有using ...),clang会正确地发出警告。
发布于 2012-06-15 00:27:59
原因如下:
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.https://stackoverflow.com/questions/11037139
复制相似问题