On 08/13/14 04:07, Richard Biener wrote:
On Wed, Aug 13, 2014 at 12:01 PM, Martin Jambor <mjam...@suse.cz> wrote:
Hi,

On Wed, Aug 06, 2014 at 01:19:44PM -0400, David Malcolm wrote:
In many circumstances, is_a_helper <T>::test assumes that the pointer is
non-NULL, but sometimes you have a pointer of type T that can be NULL.

Earlier versions of this patch kit made numerous uses of the ternary
operator to handle nullable pointers e.g.:

   return insn ? as_a <rtx_insn *> (insn) : NULL;

but this was ugly.  Instead, introduce an as_a_nullable<T> variant that
adds a check for NULL, so the above can be written simply as:

   return as_a_nullable <rtx_insn *> (insn);

A tiny bikeshedding, disregard it if you don't like it: however, the
"nullable" part of the name suggests the pointer can be NULLed in the
process.  I think that variants of functions that survive NULL
arguments are traditionally called "safe" in gcc, so what about
"safe_as" (or safely_as)?

Ok, I resisted at first starting the bike-shedding but I agree on
the badness of "nullable" (what does that mean anyway?).
as_a_safe or safe_as_a both work for me.
Then let's go with that.

David, pick one of those and adjust accordingly. Hopefully the cases where you have to adjust aren't too many.

Adjusting any patch already approved with the name change is pre-approved.


jeff

Reply via email to