2012-06-14 6 views
8

No puedo obtener clang's c++-analyzer para trabajar en un archivo C++ de juguete.clang's scan-build no funciona para el archivo cpp simple

#include <iostream> 

using namespace std; 

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

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

makefile es sólo

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

scan-build make de salida:

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. 

Como hacer C++ - analizador de trabajo? La versión de Clang es 2.9 en Ubuntu 11.10.

EDIT: Soy consciente de que el código es incorrecto. El punto es que Clang no se queja de los errores obvios. Si pego el código anterior en un archivo .c (sin el using ...), el clang emite correctamente advertencias.

Respuesta

7

Aquí está la razón:

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

¿Qué debe ajustarse a? Intenté configurarlo en 1, pero todavía no funcionaba. Google no está apareciendo en cuclillas. –

+2

¿Esta respuesta es actual? –