aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/TableGen/Dialect.cpp
diff options
context:
space:
mode:
authorFederico Lebrón <flebron@google.com>2020-09-10 19:14:42 +0000
committerMehdi Amini <joker.eph@gmail.com>2020-09-10 19:14:53 +0000
commitd867be5de389f18cf3c1a61c8b9cbf8bfda8fe28 (patch)
tree23094d1e8b764dcca8edc76e1bd72ddbfcd43cb9 /mlir/lib/TableGen/Dialect.cpp
parenta39423084cbbeb59e81002e741190dccf08b5c82 (diff)
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
Diffstat (limited to 'mlir/lib/TableGen/Dialect.cpp')
-rw-r--r--mlir/lib/TableGen/Dialect.cpp2
1 files changed, 2 insertions, 0 deletions
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);
}