[clang] Fix coverage when /fo is used (PR #88201)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 9 14:35:03 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (pdagobert)

<details>
<summary>Changes</summary>

Fixes https://github.com/llvm/llvm-project/issues/87304

---
Full diff: https://github.com/llvm/llvm-project/pull/88201.diff


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+4) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 766a9b91e3c0ad..44d18acd25a589 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -802,6 +802,10 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
     } else if (Arg *FinalOutput =
                    C.getArgs().getLastArg(options::OPT__SLASH_Fo)) {
       CoverageFilename = FinalOutput->getValue();
+      StringRef V = FinalOutput->getValue();
+      if (llvm::sys::path::is_separator(V.back())) {
+        CoverageFilename += llvm::sys::path::filename(Output.getBaseInput());
+      }
     } else if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o)) {
       CoverageFilename = FinalOutput->getValue();
     } else {

``````````

</details>


https://github.com/llvm/llvm-project/pull/88201


More information about the cfe-commits mailing list