[cfe-dev] Reporting false positives detected by Clang static analyzer

Devin Coughlin via cfe-dev cfe-dev at lists.llvm.org
Thu Apr 7 16:28:35 PDT 2016


> On Apr 7, 2016, at 1:19 PM, Apelete Seketeli via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Is there a way to report/declare such false positives in order to
> filter them out in the subsequent runs of the static analyzer ?

Unfortunately, there is not a holistic mechanism for suppressing false positives from subsequent analyzer runs.

For many false positives, there is some underlying invariant that the analyzer doesn’t understand. For these, you can often add a carefully-placed assert() to then code to tell the analyzer about the invariant (and get dynamic checking of the invariant when assertions are enabled!). You can also hide code from the analyzer with:

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

There is a FAQ describing these suppression mechanisms and others at <http://clang-analyzer.llvm.org/faq.html>.

Devin


More information about the cfe-dev mailing list