Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

@kazutakahirata kazutakahirata commented Jan 12, 2025

PointerUnion::{is,get} have been soft deprecated in PointerUnion.h:

// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa, cast and the llvm::dyn_cast

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.

@llvmbot
Copy link
Member

llvmbot commented Jan 12, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/122623.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/PointerUnion.h (+8-2)
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);
   }

@kazutakahirata
Copy link
Contributor Author

This PR needs to be merged after #122622.

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.
@kazutakahirata kazutakahirata force-pushed the cleanup_001_PointerUnion_deprecate branch from 3bc27e2 to aec8e1b Compare January 12, 2025 20:03
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kazutakahirata kazutakahirata merged commit abba01a into llvm:main Jan 13, 2025
8 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_PointerUnion_deprecate branch January 13, 2025 19:37
kazutakahirata added a commit to kazutakahirata/llvm-project that referenced this pull request Jan 13, 2025
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.
AnthonyLatsis added a commit to AnthonyLatsis/llvm-project that referenced this pull request Apr 30, 2025
llvm#122623)"

This reverts commit abba01a.

We will address these deprecations later once all the other failures are
dealt with and Swift's release/6.2 starts converging. Right now they're
just getting in the way.
bnbarham added a commit to swiftlang/llvm-project that referenced this pull request Apr 30, 2025
[stable/20250402] Revert "[ADT] Deprecate PointerUnion::{is,get} (NFC) (llvm#122623)"
AnthonyLatsis added a commit to AnthonyLatsis/llvm-project that referenced this pull request May 28, 2025
This reverts commit abba01a.

We will address these deprecations later once all the other failures are
dealt with and Swift's release/6.2 starts converging. Right now they're
just getting in the way.
bnbarham added a commit to swiftlang/llvm-project that referenced this pull request May 30, 2025
[next] Revert "[ADT] Deprecate PointerUnion::{is,get} (NFC) (llvm#122623)"
AnthonyLatsis added a commit to swiftlang/swift that referenced this pull request Jul 29, 2025
AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Jul 30, 2025
AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Jul 30, 2025
[next] Revert "Revert "[ADT] Deprecate PointerUnion::{is,get} (NFC) (llvm#122623)""
AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Jul 30, 2025
AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Jul 30, 2025
[stable/21.x] Revert "Revert "[ADT] Deprecate PointerUnion::{is,get} (NFC) (llvm#122623)""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants