Static Analysis 是基于Clang 的非常好的静态代码分析工具。
主要从以下几个方面进行检测:
-
Logic flaws, such as accessing uninitialized variables and dereferencing null pointers(逻辑错误,比如访问未初始化的变量、解引用空指针)
- Memory management flaws, such as leaking allocated memory(内存管理错误,比如内存泄露,在MRC机制下很有用)
- Dead store (unused variable) flaws(死存储,比如未使用的变量)
- API-usage flaws that result from not following the policies required by the frameworks and libraries the project is using(API使用错误)
1、点击product -> Analyze(shift+command+B)
2、选择某一条分析消息
3、点击相应的消息
4、点击箭头,查看错误跟踪线
5、编辑代码修改错误