diff tools/llvm-cov/SourceCoverageView.h @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents 1172e4bd9c6f
children 3a76565eade5
line wrap: on
line diff
--- a/tools/llvm-cov/SourceCoverageView.h	Fri Nov 25 19:14:25 2016 +0900
+++ b/tools/llvm-cov/SourceCoverageView.h	Fri Oct 27 17:07:41 2017 +0900
@@ -15,20 +15,24 @@
 #define LLVM_COV_SOURCECOVERAGEVIEW_H
 
 #include "CoverageViewOptions.h"
+#include "CoverageSummaryInfo.h"
 #include "llvm/ProfileData/Coverage/CoverageMapping.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include <vector>
 
 namespace llvm {
 
+using namespace coverage;
+
+class CoverageFiltersMatchAll;
 class SourceCoverageView;
 
 /// \brief A view that represents a macro or include expansion.
 struct ExpansionView {
-  coverage::CounterMappingRegion Region;
+  CounterMappingRegion Region;
   std::unique_ptr<SourceCoverageView> View;
 
-  ExpansionView(const coverage::CounterMappingRegion &Region,
+  ExpansionView(const CounterMappingRegion &Region,
                 std::unique_ptr<SourceCoverageView> View)
       : Region(Region), View(std::move(View)) {}
   ExpansionView(ExpansionView &&RHS)
@@ -64,30 +68,6 @@
   }
 };
 
-/// \brief Coverage statistics for a single line.
-struct LineCoverageStats {
-  uint64_t ExecutionCount;
-  unsigned RegionCount;
-  bool Mapped;
-
-  LineCoverageStats() : ExecutionCount(0), RegionCount(0), Mapped(false) {}
-
-  bool isMapped() const { return Mapped; }
-
-  bool hasMultipleRegions() const { return RegionCount > 1; }
-
-  void addRegionStartCount(uint64_t Count) {
-    // The max of all region starts is the most interesting value.
-    addRegionCount(RegionCount ? std::max(ExecutionCount, Count) : Count);
-    ++RegionCount;
-  }
-
-  void addRegionCount(uint64_t Count) {
-    Mapped = true;
-    ExecutionCount = Count;
-  }
-};
-
 /// \brief A file manager that handles format-aware file creation.
 class CoveragePrinter {
 public:
@@ -134,7 +114,8 @@
 
   /// \brief Create an index which lists reports for the given source files.
   virtual Error createIndexFile(ArrayRef<std::string> SourceFiles,
-                                const coverage::CoverageMapping &Coverage) = 0;
+                                const CoverageMapping &Coverage,
+                                const CoverageFiltersMatchAll &Filters) = 0;
 
   /// @}
 };
@@ -155,7 +136,7 @@
   const CoverageViewOptions &Options;
 
   /// Complete coverage information about the source on display.
-  coverage::CoverageData CoverageInfo;
+  CoverageData CoverageInfo;
 
   /// A container for all expansions (e.g macros) in the source on display.
   std::vector<ExpansionView> ExpansionSubViews;
@@ -175,7 +156,7 @@
     LineRef(StringRef Line, int64_t LineNo) : Line(Line), LineNo(LineNo) {}
   };
 
-  using CoverageSegmentArray = ArrayRef<const coverage::CoverageSegment *>;
+  using CoverageSegmentArray = ArrayRef<const CoverageSegment *>;
 
   /// @name Rendering Interface
   /// @{
@@ -200,8 +181,7 @@
 
   /// \brief Render a source line with highlighting.
   virtual void renderLine(raw_ostream &OS, LineRef L,
-                          const coverage::CoverageSegment *WrappedSegment,
-                          CoverageSegmentArray Segments, unsigned ExpansionCol,
+                          const LineCoverageStats &LCS, unsigned ExpansionCol,
                           unsigned ViewDepth) = 0;
 
   /// \brief Render the line's execution count column.
@@ -213,15 +193,14 @@
 
   /// \brief Render all the region's execution counts on a line.
   virtual void renderRegionMarkers(raw_ostream &OS,
-                                   CoverageSegmentArray Segments,
+                                   const LineCoverageStats &Line,
                                    unsigned ViewDepth) = 0;
 
   /// \brief Render the site of an expansion.
-  virtual void
-  renderExpansionSite(raw_ostream &OS, LineRef L,
-                      const coverage::CoverageSegment *WrappedSegment,
-                      CoverageSegmentArray Segments, unsigned ExpansionCol,
-                      unsigned ViewDepth) = 0;
+  virtual void renderExpansionSite(raw_ostream &OS, LineRef L,
+                                   const LineCoverageStats &LCS,
+                                   unsigned ExpansionCol,
+                                   unsigned ViewDepth) = 0;
 
   /// \brief Render an expansion view and any nested views.
   virtual void renderExpansionView(raw_ostream &OS, ExpansionView &ESV,
@@ -246,22 +225,21 @@
   static std::string formatCount(uint64_t N);
 
   /// \brief Check if region marker output is expected for a line.
-  bool shouldRenderRegionMarkers(bool LineHasMultipleRegions) const;
+  bool shouldRenderRegionMarkers(CoverageSegmentArray Segments) const;
 
   /// \brief Check if there are any sub-views attached to this view.
   bool hasSubViews() const;
 
   SourceCoverageView(StringRef SourceName, const MemoryBuffer &File,
                      const CoverageViewOptions &Options,
-                     coverage::CoverageData &&CoverageInfo)
+                     CoverageData &&CoverageInfo)
       : SourceName(SourceName), File(File), Options(Options),
         CoverageInfo(std::move(CoverageInfo)) {}
 
 public:
   static std::unique_ptr<SourceCoverageView>
   create(StringRef SourceName, const MemoryBuffer &File,
-         const CoverageViewOptions &Options,
-         coverage::CoverageData &&CoverageInfo);
+         const CoverageViewOptions &Options, CoverageData &&CoverageInfo);
 
   virtual ~SourceCoverageView() {}
 
@@ -271,7 +249,7 @@
   const CoverageViewOptions &getOptions() const { return Options; }
 
   /// \brief Add an expansion subview to this view.
-  void addExpansion(const coverage::CounterMappingRegion &Region,
+  void addExpansion(const CounterMappingRegion &Region,
                     std::unique_ptr<SourceCoverageView> View);
 
   /// \brief Add a function instantiation subview to this view.
@@ -281,7 +259,7 @@
   /// \brief Print the code coverage information for a specific portion of a
   /// source file to the output stream.
   void print(raw_ostream &OS, bool WholeFile, bool ShowSourceName,
-             unsigned ViewDepth = 0);
+             bool ShowTitle, unsigned ViewDepth = 0);
 };
 
 } // namespace llvm