[all-commits] [llvm/llvm-project] a96911: [mlir] Escape strings of opaque attributes

zero9178 via All-commits all-commits at lists.llvm.org
Mon Jul 5 03:14:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a96911c49bff75b22e980b87ac7375c62f671d15
      https://github.com/llvm/llvm-project/commit/a96911c49bff75b22e980b87ac7375c62f671d15
  Author: Markus Böck <markus.boeck02 at gmail.com>
  Date:   2021-07-05 (Mon, 05 Jul 2021)

  Changed paths:
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/test/IR/parser.mlir

  Log Message:
  -----------
  [mlir] Escape strings of opaque attributes

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.

Differential Revision: https://reviews.llvm.org/D105405




More information about the All-commits mailing list