diff options
author | Alan Phipps <a-phipps@ti.com> | 2023-09-18 15:49:56 -0500 |
---|---|---|
committer | Alan Phipps <a-phipps@ti.com> | 2023-09-20 15:30:47 -0500 |
commit | 618a22144db5e45da8c95dc22064103e1b5e5b71 (patch) | |
tree | 3d354382909b78f7293bbce1e6e00351b6ff59c6 /llvm/tools/llvm-cov/SourceCoverageView.h | |
parent | 33dfd90700a11fb39802d0b1ab500f3a8efd7e78 (diff) | |
download | llvm-618a22144db5e45da8c95dc22064103e1b5e5b71.zip llvm-618a22144db5e45da8c95dc22064103e1b5e5b71.tar.gz llvm-618a22144db5e45da8c95dc22064103e1b5e5b71.tar.bz2 |
[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, |