使用外部 Xcode Clang 静态分析器二进制文件,并进行额外检查
我正在使用 Xcode 3.2.4 并设置了 Clang Static Analyzer 功能以使用较新版本的二进制文件,详细信息如下: http://clang-analyzer.llvm.org/xcode.html
(基本上使用set-xcode-analyzer命令行实用程序来更改哪个副本Xcode 用于构建和分析的静态分析器。)
我无法弄清楚如何设置该二进制文件以使用其他检查,例如使用时的 -analyzer-check-objc-missing-dealloc通过 Xcode 获取二进制文件,详细信息如下: http:// /loufranco.com/blog/files/scan-build-better-than-build-analyze.html 和 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 使用时如何将额外选项传递给二进制文件?
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
(Basically using the set-xcode-analyzer command line utility to change which copy of the Static Analyser that Xcode uses for Build and Analyze.)
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
How do you pass in extra options to the binary when used via Xcode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过进一步调查,最好的方法似乎是使用目标构建信息中的几个条目,而不是使用 set-xcode-analyzer 命令行工具。
添加用户定义的设置 CC,其中包含二进制文件较新版本的完整路径,如下所示(请注意,/bin/clang 位于路径):
然后在其他警告标志条目中添加所需数量的附加检查,如下所示:
每个检查前面都有参数-Xanalyzer,该参数表明下一个参数应该传递给分析器。
有关此内容的更多信息,请访问:Mac OS X 开发者工具手册页。
然后,当您在 Xcode 中执行构建和分析时,您应该使用外部的较新的二进制文件来运行额外的检查。
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.
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):
Then in the Other Warning Flags entry add as many of the additional checks as you want, as follows:
Each is preceded by the argument -Xanalyzer which indicates that the next argument should be passed to the analyzer.
More on this can be found here: Mac OS X Developer Tools Manual Page.
Then, when you do a Build and Analyze in Xcode you should be using the external, newer binary running the additional checks.
接受的答案不再有效(Xcode 4)
Xcode 构建文件的格式意味着您必须这样做:
注意:整个 XAnalyzer 短语周围的引号。
The accepted answer no longer works (Xcode 4)
The format of Xcode's build file means you have to do it like this:
NB: the quotes surrounding the entire XAnalyzer phrase.