[llvm] [ADT] Deprecate PointerUnion::{is,get} (NFC) (PR #122623)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 12 12:03:47 PST 2025
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/122623
>From b8b015784f0606700055631286f90a3a34a5c8c6 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 11 Jan 2025 16:37:45 -0800
Subject: [PATCH 1/2] [ADT] Deprecate PointerUnion::{is,get} (NFC)
PointerUnion::{is,get} have been soft deprecated in PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa<T>, cast<T> and the llvm::dyn_cast<T>
This patch actually deprecates them with LLVM_DEPRECATED.
I'm not touching PointerUnion::dyn_cast for now because we have not
migrated away from it yet.
---
llvm/include/llvm/ADT/PointerUnion.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
index 7d4ed02b622626..ac733066a0ac82 100644
--- a/llvm/include/llvm/ADT/PointerUnion.h
+++ b/llvm/include/llvm/ADT/PointerUnion.h
@@ -147,12 +147,18 @@ class PointerUnion
// isa<T>, cast<T> and the llvm::dyn_cast<T>
/// Test if the Union currently holds the type matching T.
- template <typename T> inline bool is() const { return isa<T>(*this); }
+ template <typename T>
+ LLVM_DEPRECATED("Use isa instead", "isa")
+ inline bool is() const {
+ return isa<T>(*this);
+ }
/// Returns the value of the specified pointer type.
///
/// If the specified pointer type is incorrect, assert.
- template <typename T> inline T get() const {
+ template <typename T>
+ LLVM_DEPRECATED("Use cast instead", "cast")
+ inline T get() const {
assert(isa<T>(*this) && "Invalid accessor called");
return cast<T>(*this);
}
>From aec8e1bc16459532a14874c490a17f365c795231 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 12 Jan 2025 11:36:28 -0800
Subject: [PATCH 2/2] Address comments.
---
llvm/include/llvm/ADT/PointerUnion.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
index ac733066a0ac82..cdbd76d7f505be 100644
--- a/llvm/include/llvm/ADT/PointerUnion.h
+++ b/llvm/include/llvm/ADT/PointerUnion.h
@@ -148,7 +148,7 @@ class PointerUnion
/// Test if the Union currently holds the type matching T.
template <typename T>
- LLVM_DEPRECATED("Use isa instead", "isa")
+ [[deprecated("Use isa instead")]]
inline bool is() const {
return isa<T>(*this);
}
@@ -157,7 +157,7 @@ class PointerUnion
///
/// If the specified pointer type is incorrect, assert.
template <typename T>
- LLVM_DEPRECATED("Use cast instead", "cast")
+ [[deprecated("Use cast instead")]]
inline T get() const {
assert(isa<T>(*this) && "Invalid accessor called");
return cast<T>(*this);
More information about the llvm-commits
mailing list