Fix operator!= for Dialects.
authorFederico Lebrón <flebron@google.com>
Thu, 10 Sep 2020 19:18:07 +0000 (19:18 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Thu, 10 Sep 2020 19:18:24 +0000 (19:18 +0000)
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

index 623d614..ee86a25 100644 (file)
@@ -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;