<div dir="ltr"><div>I've added a patch, temporarily using the name Chris suggested. Please let me know what you think.<br></div><div><br></div><div><a href="https://reviews.llvm.org/D60291">https://reviews.llvm.org/D60291</a><br></div><div><br></div><div>thanks...</div><div>don</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 4, 2019 at 2:55 PM David Greene <<a href="mailto:dag@cray.com">dag@cray.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Don Hinton <<a href="mailto:hintonda@gmail.com" target="_blank">hintonda@gmail.com</a>> writes:<br>
<br>
> > if (isa_or_null<T>(var)) {<br>
> > ...<br>
> > }<br>
> ><br>
> > at least according to what "isa_or_null" conveys to me.<br>
><br>
> This is the same convention used by the existing "_or_null" varieties,<br>
> i.e., "cast_or_null" and "dyn_cast_or_null". They accept a null and<br>
> propagate it. In the "isa" case, it would accept a null and propagate<br>
> it as false.<br>
<br>
isa<> is very different from *cast<>. *cast<> gives you a pointer back,<br>
which may be null. isa<> is precondition check, so it "reads"<br>
differently to me. If I were to see:<br>
<br>
if (isa_or_null<T>(var)) {<br>
...<br>
}<br>
<br>
I would think, "Ok, the body is fine if var is null."<br>
<br>
Instead:<br>
<br>
if (exists_and_isa<T>(var)) {<br>
...<br>
}<br>
<br>
This tells me that the body expects a non-null value.<br>
<br>
> > That said, I'm not sure sure we need a special API for this. Are<br>
> > expensive calls used in the way you describe really common?<br>
><br>
> I've only been looking at the ones involving method calls, but it's<br>
> not too common. Perhaps a dozen in clang/lib -- haven't run it<br>
> against the rest of the code base.<br>
<br>
Thanks for checking. I don't have a strong opinion about the need<br>
either way, but I do care that the spelling is clear and intuitive.<br>
<br>
-David<br>
</blockquote></div>