使用外部 Xcode Clang 静态分析器二进制文件,并进行额外检查 [英] Using an external Xcode Clang Static Analyzer binary, with additional checks

查看:22
本文介绍了使用外部 Xcode Clang 静态分析器二进制文件,并进行额外检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Xcode 3.2.4 并设置了 Clang 静态分析器功能以使用二进制文件的较新版本,详情如下:http://clang-analyzer.llvm.org/xcode.html

I’m using Xcode 3.2.4 and have setup the Clang Static Analyser feature to use a newer build of the binary, as detailed here: http://clang-analyzer.llvm.org/xcode.html

(基本上使用 set-xcode-analyzer 命令行实用程序来更改 Xcode 用于构建和分析的静态分析器副本.)

(Basically using the set-xcode-analyzer command line utility to change which copy of the Static Analyser that Xcode uses for Build and Analyze.)

我不知道如何设置该二进制文件以使用其他检查,例如通过 Xcode 使用二进制文件时的 -analyzer-check-objc-missing-dealloc,详情如下:http://loufranco.com/blog/files/scan-build-better-than-build-analyze.html 和 scan-build --help.

What I can’t figure is how to set that binary to use additional checks, such as -analyzer-check-objc-missing-dealloc when using the binary via Xcode, as detailed here: http://loufranco.com/blog/files/scan-build-better-than-build-analyze.html and in scan-build --help.

    AVAILABLE ANALYSES (multiple analyses may be specified):

 (+) -analyzer-check-dead-stores
     -analyzer-check-llvm-conventions
 (+) -analyzer-check-objc-mem
 (+) -analyzer-check-objc-methodsigs
     -analyzer-check-objc-missing-dealloc
 (+) -analyzer-check-objc-unused-ivars
 (+) -analyzer-check-security-syntactic

 NOTE: "(+)" indicates that an analysis is enabled by default unless one
       or more analysis options are specified

当通过 Xcode 使用时,如何将额外的选项传递给二进制文件?

How do you pass in extra options to the binary when used via Xcode?

推荐答案

经过进一步调查,似乎最好的方法是使用 Target Build Info 中的几个条目,而不是 set-xcode-analyzer 命令行工具.

Upon further investigation, it seems the best way to do this is to use a couple of entries in the Target Build Info, rather than the set-xcode-analyzer command line tool.

添加一个用户定义的设置,CC,包含到新版本二进制文件的完整路径,如下(注意/bin/clang路径结束):

Add a User-defined setting, CC, containing the full path to the newer build of the binary, as follows (note that the /bin/clang on the end of the path):

CC = /Path/To/Folder/With/Clang/checker-244/bin/clang

然后在 Other Warning Flags 条目中添加任意数量的附加检查,如下所示:

Then in the Other Warning Flags entry add as many of the additional checks as you want, as follows:

WARNING_CFLAGS = -Xanalyzer -analyzer-check-llvm-conventions -Xanalyzer -analyzer-check-objc-missing-dealloc

每个参数前面都有 -Xanalyzer 参数,表示下一个参数应该传递给分析器.

Each is preceded by the argument -Xanalyzer which indicates that the next argument should be passed to the analyzer.

可以在此处找到更多相关信息:Mac OS X 开发者工具手册页.

More on this can be found here: Mac OS X Developer Tools Manual Page.

然后,当您在 Xcode 中执行构建和分析时,您应该使用运行额外检查的外部更新二进制文件.

Then, when you do a Build and Analyze in Xcode you should be using the external, newer binary running the additional checks.

这篇关于使用外部 Xcode Clang 静态分析器二进制文件,并进行额外检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆