diff --git a/mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.h b/mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.h --- a/mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.h +++ b/mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.h @@ -114,7 +114,7 @@ /// Checks whether the variables bound/used by this spec are valid /// with respect to the given ranks. - bool isValid(Ranks const &ranks) const; + [[nodiscard]] bool isValid(Ranks const &ranks) const; void print(llvm::raw_ostream &os) const; void print(AsmPrinter &printer) const; @@ -224,7 +224,7 @@ /// respect to the given ranks. Note that null `DimExpr` is considered /// to be vacuously valid, and therefore calling `setExpr` invalidates /// the result of this predicate. - bool isValid(Ranks const &ranks) const; + [[nodiscard]] bool isValid(Ranks const &ranks) const; // TODO(wrengr): Use it or loose it. bool isFunctionOf(Var var) const; @@ -273,7 +273,7 @@ // // NOTE: Once we introduce "counting expressions" this will need // a more sophisticated implementation than `DimSpec::isValid` does. - bool isValid(Ranks const &ranks) const; + [[nodiscard]] bool isValid(Ranks const &ranks) const; // TODO(wrengr): Use it or loose it. bool isFunctionOf(Var var) const; @@ -297,7 +297,7 @@ // Checks for integrity of variable-binding structure. // This is already called by the ctor. - bool isWF() const; + [[nodiscard]] bool isWF() const; public: DimLvlMap(unsigned symRank, ArrayRef dimSpecs, diff --git a/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h b/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h --- a/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h +++ b/mlir/lib/Dialect/SparseTensor/IR/Detail/Var.h @@ -60,7 +60,7 @@ /// representation. enum class VarKind { Symbol = 1, Dimension = 0, Level = 2 }; -constexpr bool isWF(VarKind vk) { +[[nodiscard]] constexpr bool isWF(VarKind vk) { const auto vk_ = to_underlying(vk); return 0 <= vk_ && vk_ <= 2; } @@ -145,7 +145,7 @@ // // This must be public for `VarInfo` to use it (whereas we don't want // to expose the `impl` field via friendship). - static constexpr bool isWF_Num(Num n) { return n <= kMaxNum; } + [[nodiscard]] static constexpr bool isWF_Num(Num n) { return n <= kMaxNum; } protected: /// The underlying implementation of `Var`. Note that this must be kept @@ -297,10 +297,10 @@ constexpr unsigned getDimRank() const { return getRank(VarKind::Dimension); } constexpr unsigned getLvlRank() const { return getRank(VarKind::Level); } - constexpr bool isValid(Var var) const { + [[nodiscard]] constexpr bool isValid(Var var) const { return var.getNum() < getRank(var.getKind()); } - bool isValid(DimLvlExpr expr) const; + [[nodiscard]] bool isValid(DimLvlExpr expr) const; }; static_assert(IsZeroCostAbstraction);