aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2021-04-09 11:53:59 -0700
committerPetr Hosek <phosek@google.com>2021-05-11 15:26:45 -0700
commit8280ece0c972db24e51aae5074ca5433002f1071 (patch)
treed0349813ad8a97abc2413e11d1c06636d0ecdf1d /llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
parenta0162a81b1377331c3e0ebb58ac349b2ffd7b598 (diff)
downloadllvm-8280ece0c972db24e51aae5074ca5433002f1071.zip
llvm-8280ece0c972db24e51aae5074ca5433002f1071.tar.gz
llvm-8280ece0c972db24e51aae5074ca5433002f1071.tar.bz2
[Coverage] Support overriding compilation directory
When making compilation relocatable, for example in distributed compilation scenarios, we want to set compilation dir to a relative value like `.` but this presents a problem when generating reports because if the file path is relative as well, for example `..`, you may end up writing files outside of the output directory. This change introduces a flag that allows overriding the compilation directory that's stored inside the profile with a different value that is absolute. Differential Revision: https://reviews.llvm.org/D100232
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMapping.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index f813946..2fd70a0 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -319,7 +319,8 @@ static Error handleMaybeNoDataFoundError(Error E) {
Expected<std::unique_ptr<CoverageMapping>>
CoverageMapping::load(ArrayRef<StringRef> ObjectFilenames,
- StringRef ProfileFilename, ArrayRef<StringRef> Arches) {
+ StringRef ProfileFilename, ArrayRef<StringRef> Arches,
+ StringRef CompilationDir) {
auto ProfileReaderOrErr = IndexedInstrProfReader::create(ProfileFilename);
if (Error E = ProfileReaderOrErr.takeError())
return std::move(E);
@@ -336,8 +337,8 @@ CoverageMapping::load(ArrayRef<StringRef> ObjectFilenames,
MemoryBufferRef CovMappingBufRef =
CovMappingBufOrErr.get()->getMemBufferRef();
SmallVector<std::unique_ptr<MemoryBuffer>, 4> Buffers;
- auto CoverageReadersOrErr =
- BinaryCoverageReader::create(CovMappingBufRef, Arch, Buffers);
+ auto CoverageReadersOrErr = BinaryCoverageReader::create(
+ CovMappingBufRef, Arch, Buffers, CompilationDir);
if (Error E = CoverageReadersOrErr.takeError()) {
E = handleMaybeNoDataFoundError(std::move(E));
if (E)