forked from OSchip/llvm-project
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
This commit is contained in:
parent
910838f07d
commit
5c0369eceb
|
@ -50,10 +50,12 @@ struct format_provider<mlir::tblgen::Pattern::IdentifierLine> {
|
||||||
};
|
};
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
||||||
|
// Escape a string for use inside a C++ literal.
|
||||||
|
// E.g. foo"bar -> foo\x22bar.
|
||||||
static std::string escapeString(StringRef value) {
|
static std::string escapeString(StringRef value) {
|
||||||
std::string ret;
|
std::string ret;
|
||||||
llvm::raw_string_ostream os(ret);
|
llvm::raw_string_ostream os(ret);
|
||||||
llvm::printEscapedString(value, os);
|
os.write_escaped(value, /*use_hex_escapes=*/true);
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue