[mlir] Make ShapedTypeComponents contructible from ShapeAdaptor
authorChia-hung Duan <chiahungduan@google.com>
Tue, 8 Mar 2022 20:31:06 +0000 (20:31 +0000)
committerChia-hung Duan <chiahungduan@google.com>
Wed, 9 Mar 2022 03:35:24 +0000 (03:35 +0000)
commitfcd4ee52cd6dc80a8ae4b7af68d13a37fb761cfe
treefdb1e4da4660a97b09f0e02dd36b6f94ea98cbe6
parent2b0ec7ca44ea227665f25b7dc3a3c097f16673cb
[mlir] Make ShapedTypeComponents contructible from ShapeAdaptor

ValueShapeRange::getShape() returns ShapeAdaptor rather than ShapedType
and ShapeAdaptor allows implicit conversion to bool. It ends up that
ShapedTypeComponents can be constructed with ShapeAdaptor incorrectly.
The reason is that the type trait
  std::is_constructible<ShapeStorageT, Arg>::value
is fulfilled because ShapeAdaptor can be converted to bool and it can be
used to construct ShapeStorageT. In the end, we won't give any warning
or error message when doing things like
  inferredReturnShapes.emplace_back(valueShapeRange.getShape(0));

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D120845
mlir/include/mlir/Interfaces/InferTypeOpInterface.h