summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.cpp10
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.h6
2 files changed, 11 insertions, 5 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index a4e9c43d066..08eb545a29c 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -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))
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.h b/llvm/tools/llvm-cov/SourceCoverageView.h
index 98e68b6772d..feef959f86b 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.h
+++ b/llvm/tools/llvm-cov/SourceCoverageView.h
@@ -111,9 +111,11 @@ public:
protected:
CoveragePrinter(const CoverageViewOptions &Opts) : Opts(Opts) {}
- /// \brief Return `OutputDir/ToplevelDir/Path.Extension`.
+ /// \brief Return `OutputDir/ToplevelDir/Path.Extension`. If \p InToplevel is
+ /// false, skip the ToplevelDir component. If \p Relative is false, skip the
+ /// OutputDir component.
std::string getOutputPath(StringRef Path, StringRef Extension,
- bool InToplevel);
+ bool InToplevel, bool Relative = true);
/// \brief If directory output is enabled, create a file in that directory
/// at the path given by getOutputPath(). Otherwise, return stdout.
OpenPOWER on IntegriCloud