[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
This commit is contained in:
Vedant Kumar
2016-06-29 21:55:46 +00:00
parent 30ece958db
commit d6d192cd12
3 changed files with 17 additions and 5 deletions

View File

@@ -28,10 +28,14 @@ void CoveragePrinter::StreamDestructor::operator()(raw_ostream *OS) const {
}
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 @@ CoveragePrinter::createOutputStream(StringRef Path, StringRef Extension,
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))