diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -907,6 +907,7 @@ const char *const getAttrName = R"( assert(index < {0} && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); return name.getRegisteredInfo()->getAttributeNames()[index]; )"; method->body() << formatv(getAttrName, attributes.size());