Update the type printer for Diagnostic to automatically wrap the type with ''.
authorRiver Riddle <riverriddle@google.com>
Sat, 25 May 2019 02:22:00 +0000 (19:22 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 03:02:22 +0000 (20:02 -0700)
--

PiperOrigin-RevId: 249935489

mlir/lib/IR/Diagnostics.cpp
mlir/test/IR/invalid-ops.mlir
mlir/test/IR/invalid.mlir

index 6d7a24a..67e1405 100644 (file)
@@ -79,7 +79,7 @@ void DiagnosticArgument::print(raw_ostream &os) const {
     os << getAsString();
     break;
   case DiagnosticArgumentKind::Type:
-    os << getAsType();
+    os << '\'' << getAsType() << '\'';
     break;
   case DiagnosticArgumentKind::Unsigned:
     os << getAsUnsigned();
index 80c3787..2a47730 100644 (file)
@@ -34,7 +34,7 @@ func @constant() {
 
 func @constant_out_of_range() {
 ^bb:
-  %x = "std.constant"(){value: 100} : () -> i1 // expected-error {{requires attribute's type (i64) to match op's return type (i1)}}
+  %x = "std.constant"(){value: 100} : () -> i1 // expected-error {{requires attribute's type ('i64') to match op's return type ('i1')}}
   return
 }
 
@@ -42,7 +42,7 @@ func @constant_out_of_range() {
 
 func @constant_wrong_type() {
 ^bb:
-  %x = "std.constant"(){value: 10.} : () -> f32 // expected-error {{requires attribute's type (f64) to match op's return type (f32)}}
+  %x = "std.constant"(){value: 10.} : () -> f32 // expected-error {{requires attribute's type ('f64') to match op's return type ('f32')}}
   return
 }
 
index fef4119..6eb7f59 100644 (file)
@@ -451,7 +451,7 @@ func @dominance_failure() {
 
 func @return_type_mismatch() -> i32 {
   %0 = "foo"() : ()->f32
-  return %0 : f32  // expected-error {{type of return operand 0 (f32) doesn't match function result type (i32)}}
+  return %0 : f32  // expected-error {{type of return operand 0 ('f32') doesn't match function result type ('i32')}}
 }
 
 // -----