2012-06-14 11 views
8

Ich kann nicht kling c++-analyzer auf eine Spielzeug-C++ - Datei zu arbeiten.clangs scan-build funktioniert nicht für einfache cpp-Datei

#include <iostream> 

using namespace std; 

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

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

Make-Datei ist nur

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

scan-build make Ausgang:

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. 

Wie c machen ++ - Analysator Arbeit? Clangs Version ist 2.9 unter Ubuntu 11.10.

EDIT: Ich bin mir bewusst, dass der Code falsch ist. Der Punkt ist, dass Clang sich nicht über die offensichtlichen Fehler beschwert. Wenn ich den obigen Code in eine .c-Datei (ohne using ...) einfüge, gibt clam korrekt Warnungen aus.

Antwort

7

Hier ist der Grund:

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. 
+3

Was sollte es eingestellt werden? Ich habe versucht, es auf 1, aber immer noch nicht Worky. Google kommt nicht in die Hocke. –

+2

Ist diese Antwort noch aktuell? –