]> granicus.if.org Git - clang/commitdiff
Make -M/-MM behave like in gcc; use -MF first then -o else use stdout.
authorNick Lewycky <nicholas@mxc.ca>
Thu, 23 Sep 2010 23:49:25 +0000 (23:49 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 23 Sep 2010 23:49:25 +0000 (23:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114712 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp

index 0555342bc84a489478c700fb5537d00e6a604a85..84a33a5f7763974fa85aea001f7202428a3b8657 100644 (file)
@@ -1151,16 +1151,22 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
                                        const char *BaseInput,
                                        bool AtTopLevel) const {
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
+
+  // Default to writing to stdout.
+  if (AtTopLevel && isa<PreprocessJobAction>(JA)) {
+    if (Arg *DepOutput = C.getArgs().getLastArg(options::OPT_MF))
+      return C.addResultFile(DepOutput->getValue(C.getArgs()));
+    if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+      return C.addResultFile(FinalOutput->getValue(C.getArgs()));
+    return "-";
+  }
+
   // Output to a user requested destination?
   if (AtTopLevel && !isa<DsymutilJobAction>(JA)) {
     if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
       return C.addResultFile(FinalOutput->getValue(C.getArgs()));
   }
 
-  // Default to writing to stdout?
-  if (AtTopLevel && isa<PreprocessJobAction>(JA))
-    return "-";
-
   // Output to a temporary file?
   if (!AtTopLevel && !C.getArgs().hasArg(options::OPT_save_temps)) {
     std::string TmpName =