Is it possible to suppress Xcode 4 static analyzer warnings? Is it possible to suppress Xcode 4 static analyzer warnings? objective-c objective-c

Is it possible to suppress Xcode 4 static analyzer warnings?


I found a solution: false positives (like the Apple singleton design pattern) can be avoided with:

#ifndef __clang_analyzer__// Code not to be analyzed#endif

Analyzer will not analyze the code between those preprocessor directives.


Take a look at this page which shows how to use several #defines to annotate objective-c methods and parameters to help the static analyzer (clang) do the right thing

http://clang-analyzer.llvm.org/annotations.html

From that page:

The Clang frontend supports several source-level annotations in the form of GCC-style attributes and pragmas that can help make using the Clang Static Analyzer more useful. These annotations can both help suppress false positives as well as enhance the analyzer's ability to find bugs.


See my answer here. You can add a compile flag to the files and static analyzer will ignore them. This is probably better for 3rd party code you aren't concerned about, and not for first party code you are writing.