Skip to content

Commit 6544c88

Browse files
jurahulgithub-actions[bot]
authored andcommitted
Automerge: [NFC][LLVM] Document variadic isa (#136869)
Add documentation for variadic `isa<>` in the LLVM Programmer's Manual.
2 parents de5f333 + e61c2d4 commit 6544c88

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

llvm/docs/ProgrammersManual.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ rarely have to include this file directly).
115115
The ``isa<>`` operator works exactly like the Java "``instanceof``" operator.
116116
It returns ``true`` or ``false`` depending on whether a reference or pointer points to
117117
an instance of the specified class. This can be very useful for constraint
118-
checking of various sorts (example below).
118+
checking of various sorts (example below). It's a variadic operator, so you
119+
can specify more than one class to check if the reference or pointer points
120+
to an instance of one of the classes specified.
119121

120122
``cast<>``:
121123
The ``cast<>`` operator is a "checked cast" operation. It converts a pointer
@@ -131,7 +133,11 @@ rarely have to include this file directly).
131133
if (isa<Constant>(V) || isa<Argument>(V) || isa<GlobalValue>(V))
132134
return true;
133135
134-
// Otherwise, it must be an instruction...
136+
// Alternate, more compact form.
137+
if (isa<Constant, Argument, GlobalValue>(V))
138+
return true;
139+
140+
// Otherwise, it must be an instruction.
135141
return !L->contains(cast<Instruction>(V)->getParent());
136142
}
137143

@@ -167,8 +173,9 @@ rarely have to include this file directly).
167173
``isa_and_present<>``:
168174
The ``isa_and_present<>`` operator works just like the ``isa<>`` operator,
169175
except that it allows for a null pointer as an argument (which it then
170-
returns ``false``). This can sometimes be useful, allowing you to combine several
171-
null checks into one.
176+
returns ``false``). This can sometimes be useful, allowing you to combine
177+
several null checks into one. Similar to ``isa<>`` operator, you can specify
178+
more than one class to check.
172179

173180
``cast_if_present<>``:
174181
The ``cast_if_present<>`` operator works just like the ``cast<>`` operator,

0 commit comments

Comments
 (0)