llvm-cov: Make debug output more consistent
authorJustin Bogner <mail@justinbogner.com>
Mon, 15 Sep 2014 22:23:29 +0000 (22:23 +0000)
committerJustin Bogner <mail@justinbogner.com>
Mon, 15 Sep 2014 22:23:29 +0000 (22:23 +0000)
This changes the debug output of the llvm-cov tool to consistently
write to stderr, and moves the highlighting output closer to where
it's relevant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217838 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-cov/showExpansions.cpp
test/tools/llvm-cov/showHighlightedRanges.cpp
tools/llvm-cov/CodeCoverage.cpp
tools/llvm-cov/SourceCoverageView.cpp

index db5786b9892b84ef40929e7af35dbe083141b2cd..52d33e99c6c8701bea60019ca460468b2a6db1f6 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: llvm-cov show %S/Inputs/showExpansions.covmapping -instr-profile %S/Inputs/showExpansions.profdata -dump -show-expansions -filename-equivalence %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/showExpansions.covmapping -instr-profile %S/Inputs/showExpansions.profdata -dump -show-expansions -filename-equivalence %s 2>&1 | FileCheck %s
 
 #define DO_SOMETHING_ELSE() \
   do {                      \
index ce64fdd00aaf6eb3b015d97bfdb284b8ba349e1e..cec730829e0c5b225825faa6918352c9b301d826 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -dump -filename-equivalence %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -dump -filename-equivalence %s 2>&1 | FileCheck %s
 
 void func() {
   return;
index 79a596d702a631f9f76a98cc1589215f1186236d..f3587c768deda068da0bba85c5df884e5886c76b 100644 (file)
@@ -273,7 +273,7 @@ void CodeCoverageTool::createExpansionSubView(
   auto ExpandedLines = findExpandedFileInterestingLineRange(
       ExpandedRegion.ExpandedFileID, Function);
   if (ViewOpts.Debug)
-    llvm::outs() << "Expansion of " << ExpandedRegion.ExpandedFileID << ":"
+    llvm::errs() << "Expansion of " << ExpandedRegion.ExpandedFileID << ":"
                  << ExpandedLines.first << " -> " << ExpandedLines.second
                  << " @ " << ExpandedRegion.FileID << ", "
                  << ExpandedRegion.LineStart << ":"
@@ -397,14 +397,14 @@ bool CodeCoverageTool::load() {
     for (const auto &R : I.MappingRegions) {
       // Compute the values of mapped regions
       if (ViewOpts.Debug) {
-        outs() << "File " << R.FileID << "| " << R.LineStart << ":"
+        errs() << "File " << R.FileID << "| " << R.LineStart << ":"
                << R.ColumnStart << " -> " << R.LineEnd << ":" << R.ColumnEnd
                << " = ";
         Ctx.dump(R.Count);
         if (R.Kind == CounterMappingRegion::ExpansionRegion) {
-          outs() << " (Expanded file id = " << R.ExpandedFileID << ") ";
+          errs() << " (Expanded file id = " << R.ExpandedFileID << ") ";
         }
-        outs() << "\n";
+        errs() << "\n";
       }
       ErrorOr<int64_t> ExecutionCount = Ctx.evaluate(R.Count);
       if (ExecutionCount) {
index 7c6d9a5c0f38cbc3b015abfc872fbddec26c16d6..202475a7562171e489ec5954bff82457d05b77fa 100644 (file)
@@ -49,6 +49,18 @@ void SourceCoverageView::renderLine(raw_ostream &OS, StringRef Line,
   // Show the rest of the line
   OS << Line.substr(Start - 1, Line.size() - Start + 1);
   OS << "\n";
+
+  if (Options.Debug) {
+    for (const auto &Range : Ranges) {
+      errs() << "Highlighted line " << Range.Line << ", " << Range.ColumnStart
+             << " -> ";
+      if (Range.ColumnEnd == std::numeric_limits<unsigned>::max()) {
+        errs() << "?\n";
+      } else {
+        errs() << Range.ColumnEnd << "\n";
+      }
+    }
+  }
 }
 
 void SourceCoverageView::renderOffset(raw_ostream &OS, unsigned I) {
@@ -390,18 +402,6 @@ SourceCoverageView::createHighlightRanges(SourceCoverageDataManager &Data) {
   }
 
   std::sort(HighlightRanges.begin(), HighlightRanges.end());
-
-  if (Options.Debug) {
-    for (const auto &Range : HighlightRanges) {
-      outs() << "Highlighted line " << Range.Line << ", " << Range.ColumnStart
-             << " -> ";
-      if (Range.ColumnEnd == std::numeric_limits<unsigned>::max()) {
-        outs() << "?\n";
-      } else {
-        outs() << Range.ColumnEnd << "\n";
-      }
-    }
-  }
 }
 
 void SourceCoverageView::createRegionMarkers(SourceCoverageDataManager &Data) {