[clang] 3275b18 - [Coverage] Normalize compilation dir as well

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 19 15:29:12 PST 2021


Author: Petr Hosek
Date: 2021-02-19T15:29:03-08:00
New Revision: 3275b18f8979ab750e3674f28e7f82c7ef37d2a3

URL: https://github.com/llvm/llvm-project/commit/3275b18f8979ab750e3674f28e7f82c7ef37d2a3
DIFF: https://github.com/llvm/llvm-project/commit/3275b18f8979ab750e3674f28e7f82c7ef37d2a3.diff

LOG: [Coverage] Normalize compilation dir as well

This matches debug info behavior.

Differential Revision: https://reviews.llvm.org/D97001

Added: 
    

Modified: 
    clang/lib/CodeGen/CoverageMappingGen.cpp
    clang/test/Profile/profile-prefix-map.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 9c4cab32457c..e370be163296 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1726,7 +1726,7 @@ void CoverageMappingModuleGen::emit() {
   llvm::SmallVector<std::string, 16> FilenameStrs;
   FilenameStrs.resize(FileEntries.size() + 1);
   // The first filename is the current working directory.
-  FilenameStrs[0] = getCurrentDirname();
+  FilenameStrs[0] = normalizeFilename(getCurrentDirname());
   for (const auto &Entry : FileEntries) {
     auto I = Entry.second;
     FilenameStrs[I] = normalizeFilename(Entry.first->getName());

diff  --git a/clang/test/Profile/profile-prefix-map.c b/clang/test/Profile/profile-prefix-map.c
index 9c7718e901d0..97b8ff0f4520 100644
--- a/clang/test/Profile/profile-prefix-map.c
+++ b/clang/test/Profile/profile-prefix-map.c
@@ -16,3 +16,6 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c %t/root/nested/profile-prefix-map.c -fprofile-prefix-map=%/t/root=. -o - | FileCheck --check-prefix=PROFILE-PREFIX-MAP %s
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c ../root/nested/profile-prefix-map.c -fprofile-prefix-map=../root=. -o - | FileCheck --check-prefix=PROFILE-PREFIX-MAP %s
 // PROFILE-PREFIX-MAP: @__llvm_coverage_mapping = {{.*"\\02.*}}.{{/|\\+}}nested{{.*profile-prefix-map\.c}}
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c %t/root/nested/profile-prefix-map.c -fprofile-compilation-dir=/custom -fprofile-prefix-map=/custom=/nonsense -o - | FileCheck --check-prefix=PROFILE-COMPILATION-DIR %s
+// PROFILE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense


        


More information about the cfe-commits mailing list