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/Driver.cpp b/lib/Driver/Driver.cpp
index 40c6e50..db08426 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -72,18 +72,23 @@
     }
 
     unsigned Prev = Index;
-    Arg *A = getOpts().ParseOneArg(*Args, Index, End);
-    if (A) {
-      if (A->getOption().isUnsupported()) {
-        Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(*Args);
-        continue;
-      }
+    Arg *A = getOpts().ParseOneArg(*Args, Index);
+    assert(Index > Prev && "Parser failed to consume argument.");
 
-      Args->append(A);
+    // Check for missing argument error.
+    if (!A) {
+      assert(Index >= End && "Unexpected parser error.");
+      Diag(clang::diag::err_drv_missing_argument)
+        << Args->getArgString(Prev)
+        << (Index - Prev - 1);
+      break;
     }
 
-    assert(Index > Prev && "Parser failed to consume argument.");
-    (void) Prev;
+    if (A->getOption().isUnsupported()) {
+      Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(*Args);
+      continue;
+    }
+    Args->append(A);
   }
 
   return Args;