Skip to content

Commit 5c0369e

Browse files
matthiaskrammMogball
authored andcommitted
Fix escaping in RewriterGen.cpp.
When we escape strings for C++, make sure we use C++ escape sequences. (In particular, \x22 instead of \22) Reviewed By: Mogball Differential Revision: https://reviews.llvm.org/D112269
1 parent 910838f commit 5c0369e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mlir/tools/mlir-tblgen/RewriterGen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ struct format_provider<mlir::tblgen::Pattern::IdentifierLine> {
5050
};
5151
} // end namespace llvm
5252

53+
// Escape a string for use inside a C++ literal.
54+
// E.g. foo"bar -> foo\x22bar.
5355
static std::string escapeString(StringRef value) {
5456
std::string ret;
5557
llvm::raw_string_ostream os(ret);
56-
llvm::printEscapedString(value, os);
58+
os.write_escaped(value, /*use_hex_escapes=*/true);
5759
return os.str();
5860
}
5961

0 commit comments

Comments
 (0)