mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-08 21:37:35 +00:00
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
This commit is contained in:
parent
c82a4f49bc
commit
70a99e77f2
@ -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);
|
||||
|
@ -1,6 +1,6 @@
|
||||
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
|
||||
|
||||
; CHECK: ^0 = module: (path: ".\5Cf4folder\5Cabc.o", hash: (0, 0, 0, 0, 0))
|
||||
; CHECK: ^0 = module: (path: ".\\f4folder\\abc.o", hash: (0, 0, 0, 0, 0))
|
||||
|
||||
^0 = module: (path: ".\5Cf4folder\5Cabc.o", hash: (0, 0, 0, 0, 0))
|
||||
^0 = module: (path: ".\5Cf4folder\\abc.o", hash: (0, 0, 0, 0, 0))
|
||||
^1 = gv: (guid: 15822663052811949562, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 2)))
|
||||
|
@ -1,8 +1,7 @@
|
||||
|
||||
; Make sure that llvm-as/llvm-dis properly assemble/disassemble the
|
||||
; source_filename.
|
||||
|
||||
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
|
||||
|
||||
; CHECK: source_filename = "C:\5Cpath\5Cwith\5Cbackslashes\5Ctest.cc"
|
||||
source_filename = "C:\5Cpath\5Cwith\5Cbackslashes\5Ctest.cc"
|
||||
; CHECK: source_filename = "C:\\path\\with\\backslashes\\test.cc"
|
||||
source_filename = "C:\\path\\with\5Cbackslashes\\test.cc"
|
||||
|
@ -103,7 +103,7 @@ body: |
|
||||
name: test2
|
||||
body: |
|
||||
bb.0.entry:
|
||||
; CHECK: , @"\01Hello@$%09 \5C World,",
|
||||
; CHECK: , @"\01Hello@$%09 \\ World,",
|
||||
$rax = MOV64rm $rip, 1, _, @"\01Hello@$%09 \\ World,", _
|
||||
$eax = MOV32rm killed $rax, 1, _, 0, _
|
||||
RETQ $eax
|
||||
|
@ -109,7 +109,7 @@ TEST(StringExtrasTest, printEscapedString) {
|
||||
std::string str;
|
||||
raw_string_ostream OS(str);
|
||||
printEscapedString("ABCdef123&<>\\\"'\t", OS);
|
||||
EXPECT_EQ("ABCdef123&<>\\5C\\22'\\09", OS.str());
|
||||
EXPECT_EQ("ABCdef123&<>\\\\\\22'\\09", OS.str());
|
||||
}
|
||||
|
||||
TEST(StringExtrasTest, printHTMLEscaped) {
|
||||
|
@ -164,7 +164,7 @@ TEST_F(MDStringTest, PrintingComplex) {
|
||||
std::string Str;
|
||||
raw_string_ostream oss(Str);
|
||||
s->print(oss);
|
||||
EXPECT_STREQ("!\"\\00\\0A\\22\\5C\\FF\"", oss.str().c_str());
|
||||
EXPECT_STREQ("!\"\\00\\0A\\22\\\\\\FF\"", oss.str().c_str());
|
||||
}
|
||||
|
||||
typedef MetadataTest MDNodeTest;
|
||||
|
Loading…
x
Reference in New Issue
Block a user