From 8280ece0c972db24e51aae5074ca5433002f1071 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Fri, 9 Apr 2021 11:53:59 -0700 Subject: [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 --- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp') 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> CoverageMapping::load(ArrayRef ObjectFilenames, - StringRef ProfileFilename, ArrayRef Arches) { + StringRef ProfileFilename, ArrayRef Arches, + StringRef CompilationDir) { auto ProfileReaderOrErr = IndexedInstrProfReader::create(ProfileFilename); if (Error E = ProfileReaderOrErr.takeError()) return std::move(E); @@ -336,8 +337,8 @@ CoverageMapping::load(ArrayRef ObjectFilenames, MemoryBufferRef CovMappingBufRef = CovMappingBufOrErr.get()->getMemBufferRef(); SmallVector, 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) -- cgit v1.1