aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Option/OptionParsingTest.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-08-02 21:20:27 +0000
committerHans Wennborg <hans@hanshq.net>2013-08-02 21:20:27 +0000
commitb8f3420d1eb77075f66c83bced17bb2067f1c01f (patch)
tree072a91e03f6f583096d14523ef9c5f74dc40f38d /llvm/unittests/Option/OptionParsingTest.cpp
parente9efbf140bac0ce5116d39f892818bd7a042d87e (diff)
downloadllvm-b8f3420d1eb77075f66c83bced17bb2067f1c01f.zip
llvm-b8f3420d1eb77075f66c83bced17bb2067f1c01f.tar.gz
llvm-b8f3420d1eb77075f66c83bced17bb2067f1c01f.tar.bz2
Option parsing: recognize the special -- token
Everything that comes after -- should be treated as a filename. This enables passing in filenames that would otherwise be conflated with command-line options. This is especially important for clang-cl which supports options starting with /, which are easily conflatable with Unix-style path names. Differential Revision: http://llvm-reviews.chandlerc.com/D1274 llvm-svn: 187675
Diffstat (limited to 'llvm/unittests/Option/OptionParsingTest.cpp')
-rw-r--r--llvm/unittests/Option/OptionParsingTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/unittests/Option/OptionParsingTest.cpp b/llvm/unittests/Option/OptionParsingTest.cpp
index 2a5a5a9..5a76d65 100644
--- a/llvm/unittests/Option/OptionParsingTest.cpp
+++ b/llvm/unittests/Option/OptionParsingTest.cpp
@@ -156,3 +156,16 @@ TEST(Option, AliasArgs) {
EXPECT_EQ(AL->getAllArgValues(OPT_B)[0], "foo");
EXPECT_EQ(AL->getAllArgValues(OPT_B)[1], "bar");
}
+
+TEST(Option, DashDash) {
+ TestOptTable T;
+ unsigned MAI, MAC;
+
+ const char *MyArgs[] = { "-A", "--", "-B", "--" };
+ OwningPtr<InputArgList> AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
+ EXPECT_TRUE(AL->hasArg(OPT_A));
+ EXPECT_FALSE(AL->hasArg(OPT_B));
+ EXPECT_EQ(AL->getAllArgValues(OPT_INPUT).size(), 2U);
+ EXPECT_EQ(AL->getAllArgValues(OPT_INPUT)[0], "-B");
+ EXPECT_EQ(AL->getAllArgValues(OPT_INPUT)[1], "--");
+}