From 96eb38418bcc2e11f9b991629231451dc8c19555 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sun, 5 Apr 2020 03:01:21 +0000 Subject: [PATCH] Make the AsmPrinter print "<>" instead of crashing on null types Even if this indicates in general a problem at call sites, the printer is used for debugging and avoiding crashing is friendlier for example when used in diagnostics or other printer. Differential Revision: https://reviews.llvm.org/D77481 --- mlir/lib/IR/AsmPrinter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index bc680cf..987c6b9 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1490,6 +1490,11 @@ void ModulePrinter::printDenseElementsAttr(DenseElementsAttr attr, } void ModulePrinter::printType(Type type) { + if (!type) { + os << "<>"; + return; + } + // Check for an alias for this type. if (state) { StringRef alias = state->getAliasState().getTypeAlias(type); -- 2.7.4