On 08/06/14 11:19, 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);
gcc/
* is-a.h (template<T, U> as_a_nullable <U *p>) New function.
Presumably the cases where we wanted to use as_a on a NULL pointer were
places were we can legitimately have a NULL pointer?
I guess since they'll be using as_a_nullable, they're effectively
documented as potentially being NULL and we can go back and look at them
at a future date.
OK.
jeff