diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 7 | ||||
-rw-r--r-- | llvm/unittests/Support/CommandLineTest.cpp | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 39991a8905d..c1193f90e8f 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -874,6 +874,13 @@ void cl::TokenizeWindowsCommandLine(StringRef Src, StringSaver &Saver, // QUOTED state means that it's reading a token quoted by double quotes. if (State == QUOTED) { if (C == '"') { + if (I < (E - 1) && Src[I + 1] == '"') { + // Consecutive double-quotes inside a quoted string implies one + // double-quote. + Token.push_back('"'); + I = I + 1; + continue; + } State = UNQUOTED; continue; } diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index 4bfa8a35a16..a7aee41244f 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/unittests/Support/CommandLineTest.cpp @@ -185,7 +185,7 @@ TEST(CommandLineTest, TokenizeGNUCommandLine) { array_lengthof(Output)); } -TEST(CommandLineTest, TokenizeWindowsCommandLine) { +TEST(CommandLineTest, TokenizeWindowsCommandLine1) { const char Input[] = "a\\b c\\\\d e\\\\\"f g\" h\\\"i j\\\\\\\"k \"lmn\" o pqr " "\"st \\\"u\" \\v"; const char *const Output[] = { "a\\b", "c\\\\d", "e\\f g", "h\"i", "j\\\"k", @@ -194,6 +194,13 @@ TEST(CommandLineTest, TokenizeWindowsCommandLine) { array_lengthof(Output)); } +TEST(CommandLineTest, TokenizeWindowsCommandLine2) { + const char Input[] = "clang -c -DFOO=\"\"\"ABC\"\"\" x.cpp"; + const char *const Output[] = { "clang", "-c", "-DFOO=\"ABC\"", "x.cpp"}; + testCommandLineTokenizer(cl::TokenizeWindowsCommandLine, Input, Output, + array_lengthof(Output)); +} + TEST(CommandLineTest, TokenizeConfigFile1) { const char *Input = "\\"; const char *const Output[] = { "\\" }; |