Skip to content

Commit 781f2c4

Browse files
committed
Mark isa/dyn_cast/cast/... member functions deprecated.
See https://mlir.llvm.org/deprecation
1 parent 694c444 commit 781f2c4

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

mlir/include/mlir/IR/Attributes.h

Lines changed: 7 additions & 2 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 isa<U>() instead")]]
5354
bool isa() const;
5455
template <typename... Tys>
56+
[[deprecated("Use isa_and_nonnull<U>() instead")]]
5557
bool isa_and_nonnull() const;
5658
template <typename U>
59+
[[deprecated("Use dyn_cast<U>() instead")]]
5760
U dyn_cast() const;
5861
template <typename U>
62+
[[deprecated("Use dyn_cast_or_null<U>() instead")]]
5963
U dyn_cast_or_null() const;
6064
template <typename U>
65+
[[deprecated("Use cast<U>() instead")]]
6166
U cast() const;
6267

6368
/// Return a unique identifier for the concrete attribute type. This is used
@@ -172,7 +177,7 @@ bool Attribute::isa() const {
172177

173178
template <typename... Tys>
174179
bool Attribute::isa_and_nonnull() const {
175-
return llvm::isa_and_present<Tys...>(*this);
180+
return llvm::isa_and_nonnull<Tys...>(*this);
176181
}
177182

178183
template <typename U>
@@ -182,7 +187,7 @@ U Attribute::dyn_cast() const {
182187

183188
template <typename U>
184189
U Attribute::dyn_cast_or_null() const {
185-
return llvm::dyn_cast_if_present<U>(*this);
190+
return llvm::dyn_cast_or_null<U>(*this);
186191
}
187192

188193
template <typename U>

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 isa<U>() instead")]]
8182
bool isa() const {
8283
return llvm::isa<U>(*this);
8384
}
8485
template <typename U>
86+
[[deprecated("Use dyn_cast<U>() instead")]]
8587
U dyn_cast() const {
8688
return llvm::dyn_cast<U>(*this);
8789
}
8890
template <typename U>
91+
[[deprecated("Use cast<U>() instead")]]
8992
U cast() const {
9093
return llvm::cast<U>(*this);
9194
}

mlir/include/mlir/IR/Types.h

Lines changed: 6 additions & 1 deletion
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 isa<U>() instead")]]
100101
bool isa() const;
101102
template <typename... Tys>
103+
[[deprecated("Use isa_and_nonnull<U>() instead")]]
102104
bool isa_and_nonnull() const;
103105
template <typename U>
106+
[[deprecated("Use dyn_cast<U>() instead")]]
104107
U dyn_cast() const;
105108
template <typename U>
109+
[[deprecated("Use dyn_cast_or_null<U>() instead")]]
106110
U dyn_cast_or_null() const;
107111
template <typename U>
112+
[[deprecated("Use cast<U>() instead")]]
108113
U cast() const;
109114

110115
/// Return a unique identifier for the concrete type. This is used to support
@@ -323,7 +328,7 @@ bool Type::isa() const {
323328

324329
template <typename... Tys>
325330
bool Type::isa_and_nonnull() const {
326-
return llvm::isa_and_present<Tys...>(*this);
331+
return llvm::isa_and_nonnull<Tys...>(*this);
327332
}
328333

329334
template <typename U>

mlir/include/mlir/IR/Value.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,25 @@ class Value {
9898
constexpr Value(detail::ValueImpl *impl = nullptr) : impl(impl) {}
9999

100100
template <typename U>
101+
[[deprecated("Use isa<U>() instead")]]
101102
bool isa() const {
102103
return llvm::isa<U>(*this);
103104
}
104105

105106
template <typename U>
107+
[[deprecated("Use dyn_cast<U>() instead")]]
106108
U dyn_cast() const {
107109
return llvm::dyn_cast<U>(*this);
108110
}
109111

110112
template <typename U>
113+
[[deprecated("Use dyn_cast_or_null<U>() instead")]]
111114
U dyn_cast_or_null() const {
112-
return llvm::dyn_cast_if_present<U>(*this);
115+
return llvm::dyn_cast_or_null<U>(*this);
113116
}
114117

115118
template <typename U>
119+
[[deprecated("Use cast<U>() instead")]]
116120
U cast() const {
117121
return llvm::cast<U>(*this);
118122
}

0 commit comments

Comments
 (0)