[llvm] abba01a - [ADT] Deprecate PointerUnion::{is, get} (NFC) (#122623)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 11:37:41 PST 2025


Author: Kazu Hirata
Date: 2025-01-13T11:37:37-08:00
New Revision: abba01adad5dfc54f781357d924c8021c9306615

URL: https://github.com/llvm/llvm-project/commit/abba01adad5dfc54f781357d924c8021c9306615
DIFF: https://github.com/llvm/llvm-project/commit/abba01adad5dfc54f781357d924c8021c9306615.diff

LOG: [ADT] Deprecate PointerUnion::{is,get} (NFC) (#122623)

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 [[deprecated]].

I'm not touching PointerUnion::dyn_cast for now because we have not
migrated away from it yet.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/PointerUnion.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
index 7d4ed02b622626..cdbd76d7f505be 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>
+  [[deprecated("Use isa instead")]]
+  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>
+  [[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