[PATCH] [StaticAnalyzer] New checker Sizeof on expression

Jordan Rose jordan_rose at apple.com
Mon Oct 7 18:05:24 PDT 2013


On Oct 7, 2013, at 13:58, Richard Smith <richard at metafoo.co.uk> wrote:

> On Mon, Oct 7, 2013 at 9:55 AM, Jordan Rose <jordan_rose at apple.com> wrote:
> I'm fine with this staying in the analyzer for now, unless David, Richard, or Eli feel it should be a warning right away.
> 
> Do we have evidence that we want this? Does it catch bugs? If so, what do they look like? It seems like this would trigger on legitimate code; how does a user suppress the warning in that case, and does that suppression make their code clearer?
> 
> What is the false/true positive ratio for bug finding here?
> 
> sizeof(expression) is a common idiom in SFINAE contexts. Is that covered here?
> 
> sizeof(sizeof(int)) is a "traditional" way to get sizeof(size_t). Why should we warn on that?
> 
> And more as a general question than something specific to this patch: Is there a region in the space of false positive ratios where we think a syntactic warning should go into the static analyzer? If so, why? And what is that region? I would have thought that the static analyzer, like the clang warnings, would be aimed at (eventually) having a false positive ratio of near zero. If so, then should we ever put a warning in the static analyzer if it doesn't require the static analyzer's technology (or have a high runtime cost)?

On this last (and bringing in Ted and Anna):

I think the main difference between compiler warnings and syntactic analyzer checks is that we try very hard to turn new compiler warnings on by default. A second-order effect of this is that we generally avoid style warnings. The analyzer can be a bit looser about this, though: because people know the analyzer is stricter and more in-depth, I think they might also accept that a particular check doesn't fit their project.

On the other hand, we still haven't gotten around to designing a proper bug tracking and/or manual suppression system, so that's one advantage of compiler warnings. And as you say, checks without a high runtime cost don't really have a technical reason to be in the analyzer.

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131007/377cb648/attachment.html>


More information about the cfe-commits mailing list