Driver/Frontend: Add support for -mllvm, which forwards options to the LLVM option parser.
 - Note that this is a behavior change, previously -mllvm at the driver level forwarded to clang -cc1. The driver does a little magic to make sure that '-mllvm -disable-llvm-optzns' works correctly, but other users will need to be updated to use -Xclang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101354 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 77456fa..afcf26f 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1325,8 +1325,18 @@
   Args.AddLastArg(CmdArgs, options::OPT_dM);
   Args.AddLastArg(CmdArgs, options::OPT_dD);
 
+  // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option
+  // parser.
   Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
-  Args.AddAllArgValues(CmdArgs, options::OPT_mllvm);
+  for (arg_iterator it = Args.filtered_begin(options::OPT_mllvm),
+         ie = Args.filtered_end(); it != ie; ++it) {
+    // We translate this by hand to the -cc1 argument, since nightly test uses
+    // it and developers have been trained to spell it with -mllvm.
+    if (llvm::StringRef(it->getValue(Args, 0)) == "-disable-llvm-optzns")
+      CmdArgs.push_back("-disable-llvm-optzns");
+    else
+      it->render(Args, CmdArgs);
+  }
 
   if (Output.getType() == types::TY_Dependencies) {
     // Handled with other dependency code.