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
This commit is contained in:
Federico Lebrón 2020-09-10 19:14:42 +00:00 committed by Mehdi Amini
parent a39423084c
commit d867be5de3
1 changed files with 2 additions and 0 deletions

View File

@ -16,6 +16,8 @@
using namespace mlir; using namespace mlir;
using namespace mlir::tblgen; using namespace mlir::tblgen;
Dialect::Dialect(const llvm::Record *def) : def(def) { Dialect::Dialect(const llvm::Record *def) : def(def) {
if (def == nullptr)
return;
for (StringRef dialect : def->getValueAsListOfStrings("dependentDialects")) for (StringRef dialect : def->getValueAsListOfStrings("dependentDialects"))
dependentDialects.push_back(dialect); dependentDialects.push_back(dialect);
} }