diff --git a/llvm/include/llvm/Support/SMLoc.h b/llvm/include/llvm/Support/SMLoc.h --- a/llvm/include/llvm/Support/SMLoc.h +++ b/llvm/include/llvm/Support/SMLoc.h @@ -24,14 +24,14 @@ const char *Ptr = nullptr; public: - SMLoc() = default; + constexpr SMLoc() = default; - bool isValid() const { return Ptr != nullptr; } + constexpr bool isValid() const { return Ptr != nullptr; } - bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; } - bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; } + constexpr bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; } + constexpr bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; } - const char *getPointer() const { return Ptr; } + constexpr const char *getPointer() const { return Ptr; } static SMLoc getFromPointer(const char *Ptr) { SMLoc L; 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 @@ -356,9 +356,9 @@ std::optional n = {}) : name(name), loc(loc), id(id), num(n), kind(vk) { assert(!name.empty() && "null StringRef"); + assert(loc.isValid() && "null SMLoc"); assert(isWF(vk) && "unknown VarKind"); assert((!n || Var::isWF_Num(*n)) && "Var::Num is too large"); - // NOTE TO Wren: windows did not like loc.isValid constexpr } constexpr StringRef getName() const { return name; }