[Mlir-commits] [mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (PR #89238)

Christian Sigg llvmlistbot at llvm.org
Thu Apr 18 07:18:59 PDT 2024


https://github.com/chsigg created https://github.com/llvm/llvm-project/pull/89238

See https://mlir.llvm.org/deprecation

>From 781f2c4d0d0ced43f0516eabd7edf60162624076 Mon Sep 17 00:00:00 2001
From: Christian Sigg <csigg at google.com>
Date: Thu, 18 Apr 2024 16:17:55 +0200
Subject: [PATCH] Mark `isa/dyn_cast/cast/...` member functions deprecated.

See https://mlir.llvm.org/deprecation
---
 mlir/include/mlir/IR/Attributes.h | 9 +++++++--
 mlir/include/mlir/IR/Location.h   | 3 +++
 mlir/include/mlir/IR/Types.h      | 7 ++++++-
 mlir/include/mlir/IR/Value.h      | 6 +++++-
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h
index cc0cee6a31183c..509a67f61c7a6a 100644
--- a/mlir/include/mlir/IR/Attributes.h
+++ b/mlir/include/mlir/IR/Attributes.h
@@ -50,14 +50,19 @@ class Attribute {
   /// Casting utility functions. These are deprecated and will be removed,
   /// please prefer using the `llvm` namespace variants instead.
   template <typename... Tys>
+  [[deprecated("Use isa<U>() instead")]]
   bool isa() const;
   template <typename... Tys>
+  [[deprecated("Use isa_and_nonnull<U>() instead")]]
   bool isa_and_nonnull() const;
   template <typename U>
+  [[deprecated("Use dyn_cast<U>() instead")]]
   U dyn_cast() const;
   template <typename U>
+  [[deprecated("Use dyn_cast_or_null<U>() instead")]]
   U dyn_cast_or_null() const;
   template <typename U>
+  [[deprecated("Use cast<U>() instead")]]
   U cast() const;
 
   /// Return a unique identifier for the concrete attribute type. This is used
@@ -172,7 +177,7 @@ bool Attribute::isa() const {
 
 template <typename... Tys>
 bool Attribute::isa_and_nonnull() const {
-  return llvm::isa_and_present<Tys...>(*this);
+  return llvm::isa_and_nonnull<Tys...>(*this);
 }
 
 template <typename U>
@@ -182,7 +187,7 @@ U Attribute::dyn_cast() const {
 
 template <typename U>
 U Attribute::dyn_cast_or_null() const {
-  return llvm::dyn_cast_if_present<U>(*this);
+  return llvm::dyn_cast_or_null<U>(*this);
 }
 
 template <typename U>
diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h
index d4268e804f4f7a..b7afb160743825 100644
--- a/mlir/include/mlir/IR/Location.h
+++ b/mlir/include/mlir/IR/Location.h
@@ -78,14 +78,17 @@ class Location {
 
   /// Type casting utilities on the underlying location.
   template <typename U>
+  [[deprecated("Use isa<U>() instead")]]
   bool isa() const {
     return llvm::isa<U>(*this);
   }
   template <typename U>
+  [[deprecated("Use dyn_cast<U>() instead")]]
   U dyn_cast() const {
     return llvm::dyn_cast<U>(*this);
   }
   template <typename U>
+  [[deprecated("Use cast<U>() instead")]]
   U cast() const {
     return llvm::cast<U>(*this);
   }
diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index a89e13b625bf40..69ef27018bc1b4 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -97,14 +97,19 @@ class Type {
   bool operator!() const { return impl == nullptr; }
 
   template <typename... Tys>
+  [[deprecated("Use isa<U>() instead")]]
   bool isa() const;
   template <typename... Tys>
+  [[deprecated("Use isa_and_nonnull<U>() instead")]]
   bool isa_and_nonnull() const;
   template <typename U>
+  [[deprecated("Use dyn_cast<U>() instead")]]
   U dyn_cast() const;
   template <typename U>
+  [[deprecated("Use dyn_cast_or_null<U>() instead")]]
   U dyn_cast_or_null() const;
   template <typename U>
+  [[deprecated("Use cast<U>() instead")]]
   U cast() const;
 
   /// Return a unique identifier for the concrete type. This is used to support
@@ -323,7 +328,7 @@ bool Type::isa() const {
 
 template <typename... Tys>
 bool Type::isa_and_nonnull() const {
-  return llvm::isa_and_present<Tys...>(*this);
+  return llvm::isa_and_nonnull<Tys...>(*this);
 }
 
 template <typename U>
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index a74d0faa1dfc4b..cdbc6cc374368c 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -98,21 +98,25 @@ class Value {
   constexpr Value(detail::ValueImpl *impl = nullptr) : impl(impl) {}
 
   template <typename U>
+  [[deprecated("Use isa<U>() instead")]]
   bool isa() const {
     return llvm::isa<U>(*this);
   }
 
   template <typename U>
+  [[deprecated("Use dyn_cast<U>() instead")]]
   U dyn_cast() const {
     return llvm::dyn_cast<U>(*this);
   }
 
   template <typename U>
+  [[deprecated("Use dyn_cast_or_null<U>() instead")]]
   U dyn_cast_or_null() const {
-    return llvm::dyn_cast_if_present<U>(*this);
+    return llvm::dyn_cast_or_null<U>(*this);
   }
 
   template <typename U>
+  [[deprecated("Use cast<U>() instead")]]
   U cast() const {
     return llvm::cast<U>(*this);
   }



More information about the Mlir-commits mailing list