aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index dd02d92..ec9901a 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -237,12 +237,42 @@ TEST(CommandLineTest, TokenizeWindowsCommandLine2) {
}
TEST(CommandLineTest, TokenizeWindowsCommandLineQuotedLastArgument) {
+ // Whitespace at the end of the command line doesn't cause an empty last word
+ const char Input0[] = R"(a b c d )";
+ const char *const Output0[] = {"a", "b", "c", "d"};
+ testCommandLineTokenizer(cl::TokenizeWindowsCommandLine, Input0, Output0);
+
+ // But an explicit "" does
const char Input1[] = R"(a b c d "")";
const char *const Output1[] = {"a", "b", "c", "d", ""};
testCommandLineTokenizer(cl::TokenizeWindowsCommandLine, Input1, Output1);
+
+ // An unterminated quoted string is also emitted as an argument word, empty
+ // or not
const char Input2[] = R"(a b c d ")";
- const char *const Output2[] = {"a", "b", "c", "d"};
+ const char *const Output2[] = {"a", "b", "c", "d", ""};
testCommandLineTokenizer(cl::TokenizeWindowsCommandLine, Input2, Output2);
+ const char Input3[] = R"(a b c d "text)";
+ const char *const Output3[] = {"a", "b", "c", "d", "text"};
+ testCommandLineTokenizer(cl::TokenizeWindowsCommandLine, Input3, Output3);
+}
+
+TEST(CommandLineTest, TokenizeWindowsCommandLineExeName) {
+ const char Input1[] =
+ R"("C:\Program Files\Whatever\"clang.exe z.c -DY=\"x\")";
+ const char *const Output1[] = {"C:\\Program Files\\Whatever\\clang.exe",
+ "z.c", "-DY=\"x\""};
+ testCommandLineTokenizer(cl::TokenizeWindowsCommandLineFull, Input1, Output1);
+
+ const char Input2[] = "\"a\\\"b c\\\"d\n\"e\\\"f g\\\"h\n";
+ const char *const Output2[] = {"a\\b", "c\"d", nullptr,
+ "e\\f", "g\"h", nullptr};
+ testCommandLineTokenizer(cl::TokenizeWindowsCommandLineFull, Input2, Output2,
+ /*MarkEOLs=*/true);
+
+ const char Input3[] = R"(\\server\share\subdir\clang.exe)";
+ const char *const Output3[] = {"\\\\server\\share\\subdir\\clang.exe"};
+ testCommandLineTokenizer(cl::TokenizeWindowsCommandLineFull, Input3, Output3);
}
TEST(CommandLineTest, TokenizeAndMarkEOLs) {