8

c++-analyzerおもちゃのC++ファイルでclangを動作させることができません。

#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.cpp

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のバージョンはUbuntu11.10では2.9です。

編集:コードが正しくないことを認識しています。重要なのは、Clangは明らかなバグについて文句を言わないということです。上記のコードを()なしの.cファイルに貼り付けると、using ...clangは正しく警告を発します。

4

1 に答える 1

7

理由は次のとおりです。

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.
于 2012-06-14T16:27:59.067 に答える