[Mlir-commits] [mlir] d867be5 - Allow Dialects to be initialized via nullptr.
Mehdi Amini
llvmlistbot at llvm.org
Thu Sep 10 12:15:04 PDT 2020
Author: Federico Lebrón
Date: 2020-09-10T19:14:53Z
New Revision: d867be5de389f18cf3c1a61c8b9cbf8bfda8fe28
URL: https://github.com/llvm/llvm-project/commit/d867be5de389f18cf3c1a61c8b9cbf8bfda8fe28
DIFF: https://github.com/llvm/llvm-project/commit/d867be5de389f18cf3c1a61c8b9cbf8bfda8fe28.diff
LOG: 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
Added:
Modified:
mlir/lib/TableGen/Dialect.cpp
Removed:
################################################################################
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);
}
More information about the Mlir-commits
mailing list