[llvm-cov] Use relative paths to file reports in -output-dir mode
This makes it possible to e.g copy a report to another filesystem.
llvm-svn: 274173
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index a4e9c43..08eb545 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -28,10 +28,14 @@
}
std::string CoveragePrinter::getOutputPath(StringRef Path, StringRef Extension,
- bool InToplevel) {
+ bool InToplevel, bool Relative) {
assert(Extension.size() && "The file extension may not be empty");
- SmallString<256> FullPath(Opts.ShowOutputDirectory);
+ SmallString<256> FullPath;
+
+ if (!Relative)
+ FullPath.append(Opts.ShowOutputDirectory);
+
if (!InToplevel)
sys::path::append(FullPath, getCoverageDir());
@@ -51,7 +55,7 @@
if (!Opts.hasOutputDirectory())
return OwnedStream(&outs());
- std::string FullPath = getOutputPath(Path, Extension, InToplevel);
+ std::string FullPath = getOutputPath(Path, Extension, InToplevel, false);
auto ParentDir = sys::path::parent_path(FullPath);
if (auto E = sys::fs::create_directories(ParentDir))