From d867be5de389f18cf3c1a61c8b9cbf8bfda8fe28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Lebr=C3=B3n?= Date: Thu, 10 Sep 2020 19:14:42 +0000 Subject: Allow Dialects to be initialized via nullptr. This allows Dialect to follow the MLIR style of nullable objects, and in fact is expected by `Dialect::operator bool() const` which already tests whether `def == nullptr`. This just wasn't a reachable situation, because the constructor was dereferencing the pointer unconditionally. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D86807 --- mlir/lib/TableGen/Dialect.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mlir/lib/TableGen/Dialect.cpp') diff --git a/mlir/lib/TableGen/Dialect.cpp b/mlir/lib/TableGen/Dialect.cpp index 2b5f7e534ecc..c17180c20483 100644 --- a/mlir/lib/TableGen/Dialect.cpp +++ b/mlir/lib/TableGen/Dialect.cpp @@ -16,6 +16,8 @@ using namespace mlir; using namespace mlir::tblgen; Dialect::Dialect(const llvm::Record *def) : def(def) { + if (def == nullptr) + return; for (StringRef dialect : def->getValueAsListOfStrings("dependentDialects")) dependentDialects.push_back(dialect); } -- cgit v1.2.3