[all-commits] [llvm/llvm-project] aa9ae7: [mlir][ODS] Verify type constraint in `TypeAttrOf`

Markus Böck via All-commits all-commits at lists.llvm.org
Fri Apr 7 03:31:04 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: aa9ae76cac0443b7d70b27ae2c0bf9cf92f344d3
      https://github.com/llvm/llvm-project/commit/aa9ae76cac0443b7d70b27ae2c0bf9cf92f344d3
  Author: Markus Böck <markus.boeck02 at gmail.com>
  Date:   2023-04-07 (Fri, 07 Apr 2023)

  Changed paths:
    M mlir/include/mlir/IR/OpBase.td
    M mlir/test/IR/attribute.mlir
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/test/mlir-tblgen/op-attribute.td

  Log Message:
  -----------
  [mlir][ODS] Verify type constraint in `TypeAttrOf`

The current implementation does not verify the type constraint, meaning that any type that happens to be of the same C++ type would pass the verifier.
E.g. a `TypeAttrOf<I64>` would happily accept a `i32` since both satisfy `isa<IntegerType>()`.

This patch fixes that by adding an optional type predicate parameter to `TypeAttrBase` that the type within `TypeAttr` has to satisfy. `TypeAttrOf` then simply passes the predicate of its type parameter as argument.

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




More information about the All-commits mailing list