From 42de94f839f259950df7bb142e8f2bb388825a06 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Mon, 29 Jun 2020 09:56:40 +0200 Subject: [PATCH] [mlir] do not hardcode the name of the undefined function in the error message 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 | 3 ++- mlir/test/IR/invalid.mlir | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp index 6e6ad47..8df9937 100644 --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -1120,7 +1120,8 @@ static LogicalResult verify(ConstantOp &op) { auto fn = op.getParentOfType().lookupSymbol(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) diff --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir index f075215b..f025fdf 100644 --- a/mlir/test/IR/invalid.mlir +++ b/mlir/test/IR/invalid.mlir @@ -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 } -- 2.7.4