This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix printing of EmitC attrs/types with escape characters
ClosedPublic

Authored by simon-camp on Sep 2 2021, 2:58 AM.

Details

Summary

Attributes and types were not escaped when printing.

Diff Detail

Event Timeline

simon-camp created this revision.Sep 2 2021, 2:58 AM
simon-camp requested review of this revision.Sep 2 2021, 2:58 AM
simon-camp updated this revision to Diff 370215.Sep 2 2021, 3:06 AM

Updating D109143: [mlir] Fix printing of EmitC attrs/types with escape characters

Could we have a test showing them all the way to C/C++? And is there only subset of characters supported to make the result still legal C/C++ but that's only checked in emitter?

I will add tests for the emitter now that it has landed, as well as a verifier for the opaque type to check whether it's a valid C identifier.

I will add tests for the emitter now that it has landed, as well as a verifier for the opaque type to check whether it's a valid C identifier.

SG, just to be clear, I'm waiting for those and then we can review them all together

Add tests for the CPP target.

simon-camp added a comment.EditedSep 13 2021, 3:17 AM

Sorry for the delay, I got distracted by other work :)

I additonally changed the type tests to use the template_args attribute because calling a function with a type is not valid C code (i.e. f(int) is not a valid function call).

Regarding the opaque type verifier, I'd suggest to do it in a follow up.

jpienaar accepted this revision.Sep 13 2021, 9:42 AM

Looks good thanks

mlir/test/Dialect/EmitC/attrs.mlir
7

Could you add a comment here explaining this test a bit more?

This revision is now accepted and ready to land.Sep 13 2021, 9:42 AM
marbre accepted this revision.Sep 15 2021, 11:12 AM
This revision was automatically updated to reflect the committed changes.