3

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

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

我想不通的是如何设置该二进制文件以使用额外的检查,例如通过 Xcode 使用二进制文件时的 -analyzer-check-objc-missing-dealloc,详见此处: http: //loufranco.com/blog/文件/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 使用时,如何将额外的选项传递给二进制文件?

4

2 回答 2

7

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.

于 2010-07-21T22:37:33.497 回答
1

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.

于 2013-04-12T15:12:43.040 回答