diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
| commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
| tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /tools/llvm-cov/SourceCoverageView.h | |
| parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) | |
Notes
Diffstat (limited to 'tools/llvm-cov/SourceCoverageView.h')
| -rw-r--r-- | tools/llvm-cov/SourceCoverageView.h | 64 |
1 files changed, 21 insertions, 43 deletions
diff --git a/tools/llvm-cov/SourceCoverageView.h b/tools/llvm-cov/SourceCoverageView.h index 9cb608fed608..7f58ea5d7be8 100644 --- a/tools/llvm-cov/SourceCoverageView.h +++ b/tools/llvm-cov/SourceCoverageView.h @@ -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 @@ struct InstantiationView { } }; -/// \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 @@ public: /// \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 @@ class SourceCoverageView { 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 @@ protected: 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 @@ protected: /// \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 @@ protected: /// \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 @@ protected: 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(const LineCoverageStats &LCS) 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 @@ public: 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 @@ public: /// \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 |
