Changeset View
Changeset View
Standalone View
Standalone View
llvm/docs/ProgrammersManual.rst
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | ``dyn_cast<>``: | ||||
Note that the ``dyn_cast<>`` operator, like C++'s ``dynamic_cast<>`` or Java's | Note that the ``dyn_cast<>`` operator, like C++'s ``dynamic_cast<>`` or Java's | ||||
``instanceof`` operator, can be abused. In particular, you should not use big | ``instanceof`` operator, can be abused. In particular, you should not use big | ||||
chained ``if/then/else`` blocks to check for lots of different variants of | chained ``if/then/else`` blocks to check for lots of different variants of | ||||
classes. If you find yourself wanting to do this, it is much cleaner and more | classes. If you find yourself wanting to do this, it is much cleaner and more | ||||
efficient to use the ``InstVisitor`` class to dispatch over the instruction | efficient to use the ``InstVisitor`` class to dispatch over the instruction | ||||
type directly. | type directly. | ||||
``isa_and_nonnull<>``: | |||||
hubert.reinterpretcast: The name seems backwards. What does it mean to check "isa" on null? That question would not… | |||||
hintondaAuthorUnsubmitted Btw, there's been 4 naming comments so far, and each one is different. So, I hope we can come to a consensus soon. I originally thought isa_or_null was a good idea because it matches (cast|dyn_cast)_or_null, but since we're returning a bool and not a pointer, I no longer think that's a good name either. So, I'm open to whatever is decided. hintonda: Btw, there's been 4 naming comments so far, and each one is different. So, I hope we can come… | |||||
The ``isa_and_nonnull<>`` operator works just like the ``isa<>`` operator, | |||||
except that it allows for a null pointer as an argument (which it then | |||||
returns false). This can sometimes be useful, allowing you to combine several | |||||
null checks into one. | |||||
``cast_or_null<>``: | ``cast_or_null<>``: | ||||
The ``cast_or_null<>`` operator works just like the ``cast<>`` operator, | The ``cast_or_null<>`` operator works just like the ``cast<>`` operator, | ||||
except that it allows for a null pointer as an argument (which it then | except that it allows for a null pointer as an argument (which it then | ||||
propagates). This can sometimes be useful, allowing you to combine several | propagates). This can sometimes be useful, allowing you to combine several | ||||
null checks into one. | null checks into one. | ||||
``dyn_cast_or_null<>``: | ``dyn_cast_or_null<>``: | ||||
The ``dyn_cast_or_null<>`` operator works just like the ``dyn_cast<>`` | The ``dyn_cast_or_null<>`` operator works just like the ``dyn_cast<>`` | ||||
▲ Show 20 Lines • Show All 3,999 Lines • Show Last 20 Lines |
The name seems backwards. What does it mean to check "isa" on null? That question would not arise if the name was nonnull_and_isa.