Skip to content

Commit 12f0332

Browse files
committed
[mlir] Mark isa/dyn_cast/cast/... member functions deprecated.
All users have been removed in fac349a and bd9fdce. Except for TypeSwitch, where the deprecation warning needs to be disabled until the functions are removed.
1 parent bd9fdce commit 12f0332

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

llvm/include/llvm/ADT/TypeSwitch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ template <typename DerivedT, typename T> class TypeSwitchBase {
7474
ValueT &&value,
7575
std::enable_if_t<is_detected<has_dyn_cast_t, ValueT, CastT>::value> * =
7676
nullptr) {
77+
// Silence warnings about MLIR's deprecated dyn_cast member functions.
78+
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH;
7779
return value.template dyn_cast<CastT>();
80+
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP;
7881
}
7982

8083
/// Attempt to dyn_cast the given `value` to `CastT`. This overload is

mlir/include/mlir/IR/Attributes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,19 @@ class Attribute {
5050
/// Casting utility functions. These are deprecated and will be removed,
5151
/// please prefer using the `llvm` namespace variants instead.
5252
template <typename... Tys>
53+
[[deprecated("Use mlir::isa<U>() instead")]]
5354
bool isa() const;
5455
template <typename... Tys>
56+
[[deprecated("Use mlir::isa_and_nonnull<U>() instead")]]
5557
bool isa_and_nonnull() const;
5658
template <typename U>
59+
[[deprecated("Use mlir::dyn_cast<U>() instead")]]
5760
U dyn_cast() const;
5861
template <typename U>
62+
[[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
5963
U dyn_cast_or_null() const;
6064
template <typename U>
65+
[[deprecated("Use mlir::cast<U>() instead")]]
6166
U cast() const;
6267

6368
/// Return a unique identifier for the concrete attribute type. This is used

mlir/include/mlir/IR/Location.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,17 @@ class Location {
7878

7979
/// Type casting utilities on the underlying location.
8080
template <typename U>
81+
[[deprecated("Use mlir::isa<U>() instead")]]
8182
bool isa() const {
8283
return llvm::isa<U>(*this);
8384
}
8485
template <typename U>
86+
[[deprecated("Use mlir::dyn_cast<U>() instead")]]
8587
U dyn_cast() const {
8688
return llvm::dyn_cast<U>(*this);
8789
}
8890
template <typename U>
91+
[[deprecated("Use mlir::cast<U>() instead")]]
8992
U cast() const {
9093
return llvm::cast<U>(*this);
9194
}

mlir/include/mlir/IR/Types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,19 @@ class Type {
9797
bool operator!() const { return impl == nullptr; }
9898

9999
template <typename... Tys>
100+
[[deprecated("Use mlir::isa<U>() instead")]]
100101
bool isa() const;
101102
template <typename... Tys>
103+
[[deprecated("Use mlir::isa_and_nonnull<U>() instead")]]
102104
bool isa_and_nonnull() const;
103105
template <typename U>
106+
[[deprecated("Use mlir::dyn_cast<U>() instead")]]
104107
U dyn_cast() const;
105108
template <typename U>
109+
[[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
106110
U dyn_cast_or_null() const;
107111
template <typename U>
112+
[[deprecated("Use mlir::cast<U>() instead")]]
108113
U cast() const;
109114

110115
/// Return a unique identifier for the concrete type. This is used to support

0 commit comments

Comments
 (0)