遵循主clang静态分析器网页(http://clang-analyzer.llvm.org/scan-build.html)的指示.
我有一个小的C文件,它充满了严重的bug (badcode.c):
int main(int argc, char ** argv)
{
int j;
int a[4];
puts(a[j]);
return 'a';
}为了了解clang静态分析器(扫描构建)单词的基本原理,我运行:
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对任何静态分析器来说都应该是一个明显的危险信号--为什么没有报告呢?
我只是使用错误的命令行参数吗?
发布于 2013-01-04 12:05:33
试试这个:
扫描-构建-k -V -o扫描-报告xcodebuild干净构建-configuration调试-sdk sdk-version -xcconfig=xconfig-证书-文件
例如: scan-build -k -V -o scan-reports xcodebuild -configuration Debug -sdk iphoneos5.0 -xcconfig=“/username/config.xcconfig”
这应该会创建一个html输出。
https://stackoverflow.com/questions/12008032
复制相似问题