summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-04 22:41:37 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-04 22:41:37 +0000
commitd9621da5aefa6459716adb5697c718e7db59f697 (patch)
treec86b2b63d124907f8990699239a5bb370f8c8539 /clang/lib
parent16b9fd447ad4333267e6d01055ff9ced50ab1f3f (diff)
downloadbcm5719-llvm-d9621da5aefa6459716adb5697c718e7db59f697.tar.gz
bcm5719-llvm-d9621da5aefa6459716adb5697c718e7db59f697.zip
Driver: Add OptTable::ParseOneArg.
llvm-svn: 66090
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/OptTable.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/Driver/OptTable.cpp b/clang/lib/Driver/OptTable.cpp
index 070c12e154f..284e3ba1e29 100644
--- a/clang/lib/Driver/OptTable.cpp
+++ b/clang/lib/Driver/OptTable.cpp
@@ -9,6 +9,8 @@
#include "clang/Driver/Options.h"
+#include "clang/Driver/Arg.h"
+#include "clang/Driver/ArgList.h"
#include "clang/Driver/Option.h"
#include <cassert>
@@ -115,3 +117,24 @@ Option *OptTable::constructOption(options::ID id) const {
return Opt;
}
+
+Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index,
+ unsigned IndexEnd) const {
+ const char *Str = Args.getArgString(Index);
+
+ // Anything that doesn't start with '-' is an input.
+ if (Str[0] != '-')
+ return new PositionalArg(getOption(InputOpt), Index++);
+
+ for (unsigned j = UnknownOpt + 1; j < getNumOptions(); ++j) {
+ const char *OptName = getOptionName((options::ID) (j + 1));
+
+ // Arguments are only accepted by options which prefix them.
+ if (memcmp(Str, OptName, strlen(OptName)) == 0)
+ if (Arg *A = getOption((options::ID) (j + 1))->accept(Args, Index))
+ return A;
+ }
+
+ return new PositionalArg(getOption(UnknownOpt), Index++);
+}
+
OpenPOWER on IntegriCloud