From: Anna Zaks
While not strictly part of the compiler, the diagnostics from Clang's static analyzer can also be influenced -by the user via changes to the source code. This can be done in two ways: - -
-#ifndef __clang_analyzer__ -// Code not to be analyzed -#endif -- -In general, this usage is discouraged. Instead, we prefer that users file bugs -against the analyzer when it flags false positives. There is also active -discussion of allowing users in the future to selectively silence specific -analyzer warnings (some of which can already be done using annotations).
There is currently no mechanism for suppressing the analyzer warning, -although this is currently being investigated. If you encounter an analyzer -bug/false positive, please report it.
+There is currently no solid mechanism for suppressing an analyzer warning, +although this is currently being investigated. When you encounter an analyzer +bug/false positive, check if it's one of the issues discussed above or if the +analyzer annotations can +resolve the issue. Second, please report it to +help us improve user experience. As the last resort, consider using __clang_analyzer__ macro +described below.
+ +When the static analyzer is using clang to parse source files, it implicitly +defines the preprocessor macro __clang_analyzer__. One can use this +macro to selectively exclude code the analyzer examines. Here is an example: + +
+#ifndef __clang_analyzer__ +// Code not to be analyzed +#endif ++ +This usage is discouraged because it makes the code dead to the analyzer from +now on. Instead, we prefer that users file bugs against the analyzer when it flags +false positives. +