[llvm-dev] [RFC] Should we add isa_or_null<>?
David Greene via llvm-dev
llvm-dev at lists.llvm.org
Mon Apr 8 11:33:43 PDT 2019
Bruno Ricci via llvm-dev <llvm-dev at lists.llvm.org> writes:
> On 07/04/2019 14:13, via llvm-dev wrote:
>> I have to say `not_null(v)` reads more like an assertion than a
>> predicate, in which case `isa<T>(not_null(v))` reads like it has the
>> exact same semantics that `isa<T>(v)` has currently—asserts that `v`
>> is not null.
>>
>> I don't dispute that you can *make* it have the desired semantics, it just won't *look* that way.
>>
>>
>>
>> maybe `isaT_or_null<Foo>(v)` ? Still looks awkward but maybe less naively misleading.
>>
>
> ... or we keep using "v && isa<T>(v)" (which is not even longer!), which is unambiguous for everyone.
> In the rare special case where the pattern "someExpensiveCall() && isa<T>(someExpensiveCall())" is used,
> just assign the result of "someExpensiveCall()" to a variable.
+1.
-David
More information about the llvm-dev
mailing list