按照主clang静态分析器网页(http://clang-analyzer.llvm.org/scan-build.html)...
的说明进行操作我有一个小错误的小文件(badcode.c
):
int main(int argc, char ** argv)
{
int j;
int a[4];
puts(a[j]);
return 'a';
}
为了弄清楚clang静态分析器(scan-build)字的基本概念,我运行:
scan-build -v clang badcode.c
输出:
scan-build: Emitting reports for this run to '/tmp/scan-build-2012-08-17-1'.
scan-build: 'clang' executable not found in '/usr/share/clang/scan-build/bin'.
scan-build: Using 'clang' from path: /usr/bin/clang
badcode.c:7:2: warning: implicit declaration of function 'puts' is invalid in C99 [-Wimplicit-function-declaration]
puts(a[j]);
^
1 warning generated.
scan-build: Removing directory '/tmp/scan-build-2012-08-17-1' because it contains no reports.
好的,很棒,clang发出一点警告,但仍然会产生a.out。为什么它不会产生报告?对于任何静态分析仪,单元化变量j
应该是一个非常明显的红旗 - 为什么不报告?
我只是使用错误的命令行参数吗?
答案 0 :(得分:0)
试试这个:
scan-build -k -V -o scan-reports xcodebuild clean build -configuration Debug -sdk [sdk-version] -xcconfig = [xconfig-certificate-file]
<强> E.g:强> scan-build -k -V -o scan-reports xcodebuild clean build -configuration Debug -sdk iphoneos5.0 -xcconfig =“/ Users / username / config.xcconfig”
这应该创建一个html输出。