Index: lib/Support/CommandLine.cpp =================================================================== --- lib/Support/CommandLine.cpp +++ lib/Support/CommandLine.cpp @@ -868,6 +868,13 @@ // 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; } Index: unittests/Support/CommandLineTest.cpp =================================================================== --- unittests/Support/CommandLineTest.cpp +++ unittests/Support/CommandLineTest.cpp @@ -185,7 +185,7 @@ 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 @@ 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[] = { "\\" };