Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to suppress Xcode 4 static analyzer warnings?

The Xcode 4 static analyzer reports in my code some false positives. Is there any way to suppress them?

like image 938
DreamOfMirrors Avatar asked Apr 27 '11 14:04

DreamOfMirrors


People also ask

How do I silence a warning in Xcode?

Add -fdiagnostics-show-option to your CFLAGS and you can see which flag you can use to disable that warning. Thanks ! Exactly what i needed !

What is static analyzer in Xcode?

The static analyzer is a tool in Xcode that can discover bugs by analyzing the source code without running it, so it can reveal bugs, even before you do testing and quality assurance of your app. It can also find problems in code paths that are rare and not covered by tests.

What is Clang static analyzer?

The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs. It implements path-sensitive, inter-procedural analysis based on symbolic execution technique.


1 Answers

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.

like image 199
DreamOfMirrors Avatar answered Sep 18 '22 08:09

DreamOfMirrors