aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Option/OptionParsingTest.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-08-13 21:09:50 +0000
committerHans Wennborg <hans@hanshq.net>2013-08-13 21:09:50 +0000
commitd505fbf40376dd7ace0ef50e794a840f54091586 (patch)
tree9a547901540e3b2ccf0e03a4788fdb87ab590673 /llvm/unittests/Option/OptionParsingTest.cpp
parent3a2c2d42b85b657535dfb39e811045403ccdd195 (diff)
downloadllvm-d505fbf40376dd7ace0ef50e794a840f54091586.zip
llvm-d505fbf40376dd7ace0ef50e794a840f54091586.tar.gz
llvm-d505fbf40376dd7ace0ef50e794a840f54091586.tar.bz2
Options: Add new option kind that consumes remaining arguments
This adds KIND_REMAINING_ARGS, a class of options that consume all remaining arguments on the command line. This will be used to support /link in clang-cl, which is used to forward all remaining arguments to the linker. It also allows us to remove the hard-coded handling of "--", allowing clients (clang and lld) to implement that functionality themselves with this new option class. Differential Revision: http://llvm-reviews.chandlerc.com/D1387 llvm-svn: 188314
Diffstat (limited to 'llvm/unittests/Option/OptionParsingTest.cpp')
-rw-r--r--llvm/unittests/Option/OptionParsingTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/unittests/Option/OptionParsingTest.cpp b/llvm/unittests/Option/OptionParsingTest.cpp
index 5a76d65..4a7b7b1 100644
--- a/llvm/unittests/Option/OptionParsingTest.cpp
+++ b/llvm/unittests/Option/OptionParsingTest.cpp
@@ -169,3 +169,30 @@ TEST(Option, DashDash) {
EXPECT_EQ(AL->getAllArgValues(OPT_INPUT)[0], "-B");
EXPECT_EQ(AL->getAllArgValues(OPT_INPUT)[1], "--");
}
+
+TEST(Option, SlurpEmpty) {
+ TestOptTable T;
+ unsigned MAI, MAC;
+
+ const char *MyArgs[] = { "-A", "-slurp" };
+ OwningPtr<InputArgList> AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
+ EXPECT_TRUE(AL->hasArg(OPT_A));
+ EXPECT_TRUE(AL->hasArg(OPT_Slurp));
+ EXPECT_EQ(AL->getAllArgValues(OPT_Slurp).size(), 0);
+}
+
+TEST(Option, Slurp) {
+ TestOptTable T;
+ unsigned MAI, MAC;
+
+ const char *MyArgs[] = { "-A", "-slurp", "-B", "--", "foo" };
+ OwningPtr<InputArgList> AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
+ EXPECT_EQ(AL->size(), 2U);
+ EXPECT_TRUE(AL->hasArg(OPT_A));
+ EXPECT_FALSE(AL->hasArg(OPT_B));
+ EXPECT_TRUE(AL->hasArg(OPT_Slurp));
+ EXPECT_EQ(AL->getAllArgValues(OPT_Slurp).size(), 3U);
+ EXPECT_EQ(AL->getAllArgValues(OPT_Slurp)[0], "-B");
+ EXPECT_EQ(AL->getAllArgValues(OPT_Slurp)[1], "--");
+ EXPECT_EQ(AL->getAllArgValues(OPT_Slurp)[2], "foo");
+}