summaryrefslogtreecommitdiffstats
path: root/unittests/Option
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
commit6bf104b165cec9c14dacf10bf3380eeb32c278d7 (patch)
treef611789d6ec1eb7f6f0b70dd7d545941f246e653 /unittests/Option
parente8bc700a87b88751b82e132b10c4b96f311e0b3a (diff)
downloadexternal_llvm-6bf104b165cec9c14dacf10bf3380eeb32c278d7.zip
external_llvm-6bf104b165cec9c14dacf10bf3380eeb32c278d7.tar.gz
external_llvm-6bf104b165cec9c14dacf10bf3380eeb32c278d7.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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187675 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Option')
-rw-r--r--unittests/Option/OptionParsingTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/unittests/Option/OptionParsingTest.cpp b/unittests/Option/OptionParsingTest.cpp
index 2a5a5a9..5a76d65 100644
--- a/unittests/Option/OptionParsingTest.cpp
+++ b/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], "--");
+}