Driver: Implement 'missing argument' error.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67490 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp
index 7b7e2a7..07e3511 100644
--- a/lib/Driver/OptTable.cpp
+++ b/lib/Driver/OptTable.cpp
@@ -128,21 +128,28 @@
   return Opt;
 }
 
-Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index, 
-                           unsigned IndexEnd) const {
+Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const {
+  unsigned Prev = Index;
   const char *Str = Args.getArgString(Index);
 
   // Anything that doesn't start with '-' is an input, as is '-' itself.
   if (Str[0] != '-' || Str[1] == '\0')
     return new PositionalArg(getOption(OPT_INPUT), Index++);
 
+  // FIXME: Make this fast, and avoid looking through option
+  // groups. Maybe we should declare them separately?
   for (unsigned j = OPT_UNKNOWN + 1; j < LastOption; ++j) {
     const char *OptName = getOptionName((options::ID) j);
     
     // Arguments are only accepted by options which prefix them.
-    if (memcmp(Str, OptName, strlen(OptName)) == 0)
+    if (memcmp(Str, OptName, strlen(OptName)) == 0) {
       if (Arg *A = getOption((options::ID) j)->accept(Args, Index))
         return A;
+
+      // Otherwise, see if this argument was missing values.
+      if (Prev != Index)
+        return 0;
+    }
   }
 
   return new PositionalArg(getOption(OPT_UNKNOWN), Index++);