diff options
author | Reid Kleckner <rnk@google.com> | 2019-10-10 18:31:57 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2019-10-10 18:31:57 +0000 |
commit | 67d440b949d6fefef53deec1e585435ffb33f4f8 (patch) | |
tree | 0df3c5909e591b098da10cfe59dc1fb0953efa02 /llvm/lib/Support/StringExtras.cpp | |
parent | e9529a942a76a9247fb94613c7d5ae482fe22adf (diff) | |
download | bcm5719-llvm-67d440b949d6fefef53deec1e585435ffb33f4f8.tar.gz bcm5719-llvm-67d440b949d6fefef53deec1e585435ffb33f4f8.zip |
Print quoted backslashes in LLVM IR as \\ instead of \5C
This improves readability of Windows path string literals in LLVM IR.
The LLVM assembler has supported \\ in IR strings for a long time, but
the lexer doesn't tolerate escaped quotes, so they have to be printed as
\22 for now.
llvm-svn: 374415
Diffstat (limited to 'llvm/lib/Support/StringExtras.cpp')
-rw-r--r-- | llvm/lib/Support/StringExtras.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Support/StringExtras.cpp b/llvm/lib/Support/StringExtras.cpp index bf28b2be565..af8dd463e12 100644 --- a/llvm/lib/Support/StringExtras.cpp +++ b/llvm/lib/Support/StringExtras.cpp @@ -60,7 +60,9 @@ void llvm::SplitString(StringRef Source, void llvm::printEscapedString(StringRef Name, raw_ostream &Out) { for (unsigned i = 0, e = Name.size(); i != e; ++i) { unsigned char C = Name[i]; - if (isPrint(C) && C != '\\' && C != '"') + if (C == '\\') + Out << '\\' << C; + else if (isPrint(C) && C != '"') Out << C; else Out << '\\' << hexdigit(C >> 4) << hexdigit(C & 0x0F); |