Displaying 5 results from an estimated 5 matches for "exists_and_isa".
2019 Apr 04
2
[RFC] Should we add isa_or_null<>?
...he existing "_or_null" varieties,
i.e., "cast_or_null" and "dyn_cast_or_null". They accept a null and
propagate it. In the "isa" case, it would accept a null and propagate it
as false.
>
> not_null_and_isa<T> would seem a better fit, or maybe exists_and_isa<T>.
>
> That said, I'm not sure sure we need a special API for this. Are
> expensive calls used in the way you describe really common?
>
I've only been looking at the ones involving method calls, but it's not too
common. Perhaps a dozen in clang/lib -- haven't r...
2019 Apr 04
2
[RFC] Should we add isa_or_null<>?
...ack,
> which may be null. isa<> is precondition check, so it "reads"
> differently to me. If I were to see:
>
> if (isa_or_null<T>(var)) {
> ...
> }
>
> I would think, "Ok, the body is fine if var is null."
>
> Instead:
>
> if (exists_and_isa<T>(var)) {
> ...
> }
>
> This tells me that the body expects a non-null value.
>
> > > That said, I'm not sure sure we need a special API for this. Are
> > > expensive calls used in the way you describe really common?
> >
> > I've only...
2019 Apr 04
2
[RFC] Should we add isa_or_null<>?
...>>> differently to me. If I were to see:
>>>
>>> if (isa_or_null<T>(var)) {
>>> ...
>>> }
>>>
>>> I would think, "Ok, the body is fine if var is null."
>>>
>>> Instead:
>>>
>>> if (exists_and_isa<T>(var)) {
>>> ...
>>> }
>>>
>>> This tells me that the body expects a non-null value.
>>>
>>> > > That said, I'm not sure sure we need a special API for this. Are
>>> > > expensive calls used in the way you d...
2019 Apr 05
2
[RFC] Should we add isa_or_null<>?
...;>>> if (isa_or_null<T>(var)) {
>>>>> ...
>>>>> }
>>>>>
>>>>> I would think, "Ok, the body is fine if var is null."
>>>>>
>>>>> Instead:
>>>>>
>>>>> if (exists_and_isa<T>(var)) {
>>>>> ...
>>>>> }
>>>>>
>>>>> This tells me that the body expects a non-null value.
>>>>>
>>>>> > > That said, I'm not sure sure we need a special API for this. Are
>>>&...
2019 Apr 04
4
[RFC] Should we add isa_or_null<>?
I'd like to propose adding `isa_or_null<>` to replace the following usage
pattern that's relatively common in conditionals:
var && isa<T>(var) =>> isa_or_null<T>(var)
And in particular when `var` is a method call which might be expensive,
e.g.:
X->foo() && isa<T>(X->foo()) =>> isa_or_null<T>(X->foo())
The