From 2141705337989195b448e292955f08884babbcbd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Federico=20Lebr=C3=B3n?= Date: Thu, 10 Sep 2020 19:18:07 +0000 Subject: [PATCH] Fix operator!= for Dialects. Currently the global operator!=(bool, bool) is selected due to the implicit bool conversion operator. Since this is never the desired semantics, we give it a standard operator!= and make the bool conversion explicit. Depends On D86809 Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D86810 --- mlir/include/mlir/TableGen/Dialect.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mlir/include/mlir/TableGen/Dialect.h b/mlir/include/mlir/TableGen/Dialect.h index 623d614..ee86a2504 100644 --- a/mlir/include/mlir/TableGen/Dialect.h +++ b/mlir/include/mlir/TableGen/Dialect.h @@ -67,11 +67,13 @@ public: // underlying record. bool operator==(const Dialect &other) const; + bool operator!=(const Dialect &other) const { return !(*this == other); } + // Compares two dialects by comparing the names of the dialects. bool operator<(const Dialect &other) const; // Returns whether the dialect is defined. - operator bool() const { return def != nullptr; } + explicit operator bool() const { return def != nullptr; } private: const llvm::Record *def; -- 2.7.4