[PATCH] D88401: [lib/Support/CommandLine][windows] - Handle "\ " as a space token.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 03:57:47 PDT 2020
grimar created this revision.
grimar added reviewers: jhenderson, MaskRay, rnk.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
grimar requested review of this revision.
This fixes an issue for LLD:
https://bugs.llvm.org/show_bug.cgi?id=47527
We might have a response file, which contains a path
to a library which included space symbols, e.g:
-Lw:/common/lib/611042000\ GIN-PCIe\ Debug
Currently it is not handled properly, because we are not escaping
space characters, like GNU does.
https://reviews.llvm.org/D88401
Files:
llvm/lib/Support/CommandLine.cpp
llvm/unittests/Support/CommandLineTest.cpp
Index: llvm/unittests/Support/CommandLineTest.cpp
===================================================================
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -239,6 +239,14 @@
array_lengthof(Output));
}
+TEST(CommandLineTest, TokenizeWindowsCommandLine3) {
+ const char Input[] = "-o D:/work\\ folder\\ foo -o D:/work\\\\ folder";
+ const char *const Output[] = {"-o", "D:/work folder foo", "-o", "D:/work\\\\",
+ "folder"};
+ testCommandLineTokenizer(cl::TokenizeWindowsCommandLine, Input, Output,
+ array_lengthof(Output));
+}
+
TEST(CommandLineTest, TokenizeWindowsCommandLineQuotedLastArgument) {
const char Input1[] = R"(a b c d "")";
const char *const Output1[] = {"a", "b", "c", "d", ""};
Index: llvm/lib/Support/CommandLine.cpp
===================================================================
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -919,6 +919,14 @@
Token.push_back('"');
return I;
}
+
+ bool FollowedBySpace = (I != E && Src[I] == ' ');
+ if (FollowedBySpace && (BackslashCount % 2 == 1)) {
+ Token.append(BackslashCount - 1, '\\');
+ Token.append(1, ' ');
+ return I;
+ }
+
Token.append(BackslashCount, '\\');
return I - 1;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88401.294642.patch
Type: text/x-patch
Size: 1364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200928/79c8104c/attachment.bin>
More information about the llvm-commits
mailing list