使用外部 Xcode Clang 静态分析器二进制文件,并进行额外检查

发布于 2024-09-10 14:39:46 字数 1103 浏览 6 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

≈。彩虹 2024-09-17 14:39:46

经过进一步调查,最好的方法似乎是使用目标构建信息中的几个条目,而不是使用 set-xcode-analyzer 命令行工具。

添加用户定义的设置 CC,其中包含二进制文件较新版本的完整路径,如下所示(请注意,/bin/clang 位于路径):

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

然后在其他警告标志条目中添加所需数量的附加检查,如下所示:

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

每个检查前面都有参数-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):

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

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

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.

不羁少年 2024-09-17 14:39:46

接受的答案不再有效(Xcode 4)

Xcode 构建文件的格式意味着您必须这样做:

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

注意:整个 XAnalyzer 短语周围的引号。

The accepted answer no longer works (Xcode 4)

The format of Xcode's build file means you have to do it like this:

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

NB: the quotes surrounding the entire XAnalyzer phrase.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文