[mlir] do not hardcode the name of the undefined function in the error message
authorAlex Zinenko <zinenko@google.com>
Mon, 29 Jun 2020 07:56:40 +0000 (09:56 +0200)
committerAlex Zinenko <zinenko@google.com>
Mon, 29 Jun 2020 08:05:06 +0000 (10:05 +0200)
The error message in the `std.constant` verifier for function-typed constants
had the name of the undefined function hardcoded to `bar`. Report the actual
name instead.

Differential Revision: https://reviews.llvm.org/D82666

mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/test/IR/invalid.mlir

index 6e6ad47..8df9937 100644 (file)
@@ -1120,7 +1120,8 @@ static LogicalResult verify(ConstantOp &op) {
     auto fn =
         op.getParentOfType<ModuleOp>().lookupSymbol<FuncOp>(fnAttr.getValue());
     if (!fn)
-      return op.emitOpError("reference to undefined function 'bar'");
+      return op.emitOpError()
+             << "reference to undefined function '" << fnAttr.getValue() << "'";
 
     // Check that the referenced function has the correct type.
     if (fn.getType() != type)
index f075215..f025fdf 100644 (file)
@@ -513,7 +513,7 @@ func @foo() {
 
 func @undefined_function() {
 ^bb0:
-  %x = constant @bar : (i32) -> ()  // expected-error {{reference to undefined function 'bar'}}
+  %x = constant @qux : (i32) -> ()  // expected-error {{reference to undefined function 'qux'}}
   return
 }