diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -914,7 +914,9 @@ if ((Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) && (EmitCovNotes || EmitCovData) && Output.isFilename()) { SmallString<128> OutputFilename; - if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o)) + if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_Fo)) + OutputFilename = FinalOutput->getValue(); + else if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o)) OutputFilename = FinalOutput->getValue(); else OutputFilename = llvm::sys::path::filename(Output.getBaseInput()); diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c --- a/clang/test/Driver/clang_f_opts.c +++ b/clang/test/Driver/clang_f_opts.c @@ -85,6 +85,9 @@ // CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc // CHECK-PROFILE-DIR-NEITHER-NOT: argument unused +// RUN: %clang_cl -### /c --coverage /Fo/foo/bar.obj -- %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s +// CHECK-GCNO-LOCATION: "-coverage-notes-file" "{{.*}}/foo/bar.gcno" + // RUN: %clang -### -fprofile-arcs -ftest-coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s // RUN: %clang -### --coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s // CHECK-u-NOT: "-u{{.*}}"