From: Nick Lewycky Date: Thu, 23 Sep 2010 23:49:25 +0000 (+0000) Subject: Make -M/-MM behave like in gcc; use -MF first then -o else use stdout. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=280ec9d23cf16f50fd173bc87da7d2101446bcdd;p=clang Make -M/-MM behave like in gcc; use -MF first then -o else use stdout. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114712 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 0555342bc8..84a33a5f77 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -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(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(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(JA)) - return "-"; - // Output to a temporary file? if (!AtTopLevel && !C.getArgs().hasArg(options::OPT_save_temps)) { std::string TmpName =