[all-commits] [llvm/llvm-project] a00a61: [mlir][IR] Improve error message when parsing inco...
Matthias Springer via All-commits
all-commits at lists.llvm.org
Wed Apr 9 08:50:09 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a00a61d59bf1c1f142c8e08b74a0f26991122f7a
https://github.com/llvm/llvm-project/commit/a00a61d59bf1c1f142c8e08b74a0f26991122f7a
Author: Matthias Springer <me at m-sp.org>
Date: 2025-04-09 (Wed, 09 Apr 2025)
Changed paths:
M mlir/include/mlir/IR/OpImplementation.h
M mlir/test/Dialect/EmitC/invalid_ops.mlir
M mlir/test/Dialect/LLVMIR/invalid.mlir
M mlir/test/Dialect/SparseTensor/invalid.mlir
M mlir/test/Dialect/Tensor/invalid.mlir
M mlir/test/Dialect/Vector/invalid.mlir
M mlir/test/Target/LLVMIR/llvmir-invalid.mlir
M mlir/test/mlir-tblgen/attr-or-type-format.mlir
Log Message:
-----------
[mlir][IR] Improve error message when parsing incorrect type (#134984)
Improve error messages when parsing an incorrect type.
Before:
```
invalid kind of type specified
```
After:
```
invalid kind of type specified: expected builtin.tensor, but found 'tensor<*xi32>'
```
This error message is produced when a certain operand/result type is
expected according to an op's TableGen definition, but a different type
is parsed. Type constraints (which may have nice error messages) are
checked after parsing a type. If an incorrect type is parsed, we never
get to the point of printing type constraint error messages. This may
discourage users from specifying C++ classes with type constraints.
(Explicitly specifying C++ classes is beneficial because the
auto-generated C++ code will have richer type information; explicit
casts are unnecessary, etc.) See #134981 for an example where specifying
additional type information with type constraints (e.g.,
`LLVM_AnyVector`) lead to worse error messages.
Note: In order to generate a better error message, the parser must
retrieve a type's name from the C++ class. TableGen-generated type
classes always have a `name` field, but hand-written C++ type classes
may not. The `HasStaticName` template was copied from
`DialectImplementation.h` (`HasStaticDialectName`).
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list