summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2016-06-28 16:12:24 +0000
committerVedant Kumar <vsk@apple.com>2016-06-28 16:12:24 +0000
commit9cbad2c2b8ca3a5db8979f8233612a781b8eb7c5 (patch)
treed70144a8d080a512ed50f6c0e7fef8b0dc3a2171 /llvm/tools/llvm-cov/SourceCoverageViewText.cpp
parent64d8a029e9657538f7e89b932c0f20248ee0f23c (diff)
downloadbcm5719-llvm-9cbad2c2b8ca3a5db8979f8233612a781b8eb7c5.tar.gz
bcm5719-llvm-9cbad2c2b8ca3a5db8979f8233612a781b8eb7c5.zip
[llvm-cov] Create an index of reports in -output-dir mode
This index lists the reports available in the 'coverage' sub-directory. This will help navigate coverage output from large projects. This commit factors the file creation code out of SourceCoverageView and into CoveragePrinter. llvm-svn: 274029
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageViewText.cpp')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewText.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index 65169519c30..848b5f899cd 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -18,6 +18,28 @@
using namespace llvm;
+Expected<CoveragePrinter::OwnedStream>
+CoveragePrinterText::createViewFile(StringRef Path, bool InToplevel) {
+ return createOutputStream(Path, "txt", InToplevel);
+}
+
+void CoveragePrinterText::closeViewFile(OwnedStream OS) {
+ OS->operator<<('\n');
+}
+
+Error CoveragePrinterText::createIndexFile(ArrayRef<StringRef> SourceFiles) {
+ auto OSOrErr = createOutputStream("index", "txt", /*InToplevel=*/true);
+ if (Error E = OSOrErr.takeError())
+ return E;
+ auto OS = std::move(OSOrErr.get());
+ raw_ostream &OSRef = *OS.get();
+
+ for (StringRef SF : SourceFiles)
+ OSRef << getOutputPath(SF, "txt", /*InToplevel=*/false) << '\n';
+
+ return Error::success();
+}
+
namespace {
static const unsigned LineCoverageColumnWidth = 7;
@@ -37,15 +59,6 @@ unsigned getDividerWidth(const CoverageViewOptions &Opts) {
} // anonymous namespace
-Expected<SourceCoverageView::OwnedStream>
-SourceCoverageViewText::createOutputFile(StringRef Path, bool InToplevel) {
- return createOutputStream(getOptions(), Path, "txt", InToplevel);
-}
-
-void SourceCoverageViewText::closeOutputFile(OwnedStream OS) {
- OS->operator<<('\n');
-}
-
void SourceCoverageViewText::renderSourceName(raw_ostream &OS) {
getOptions().colored_ostream(OS, raw_ostream::CYAN) << getSourceName()
<< ":\n";
OpenPOWER on IntegriCloud