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
diff --git a/lib/Option/OptTable.cpp b/lib/Option/OptTable.cpp
index 11439d3..98e63bc 100644
--- a/lib/Option/OptTable.cpp
+++ b/lib/Option/OptTable.cpp
@@ -253,11 +253,26 @@
   unsigned Index = 0, End = ArgEnd - ArgBegin;
   while (Index < End) {
     // Ignore empty arguments (other things may still take them as arguments).
-    if (Args->getArgString(Index)[0] == '\0') {
+    StringRef Str = Args->getArgString(Index);
+    if (Str == "") {
       ++Index;
       continue;
     }
 
+    if (Str == "--") {
+      // Everything after -- is a filename.
+      ++Index;
+
+      assert(TheInputOptionID != 0 && "Invalid input option ID.");
+      while (Index < End) {
+        Args->append(new Arg(getOption(TheInputOptionID),
+                             Args->getArgString(Index), Index,
+                             Args->getArgString(Index)));
+        ++Index;
+      }
+      break;
+    }
+
     unsigned Prev = Index;
     Arg *A = ParseOneArg(*Args, Index, FlagsToInclude, FlagsToExclude);
     assert(Index > Prev && "Parser failed to consume argument.");