深静态分析和浅静态分析有什么区别?

Sea*_*ian 5 xcode static-analysis clang-static-analyzer

浅层和深层静态分析有什么区别?我现在正在使用Xcode,并注意到有一个构建设置区分了两者.

在一般情况下我对此很好奇,我也想知道Clang如何实现这种区别有什么不同.

我尝试了一些Google-foo,我找不到答案.我尝试通过Apple和Clang文档来看看他们是否解释了但我没有找到任何东西.希望我没有错过一个明显的石头推翻我的搜索.

Xcode深度和浅静态分析选项的截图

Lon*_*zak 3

(1)苹果公司 Evan Cheng(编译技术)的演讲给出了指示(参见第 157/158 页):

  • 浅层快速分析
  • 深入-更彻底的分析

推荐:Always analyze in deep mode as part of qualifications

(2)更多细节你可以在analyzerOptions的源代码中找到UserModeKind 变量:

00184   /// \brief Describes the kinds for high-level analyzer mode.
00185   enum UserModeKind {
00186     UMK_NotSet = 0,
00187     /// Perform shallow but fast analyzes.
00188     UMK_Shallow = 1,
00189     /// Perform deep analyzes.
00190     UMK_Deep = 2
00191   };
00192 
00193   /// Controls the high-level analyzer mode, which influences the default 
00194   /// settings for some of the lower-level config options (such as IPAMode).
00195   /// \sa getUserMode
00196   UserModeKind UserMode;
00197 
00198   /// Controls the mode of inter-procedural analysis.
00199   IPAKind IPAMode;
Run Code Online (Sandbox Code Playgroud)

无需深入研究代码,您就会发现一个区别是(耗时的)过程间分析的停用......