Verify that ModuleOps only contain dialect specific attributes.

ModuleOp has no expected operations, so only dialect-specific attributes are valid.

PiperOrigin-RevId: 269020062
This commit is contained in:
River Riddle 2019-09-13 18:18:22 -07:00 committed by TensorFlower Gardener
parent 4951f6fd7d
commit a47914d89e

View File

@ -80,6 +80,14 @@ LogicalResult ModuleOp::verify() {
if (body->getNumArguments() != 0)
return emitOpError("expected body to have no arguments");
// Check that none of the attributes are non-dialect attributes.
for (auto attr : getOperation()->getAttrList().getAttrs()) {
if (!attr.first.strref().contains('.'))
return emitOpError(
"can only contain dialect-specific attributes, found: 1")
<< attr.first << "'";
}
return success();
}