[Mlir-commits] [mlir] [mlir][python] Improve sanitization of python names (PR #68801)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Oct 11 09:40:55 PDT 2023
================
@@ -616,6 +616,15 @@ def VariadicRegionOp : TestOp<"variadic_region"> {
// CHECK: def variadic_region(num_variadic, *, loc=None, ip=None)
// CHECK: return _get_op_result_or_op_results(VariadicRegionOp(num_variadic=num_variadic, loc=loc, ip=ip))
+// CHECK: @_ods_cext.register_operation(_Dialect)
+// CHECK: class WithSpecialCharactersOp(_ods_ir.OpView):
+// CHECK-LABEL: OPERATION_NAME = "test.123with- special.characters"
+def WithSpecialCharactersOp : TestOp<"123with- special.characters"> {
+}
+
+// CHECK: def _123with__special_characters(*, loc=None, ip=None)
----------------
JoelWee wrote:
We convert all non alnum to _. There's a '-' and a ' ' (space) which both get converted to '_' which is why there are two.
I'm not sure about the pros/cons of collapsing groups of '_'s. It feels clearer that we're sanitizing if we keep the string length roughly the same. It's best for users to avoid such weirdness so I don't think we need to do anything special other than make sure it compiles but happy to change my mind :)
https://github.com/llvm/llvm-project/pull/68801
More information about the Mlir-commits
mailing list