diff --git a/mlir/docs/Diagnostics.md b/mlir/docs/Diagnostics.md --- a/mlir/docs/Diagnostics.md +++ b/mlir/docs/Diagnostics.md @@ -108,7 +108,8 @@ ``` Operations attached to a diagnostic will be printed in generic form if the -severity level is `Error`, otherwise custom operation printers will be used. +severity level is `Error` or `Warning`, otherwise custom operation printers will +be used. ```c++ // `anotherOp` will be printed in generic form, // e.g. %3 = "arith.addf"(%arg4, %2) : (f32, f32) -> f32 diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -606,9 +606,9 @@ Custom verifiers should avoid printing operations using custom operation printers, because they require the printed operation (and sometimes its parent operation) to be verified first. In particular, when emitting diagnostics, -custom verifiers should use the `Error` severity level, which prints operations -in generic form by default, and avoid using lower severity levels (`Note`, -`Remark`, `Warning`). +custom verifiers should use the `Error` or `Warning` severity level, which print +operations in generic form by default, and avoid using lower severity levels +(`Note`, `Remark`). ### Declarative Assembly Format diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -127,7 +127,8 @@ DiagnosticSeverity severity) { flags.useLocalScope(); flags.elideLargeElementsAttrs(); - if (severity == DiagnosticSeverity::Error) + if (severity == DiagnosticSeverity::Error || + severity == DiagnosticSeverity::Warning) flags.printGenericOpForm(); return flags; }