[llvm] r374415 - Print quoted backslashes in LLVM IR as \\ instead of \5C
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 11:31:57 PDT 2019
Author: rnk
Date: Thu Oct 10 11:31:57 2019
New Revision: 374415
URL: http://llvm.org/viewvc/llvm-project?rev=374415&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Support/StringExtras.cpp
llvm/trunk/test/Assembler/asm-path-writer.ll
llvm/trunk/test/Assembler/source-filename-backslash.ll
llvm/trunk/test/CodeGen/MIR/X86/global-value-operands.mir
llvm/trunk/unittests/ADT/StringExtrasTest.cpp
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/lib/Support/StringExtras.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=374415&r1=374414&r2=374415&view=diff
==============================================================================
--- llvm/trunk/lib/Support/StringExtras.cpp (original)
+++ llvm/trunk/lib/Support/StringExtras.cpp Thu Oct 10 11:31:57 2019
@@ -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);
Modified: llvm/trunk/test/Assembler/asm-path-writer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/asm-path-writer.ll?rev=374415&r1=374414&r2=374415&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/asm-path-writer.ll (original)
+++ llvm/trunk/test/Assembler/asm-path-writer.ll Thu Oct 10 11:31:57 2019
@@ -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)))
Modified: llvm/trunk/test/Assembler/source-filename-backslash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/source-filename-backslash.ll?rev=374415&r1=374414&r2=374415&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/source-filename-backslash.ll (original)
+++ llvm/trunk/test/Assembler/source-filename-backslash.ll Thu Oct 10 11:31:57 2019
@@ -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"
Modified: llvm/trunk/test/CodeGen/MIR/X86/global-value-operands.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/global-value-operands.mir?rev=374415&r1=374414&r2=374415&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/global-value-operands.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/global-value-operands.mir Thu Oct 10 11:31:57 2019
@@ -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
Modified: llvm/trunk/unittests/ADT/StringExtrasTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringExtrasTest.cpp?rev=374415&r1=374414&r2=374415&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/StringExtrasTest.cpp (original)
+++ llvm/trunk/unittests/ADT/StringExtrasTest.cpp Thu Oct 10 11:31:57 2019
@@ -109,7 +109,7 @@ TEST(StringExtrasTest, printEscapedStrin
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) {
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=374415&r1=374414&r2=374415&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Thu Oct 10 11:31:57 2019
@@ -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;
More information about the llvm-commits
mailing list