Make ops with StructAttr's actually verify `isa<TheStruct>`.
authorSean Silva <silvasean@google.com>
Tue, 28 Apr 2020 00:52:59 +0000 (17:52 -0700)
committerSean Silva <silvasean@google.com>
Tue, 28 Apr 2020 21:00:18 +0000 (14:00 -0700)
commit9c9f479a7dc10e16fd8032875a477827db4b3b77
treebd0a3d27152b42aadde8758892f9184f7793365b
parent751a554f25a9d8e92b378c870d0fb876db72d54a
Make ops with StructAttr's actually verify `isa<TheStruct>`.

Previously, they would only only verify `isa<DictionaryAttr>` on such attrs
which resulted in crashes down the line from code assuming that the
verifier was doing the more thorough check introduced in this patch.
The key change here is for StructAttr to use
`CPred<"$_self.isa<" # name # ">()">` instead of `isa<DictionaryAttr>`.

To test this, introduce struct attrs to the test dialect. Previously,
StructAttr was only being tested by unittests/, which didn't verify how
StructAttr interacted with ODS.

Differential Revision: https://reviews.llvm.org/D78975
mlir/include/mlir/IR/OpBase.td
mlir/test/IR/attribute.mlir
mlir/test/lib/Dialect/Test/CMakeLists.txt
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestDialect.h
mlir/test/lib/Dialect/Test/TestOps.td