[PATCH] D124767: [Clang] Map .gcda paths according to -fcoverage-prefix-map
Vitaly Cheptsov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 2 07:18:27 PDT 2022
vit9696 updated this revision to Diff 426414.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124767/new/
https://reviews.llvm.org/D124767
Files:
clang/lib/CodeGen/CodeGenModule.cpp
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -6550,8 +6550,21 @@
llvm::NamedMDNode *GCov = TheModule.getOrInsertNamedMetadata("llvm.gcov");
llvm::LLVMContext &Ctx = TheModule.getContext();
- auto *CoverageDataFile =
+ llvm::MDString *CoverageDataFile = nullptr;
+ auto &PrefixMap = getCodeGenOpts().CoveragePrefixMap;
+ llvm::SmallString<256> File;
+ if (!PrefixMap.empty()) {
+ File = getCodeGenOpts().CoverageDataFile;
+ llvm::sys::path::remove_dots(File, /*remove_dot_dot=*/true);
+ for (const auto &Entry : PrefixMap) {
+ if (llvm::sys::path::replace_path_prefix(File, Entry.first, Entry.second))
+ break;
+ }
+ CoverageDataFile = llvm::MDString::get(Ctx, File.c_str());
+ } else {
+ CoverageDataFile =
llvm::MDString::get(Ctx, getCodeGenOpts().CoverageDataFile);
+ }
auto *CoverageNotesFile =
llvm::MDString::get(Ctx, getCodeGenOpts().CoverageNotesFile);
for (int i = 0, e = CUNode->getNumOperands(); i != e; ++i) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124767.426414.patch
Type: text/x-patch
Size: 1135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220502/35ea59e2/attachment.bin>
More information about the cfe-commits
mailing list