Skip to content

Commit 2a68213

Browse files
committed
[mlir][sparse] Adding nodiscard annotations to isWF/isValid predicates
Depends On D156001 Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D156007
1 parent fa4a304 commit 2a68213

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class DimLvlExpr {
114114

115115
/// Checks whether the variables bound/used by this spec are valid
116116
/// with respect to the given ranks.
117-
bool isValid(Ranks const &ranks) const;
117+
[[nodiscard]] bool isValid(Ranks const &ranks) const;
118118

119119
void print(llvm::raw_ostream &os) const;
120120
void print(AsmPrinter &printer) const;
@@ -224,7 +224,7 @@ class DimSpec final {
224224
/// respect to the given ranks. Note that null `DimExpr` is considered
225225
/// to be vacuously valid, and therefore calling `setExpr` invalidates
226226
/// the result of this predicate.
227-
bool isValid(Ranks const &ranks) const;
227+
[[nodiscard]] bool isValid(Ranks const &ranks) const;
228228

229229
// TODO(wrengr): Use it or loose it.
230230
bool isFunctionOf(Var var) const;
@@ -273,7 +273,7 @@ class LvlSpec final {
273273
//
274274
// NOTE: Once we introduce "counting expressions" this will need
275275
// a more sophisticated implementation than `DimSpec::isValid` does.
276-
bool isValid(Ranks const &ranks) const;
276+
[[nodiscard]] bool isValid(Ranks const &ranks) const;
277277

278278
// TODO(wrengr): Use it or loose it.
279279
bool isFunctionOf(Var var) const;
@@ -297,7 +297,7 @@ class DimLvlMap final {
297297

298298
// Checks for integrity of variable-binding structure.
299299
// This is already called by the ctor.
300-
bool isWF() const;
300+
[[nodiscard]] bool isWF() const;
301301

302302
public:
303303
DimLvlMap(unsigned symRank, ArrayRef<DimSpec> dimSpecs,

mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace ir_detail {
6060
/// representation.
6161
enum class VarKind { Symbol = 1, Dimension = 0, Level = 2 };
6262

63-
constexpr bool isWF(VarKind vk) {
63+
[[nodiscard]] constexpr bool isWF(VarKind vk) {
6464
const auto vk_ = to_underlying(vk);
6565
return 0 <= vk_ && vk_ <= 2;
6666
}
@@ -145,7 +145,7 @@ class Var {
145145
//
146146
// This must be public for `VarInfo` to use it (whereas we don't want
147147
// to expose the `impl` field via friendship).
148-
static constexpr bool isWF_Num(Num n) { return n <= kMaxNum; }
148+
[[nodiscard]] static constexpr bool isWF_Num(Num n) { return n <= kMaxNum; }
149149

150150
protected:
151151
/// The underlying implementation of `Var`. Note that this must be kept
@@ -297,10 +297,10 @@ class Ranks final {
297297
constexpr unsigned getDimRank() const { return getRank(VarKind::Dimension); }
298298
constexpr unsigned getLvlRank() const { return getRank(VarKind::Level); }
299299

300-
constexpr bool isValid(Var var) const {
300+
[[nodiscard]] constexpr bool isValid(Var var) const {
301301
return var.getNum() < getRank(var.getKind());
302302
}
303-
bool isValid(DimLvlExpr expr) const;
303+
[[nodiscard]] bool isValid(DimLvlExpr expr) const;
304304
};
305305
static_assert(IsZeroCostAbstraction<Ranks>);
306306

0 commit comments

Comments
 (0)