[Mlir-commits] [mlir] 96eb384 - Make the AsmPrinter print "<<NULL TYPE>>" instead of crashing on null types
    Mehdi Amini 
    llvmlistbot at llvm.org
       
    Sun Apr  5 11:36:36 PDT 2020
    
    
  
Author: Mehdi Amini
Date: 2020-04-05T18:36:18Z
New Revision: 96eb38418bcc2e11f9b991629231451dc8c19555
URL: https://github.com/llvm/llvm-project/commit/96eb38418bcc2e11f9b991629231451dc8c19555
DIFF: https://github.com/llvm/llvm-project/commit/96eb38418bcc2e11f9b991629231451dc8c19555.diff
LOG: Make the AsmPrinter print "<<NULL TYPE>>" 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
Added: 
    
Modified: 
    mlir/lib/IR/AsmPrinter.cpp
Removed: 
    
################################################################################
diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index bc680cfbc980..987c6b95586f 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 << "<<NULL TYPE>>";
+    return;
+  }
+
   // Check for an alias for this type.
   if (state) {
     StringRef alias = state->getAliasState().getTypeAlias(type);
        
    
    
More information about the Mlir-commits
mailing list