[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 06:09:59 PDT 2022
vit9696 created this revision.
vit9696 added reviewers: keith, phosek.
Herald added a project: All.
vit9696 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
https://github.com/llvm/llvm-project/issues/54670
Repository:
rG LLVM Github Monorepo
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,20 @@
llvm::NamedMDNode *GCov = TheModule.getOrInsertNamedMetadata("llvm.gcov");
llvm::LLVMContext &Ctx = TheModule.getContext();
- auto *CoverageDataFile =
+ 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.426389.patch
Type: text/x-patch
Size: 1088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220502/b90c41c5/attachment.bin>
More information about the cfe-commits
mailing list