[llvm] [NFC][LLVM] Document and adopt variadic `isa` in a few places (PR #136869)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 10:50:18 PST 2025
https://github.com/jurahul updated https://github.com/llvm/llvm-project/pull/136869
>From 057a63484d47dc5dfa00fc7ee51349b117b2af4f Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 10 Dec 2025 10:48:41 -0800
Subject: [PATCH] [LLVM] Document variadic `isa`.
---
llvm/docs/ProgrammersManual.rst | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
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