Implementing logic to check if the emitc dialect constant Op is empty.
Reviewed By: marbre
Differential Revision: https://reviews.llvm.org/D147907
let results = (outs AnyType);
let hasFolder = 1;
- // TODO: Disallow empty constants.
let hasVerifier = 1;
}
if (getValueAttr().isa<emitc::OpaqueAttr>())
return success();
+ // Value must not be empty
+ StringAttr strAttr = getValueAttr().dyn_cast<StringAttr>();
+ if (strAttr && strAttr.getValue().empty())
+ return emitOpError() << "value must not be empty";
+
auto value = cast<TypedAttr>(getValueAttr());
Type type = getType();
if (!value.getType().isa<NoneType>() && type != value.getType())
// -----
+func.func @empty_constant() {
+ // expected-error @+1 {{'emitc.constant' op value must not be empty}}
+ %c0 = "emitc.constant"(){value = ""} : () -> i32
+ return
+}
+
+// -----
+
func.func @index_args_out_of_range_1() {
// expected-error @+1 {{'emitc.call' op index argument is out of range}}
emitc.call "test" () {args = [0 : index]} : () -> ()