[clang] 18b72d3 - Also check /Fo when deciding on the .gcna / .gcda filename (PR44208)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 05:02:53 PST 2019


Author: Hans Wennborg
Date: 2019-12-05T13:57:04+01:00
New Revision: 18b72d337ef31bc4f1b898ceb17796ffe12dd104

URL: https://github.com/llvm/llvm-project/commit/18b72d337ef31bc4f1b898ceb17796ffe12dd104
DIFF: https://github.com/llvm/llvm-project/commit/18b72d337ef31bc4f1b898ceb17796ffe12dd104.diff

LOG: Also check /Fo when deciding on the .gcna / .gcda filename (PR44208)

Differential revision: https://reviews.llvm.org/D71012

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/clang_f_opts.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 5f8c0cb8a2c1..5ebf36f13ce9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -914,7 +914,9 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
   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
index fef9cbfb115e..2e445d54880a 100644
--- 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{{.*}}"


        


More information about the cfe-commits mailing list