[llvm] e61c2d4 - [NFC][LLVM] Document variadic `isa` (#136869)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 13:20:02 PST 2025
Author: Rahul Joshi
Date: 2025-12-10T13:19:59-08:00
New Revision: e61c2d40b615d72b3ab98ea22c48475502962f8c
URL: https://github.com/llvm/llvm-project/commit/e61c2d40b615d72b3ab98ea22c48475502962f8c
DIFF: https://github.com/llvm/llvm-project/commit/e61c2d40b615d72b3ab98ea22c48475502962f8c.diff
LOG: [NFC][LLVM] Document variadic `isa` (#136869)
Add documentation for variadic `isa<>` in the LLVM Programmer's Manual.
Added:
Modified:
llvm/docs/ProgrammersManual.rst
Removed:
################################################################################
diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index 270a635e0d153..51a813eadee73 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -115,7 +115,9 @@ rarely have to include this file directly).
The ``isa<>`` operator works exactly like the Java "``instanceof``" operator.
It returns ``true`` or ``false`` depending on whether a reference or pointer points to
an instance of the specified class. This can be very useful for constraint
- checking of various sorts (example below).
+ checking of various sorts (example below). It's a variadic operator, so you
+ can specify more than one class to check if the reference or pointer points
+ to an instance of one of the classes specified.
``cast<>``:
The ``cast<>`` operator is a "checked cast" operation. It converts a pointer
@@ -131,7 +133,11 @@ rarely have to include this file directly).
if (isa<Constant>(V) || isa<Argument>(V) || isa<GlobalValue>(V))
return true;
- // Otherwise, it must be an instruction...
+ // Alternate, more compact form.
+ if (isa<Constant, Argument, GlobalValue>(V))
+ return true;
+
+ // Otherwise, it must be an instruction.
return !L->contains(cast<Instruction>(V)->getParent());
}
@@ -167,8 +173,9 @@ rarely have to include this file directly).
``isa_and_present<>``:
The ``isa_and_present<>`` 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.
+ returns ``false``). This can sometimes be useful, allowing you to combine
+ several null checks into one. Similar to ``isa<>`` operator, you can specify
+ more than one class to check.
``cast_if_present<>``:
The ``cast_if_present<>`` operator works just like the ``cast<>`` operator,
More information about the llvm-commits
mailing list