[PATCH] Combine the checks for returns_nonnull and for operator new returning null, in Sema::CheckReturnValExpr

Richard Smith richard at metafoo.co.uk
Thu Jan 23 13:15:00 PST 2014


On Thu, Jan 23, 2014 at 9:20 AM, Jordan Rose <jordan_rose at apple.com> wrote:

> This mostly looks good to me. One comment, though:
>
> +          !RetValExp->isValueDependent() &&
>
> The returns_nonnull check doesn't bother to check if it's value-dependent
> first. Is that necessary? Should that be folded in somewhere else?


Yes, that is necessary. If your CheckNonNullExpr is supposed to
conservatively return false if the expression isn't known to be null, it
should return false on any value-dependent expression.

Jordan
>
>
> On Jan 23, 2014, at 2:24 , Artyom Skrobov <Artyom.Skrobov at arm.com> wrote:
>
> > Jordan, good catch that this can be combined; attaching for a review.
> >
> >
> >
> > -----Original Message-----
> > From: Jordan Rose [mailto:jordan_rose at apple.com]
> > Sent: 22 January 2014 17:21
> > To: Ted Kremenek
> > Cc: llvm cfe; Richard Smith; Artyom Skrobov
> > Subject: Re: r199790 - Add basic checking for returning null from
> > functions/methods marked 'returns_nonnull'.
> >
> > Should this be combined with the check that a throwing operator new never
> > returns non-null? (r199452)
> >
> >
> > On Jan 21, 2014, at 22:10 , Ted Kremenek <kremenek at apple.com> wrote:
> >
> >> Author: kremenek
> >> Date: Wed Jan 22 00:10:28 2014
> >> New Revision: 199790
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=199790&view=rev
> >> Log:
> >> Add basic checking for returning null from functions/methods marked
> > 'returns_nonnull'.
> >>
> >> This involved making CheckReturnStackAddr into a static function, which
> >> is now called by a top-level return value checking routine called
> >> CheckReturnValExpr.
> >>
> >> Modified:
> >>   cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> >>   cfe/trunk/include/clang/Sema/Sema.h
> >>   cfe/trunk/lib/Sema/SemaChecking.cpp
> >>   cfe/trunk/lib/Sema/SemaStmt.cpp
> >>   cfe/trunk/test/Sema/nonnull.c
> >>   cfe/trunk/test/SemaObjC/nonnull.m
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140123/d035e78b/attachment.html>


More information about the cfe-commits mailing list