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.
Details
Details
Summary
Diff Detail
Diff Detail
Event Timeline
Herald added subscribers: dcaballe, cota, teijeong and 14 others. · View Herald TranscriptJul 4 2021, 6:31 AM
This revision is now accepted and ready to land.Jul 4 2021, 8:04 PM
Closed by commit rGa96911c49bff: [mlir] Escape strings of opaque attributes (authored by zero9178). · Explain WhyJul 5 2021, 3:13 AM
This revision was automatically updated to reflect the committed changes.