diff options
author | Alan Phipps <a-phipps@ti.com> | 2023-12-13 14:13:56 -0600 |
---|---|---|
committer | Alan Phipps <a-phipps@ti.com> | 2023-12-13 15:10:05 -0600 |
commit | 8ecbb0404d740d1ab173554e47cef39cd5e3ef8c (patch) | |
tree | 93cc0afc02965f5ccc27dc83c7389662ef772661 /llvm/tools/llvm-cov/SourceCoverageView.h | |
parent | 14d7e0bb0f75066da5d2eff718b6d59215a02077 (diff) | |
download | llvm-8ecbb0404d740d1ab173554e47cef39cd5e3ef8c.zip llvm-8ecbb0404d740d1ab173554e47cef39cd5e3ef8c.tar.gz llvm-8ecbb0404d740d1ab173554e47cef39cd5e3ef8c.tar.bz2 |
Reland "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code Coverage (2/3)"
Part 2 of 3. This includes the Visualization and Evaluation components.
Differential Revision: https://reviews.llvm.org/D138847
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageView.h')
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageView.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.h b/llvm/tools/llvm-cov/SourceCoverageView.h index c07595f..2e3fa8e 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.h +++ b/llvm/tools/llvm-cov/SourceCoverageView.h @@ -84,6 +84,23 @@ struct BranchView { } }; +/// A view that represents one or more MCDC regions on a given source line. +struct MCDCView { + std::vector<MCDCRecord> Records; + std::unique_ptr<SourceCoverageView> View; + unsigned Line; + + MCDCView(unsigned Line, ArrayRef<MCDCRecord> Records, + std::unique_ptr<SourceCoverageView> View) + : Records(Records), View(std::move(View)), Line(Line) {} + + unsigned getLine() const { return Line; } + + friend bool operator<(const MCDCView &LHS, const MCDCView &RHS) { + return LHS.Line < RHS.Line; + } +}; + /// A file manager that handles format-aware file creation. class CoveragePrinter { public: @@ -160,6 +177,9 @@ class SourceCoverageView { /// A container for all branches in the source on display. std::vector<BranchView> BranchSubViews; + /// A container for all MCDC records in the source on display. + std::vector<MCDCView> MCDCSubViews; + /// A container for all instantiations (e.g template functions) in the source /// on display. std::vector<InstantiationView> InstantiationSubViews; @@ -233,6 +253,10 @@ protected: virtual void renderBranchView(raw_ostream &OS, BranchView &BRV, unsigned ViewDepth) = 0; + /// Render an MCDC view. + virtual void renderMCDCView(raw_ostream &OS, MCDCView &BRV, + unsigned ViewDepth) = 0; + /// Render \p Title, a project title if one is available, and the /// created time. virtual void renderTitle(raw_ostream &OS, StringRef CellText) = 0; @@ -283,6 +307,10 @@ public: void addBranch(unsigned Line, ArrayRef<CountedRegion> Regions, std::unique_ptr<SourceCoverageView> View); + /// Add an MCDC subview to this view. + void addMCDCRecord(unsigned Line, ArrayRef<MCDCRecord> Records, + std::unique_ptr<SourceCoverageView> View); + /// 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, |