[llvm] r280896 - [llvm-cov] Use less space to describe source names

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 17:56:48 PDT 2016


Author: vedantk
Date: Wed Sep  7 19:56:48 2016
New Revision: 280896

URL: http://llvm.org/viewvc/llvm-project?rev=280896&view=rev
Log:
[llvm-cov] Use less space to describe source names

In r279628, we made SourceCoverageView list the binary associated with a
view and started adding labels (e.g "Source: foo" or "Function: bar") to
everything. Condense this information a bit to unclutter reports.

Modified:
    llvm/trunk/test/tools/llvm-cov/showProjectSummary.cpp
    llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp
    llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
    llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
    llvm/trunk/tools/llvm-cov/SourceCoverageView.h
    llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
    llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h
    llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
    llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h

Modified: llvm/trunk/test/tools/llvm-cov/showProjectSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/showProjectSummary.cpp?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/showProjectSummary.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/showProjectSummary.cpp Wed Sep  7 19:56:48 2016
@@ -36,11 +36,8 @@ int main(int argc, char ** argv) {
 // HTML: <span>Code Coverage Report</span>
 // HTML: <div class='created-time'>
 // HTML: <span>Created:
-// HTML-FILE: <pre>Source:
-// HTML-FILE: showProjectSummary.cpp</pre>
-// HTML-FILE: <pre>Binary:
-// HTML-FILE: showProjectSummary.covmapping</pre>
-// HTML-FUNCTION: <pre>Function: main</pre>
+// HTML-FILE: <pre>Source: {{.*}}showProjectSummary.cpp (Binary: showProjectSummary.covmapping)</pre>
+// HTML-FUNCTION: <pre>main</pre>
 // HTML-UNCOVEREDLINE: <a href='#L8'>Go to first unexecuted line</a>
 // HTML-HEADER: <tr><td><span><pre>Line No.</pre></span></td>
 // HTML-HEADER: <td><span><pre>Count</pre></span></td>

Modified: llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp Wed Sep  7 19:56:48 2016
@@ -12,7 +12,7 @@ int func(T x) {      // ALL-NEXT:    [[@
   int j = 1;         // ALL-NEXT:    [[@LINE]]| 0|  int j = 1;
 }                    // ALL-NEXT:    [[@LINE]]| 2|}
 
-                     // SHARED:       {{^ *(\| )?}}Function: _Z4funcIbEiT_:
+                     // SHARED:       {{^ *(\| )?}}_Z4funcIbEiT_:
                      // SHARED:       [[@LINE-9]]| 1|int func(T x) {
                      // SHARED-NEXT:  [[@LINE-9]]| 1|  if(x)
                      // SHARED-NEXT:  [[@LINE-9]]| 1|    return 0;
@@ -21,8 +21,8 @@ int func(T x) {      // ALL-NEXT:    [[@
                      // SHARED-NEXT:  [[@LINE-9]]| 0|  int j = 1;
                      // SHARED-NEXT:  [[@LINE-9]]| 1|}
 
-                     // ALL:         {{^ *}}| Function: _Z4funcIiEiT_:
-                     // FILTER-NOT:  {{^ *(\| )?}}Function: _Z4funcIiEiT_:
+                     // ALL:         {{^ *}}| _Z4funcIiEiT_:
+                     // FILTER-NOT:  {{^ *(\| )?}} _Z4funcIiEiT_:
                      // ALL:         [[@LINE-19]]| 1|int func(T x) {
                      // ALL-NEXT:    [[@LINE-19]]| 1|  if(x)
                      // ALL-NEXT:    [[@LINE-19]]| 0|    return 0;
@@ -56,7 +56,7 @@ int main() {         // ALL:         [[@
 // HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
 // HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>2</pre></td><td class='code'><pre>}
 
-// HTML-SHARED: <div class='source-name-title'><pre>Function: _Z4funcIbEiT_</pre></div>
+// HTML-SHARED: <div class='source-name-title'><pre>_Z4funcIbEiT_</pre></div>
 // HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
 // HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>  if(x)
 // HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>    ret
@@ -65,7 +65,7 @@ int main() {         // ALL:         [[@
 // HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
 // HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>}
 
-// HTML-ALL: <div class='source-name-title'><pre>Function: _Z4funcIiEiT_</pre></div>
+// HTML-ALL: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div>
 // HTML-FILTER-NOT: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div><table>
 // HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
 // HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>  if(x)

Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Wed Sep  7 19:56:48 2016
@@ -210,9 +210,9 @@ CodeCoverageTool::createFunctionView(con
     return nullptr;
 
   auto Expansions = FunctionCoverage.getExpansions();
-  auto View = SourceCoverageView::create(
-      getSymbolForHumans(Function.Name), SourceBuffer.get(), ViewOpts,
-      std::move(FunctionCoverage), /*FunctionView=*/true);
+  auto View = SourceCoverageView::create(getSymbolForHumans(Function.Name),
+                                         SourceBuffer.get(), ViewOpts,
+                                         std::move(FunctionCoverage));
   attachExpansionSubViews(*View, Expansions, Coverage);
 
   return View;
@@ -238,7 +238,7 @@ CodeCoverageTool::createSourceFileView(S
     auto SubViewExpansions = SubViewCoverage.getExpansions();
     auto SubView = SourceCoverageView::create(
         getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts,
-        std::move(SubViewCoverage), /*FunctionView=*/true);
+        std::move(SubViewCoverage));
     attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
 
     if (SubView) {

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp Wed Sep  7 19:56:48 2016
@@ -129,26 +129,28 @@ bool SourceCoverageView::hasSubViews() c
 std::unique_ptr<SourceCoverageView>
 SourceCoverageView::create(StringRef SourceName, const MemoryBuffer &File,
                            const CoverageViewOptions &Options,
-                           coverage::CoverageData &&CoverageInfo,
-                           bool FunctionView) {
+                           coverage::CoverageData &&CoverageInfo) {
   switch (Options.Format) {
   case CoverageViewOptions::OutputFormat::Text:
     return llvm::make_unique<SourceCoverageViewText>(
-        SourceName, File, Options, std::move(CoverageInfo), FunctionView);
+        SourceName, File, Options, std::move(CoverageInfo));
   case CoverageViewOptions::OutputFormat::HTML:
     return llvm::make_unique<SourceCoverageViewHTML>(
-        SourceName, File, Options, std::move(CoverageInfo), FunctionView);
+        SourceName, File, Options, std::move(CoverageInfo));
   }
   llvm_unreachable("Unknown coverage output format!");
 }
 
-std::string SourceCoverageView::getNativeSourceName() const {
-  std::string SourceFile = isFunctionView() ? "Function: " : "Source: ";
-  SourceFile += getSourceName().str();
-  SmallString<128> SourceText(SourceFile);
+std::string SourceCoverageView::getSourceName() const {
+  SmallString<128> SourceText(SourceName);
   sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true);
   sys::path::native(SourceText);
-  return SourceText.c_str();
+  return SourceText.str();
+}
+
+std::string SourceCoverageView::getVerboseSourceName() const {
+  return "Source: " + getSourceName() + " (Binary: " +
+         sys::path::filename(getOptions().ObjectFilename).str() + ")";
 }
 
 void SourceCoverageView::addExpansion(

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.h?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.h Wed Sep  7 19:56:48 2016
@@ -172,9 +172,6 @@ class SourceCoverageView {
   /// on display.
   std::vector<InstantiationView> InstantiationSubViews;
 
-  /// Specifies whether or not the view is a function view.
-  bool FunctionView;
-
   /// Get the first uncovered line number for the source file.
   unsigned getFirstUncoveredLineNo();
 
@@ -264,24 +261,24 @@ protected:
 
   SourceCoverageView(StringRef SourceName, const MemoryBuffer &File,
                      const CoverageViewOptions &Options,
-                     coverage::CoverageData &&CoverageInfo, bool FunctionView)
+                     coverage::CoverageData &&CoverageInfo)
       : SourceName(SourceName), File(File), Options(Options),
-        CoverageInfo(std::move(CoverageInfo)), FunctionView(FunctionView) {}
+        CoverageInfo(std::move(CoverageInfo)) {}
 
 public:
   static std::unique_ptr<SourceCoverageView>
   create(StringRef SourceName, const MemoryBuffer &File,
          const CoverageViewOptions &Options,
-         coverage::CoverageData &&CoverageInfo, bool FucntionView = false);
+         coverage::CoverageData &&CoverageInfo);
 
   virtual ~SourceCoverageView() {}
 
-  StringRef getSourceName() const { return SourceName; }
-
   /// \brief Return the source name formatted for the host OS.
-  std::string getNativeSourceName() const;
+  std::string getSourceName() const;
 
-  bool isFunctionView() const { return FunctionView; }
+  /// \brief Return a verbose description of the source name and the binary it
+  /// corresponds to.
+  std::string getVerboseSourceName() const;
 
   const CoverageViewOptions &getOptions() const { return Options; }
 

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp Wed Sep  7 19:56:48 2016
@@ -341,12 +341,10 @@ void SourceCoverageViewHTML::renderViewF
 void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile,
                                               unsigned FirstUncoveredLineNo) {
   OS << BeginSourceNameDiv;
-  // Render the source name for the view.
-  OS << tag("pre", escape(getNativeSourceName(), getOptions()));
+  std::string ViewInfo = escape(
+      WholeFile ? getVerboseSourceName() : getSourceName(), getOptions());
+  OS << tag("pre", ViewInfo);
   if (WholeFile) {
-    // Render the object file name for the view.
-    OS << tag("pre",
-              escape("Binary: " + getOptions().ObjectFilename, getOptions()));
     // Render the "Go to first unexecuted line" link for the view.
     if (FirstUncoveredLineNo != 0) { // The file is not fully covered
       std::string LinkText =

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h Wed Sep  7 19:56:48 2016
@@ -78,10 +78,9 @@ class SourceCoverageViewHTML : public So
 public:
   SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File,
                          const CoverageViewOptions &Options,
-                         coverage::CoverageData &&CoverageInfo,
-                         bool FunctionView)
-      : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo),
-                           FunctionView) {}
+                         coverage::CoverageData &&CoverageInfo)
+      : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
+  }
 };
 
 } // namespace llvm

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp Wed Sep  7 19:56:48 2016
@@ -65,12 +65,8 @@ void SourceCoverageViewText::renderViewF
 
 void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile,
                                               unsigned FirstUncoveredLineNo) {
-  getOptions().colored_ostream(OS, raw_ostream::CYAN) << getNativeSourceName()
-                                                      << ":\n";
-  if (WholeFile) {
-    getOptions().colored_ostream(OS, raw_ostream::CYAN)
-        << "Binary: " << getOptions().ObjectFilename << ":\n";
-  }
+  std::string ViewInfo = WholeFile ? getVerboseSourceName() : getSourceName();
+  getOptions().colored_ostream(OS, raw_ostream::CYAN) << ViewInfo << ":\n";
 }
 
 void SourceCoverageViewText::renderLinePrefix(raw_ostream &OS,

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h?rev=280896&r1=280895&r2=280896&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h Wed Sep  7 19:56:48 2016
@@ -78,10 +78,9 @@ class SourceCoverageViewText : public So
 public:
   SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
                          const CoverageViewOptions &Options,
-                         coverage::CoverageData &&CoverageInfo,
-                         bool FunctionView)
-      : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo),
-                           FunctionView) {}
+                         coverage::CoverageData &&CoverageInfo)
+      : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
+  }
 };
 
 } // namespace llvm




More information about the llvm-commits mailing list