Page MenuHomePhabricator

[mlir] Escape strings of opaque attributes
ClosedPublic

Authored by zero9178 on Jul 4 2021, 6:31 AM.

Details

Summary

Opaque attributes that currently contain string literals can't currently be properly roundtripped as they are not printed as escaped strings. This leads to incorrect tokens being generated and the parser to almost certainly fail. This patch simply uses llvm::printEscapedString from LLVM. It escapes all non printable characters and quotes to \xx hex literals, and backslashes to two backslashes. This syntax is supported by MLIRs Lexer as well. The same function is also currently in use for the same purpose in printSymbolReference, printAttribute for StringAttr and many more in AsmPrinter.cpp.

Diff Detail

Event Timeline

zero9178 created this revision.Jul 4 2021, 6:31 AM
zero9178 requested review of this revision.Jul 4 2021, 6:31 AM
mehdi_amini accepted this revision.Jul 4 2021, 8:04 PM
This revision is now accepted and ready to land.Jul 4 2021, 8:04 PM
This revision was automatically updated to reflect the committed changes.