diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 9ce6eea4259c..617e6b29254b 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -50,10 +50,12 @@ struct format_provider { }; } // end namespace llvm +// Escape a string for use inside a C++ literal. +// E.g. foo"bar -> foo\x22bar. static std::string escapeString(StringRef value) { std::string ret; llvm::raw_string_ostream os(ret); - llvm::printEscapedString(value, os); + os.write_escaped(value, /*use_hex_escapes=*/true); return os.str(); }