aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/SourceCoverageView.h
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2024-12-27 19:48:30 +0900
committerGitHub <noreply@github.com>2024-12-27 19:48:30 +0900
commit223521b13e7465bc177f43e22de526b777d6ff74 (patch)
treedfed43bba84ac0741bf9a2febd22ee9c478954ce /llvm/tools/llvm-cov/SourceCoverageView.h
parentac8bb7353a7fe79cd99b3c041d5a153517c31abc (diff)
downloadllvm-223521b13e7465bc177f43e22de526b777d6ff74.zip
llvm-223521b13e7465bc177f43e22de526b777d6ff74.tar.gz
llvm-223521b13e7465bc177f43e22de526b777d6ff74.tar.bz2
llvm-cov: Introduce `--binary-counters` (#120841)
In `llvm-cov show`, this option rounds counters (line, branch) to `[1,0]` at rendering. This will be useful when the number of counts doesn't interest but **Covered/uncoverd** does.
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageView.h')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageView.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.h b/llvm/tools/llvm-cov/SourceCoverageView.h
index 2b1570d..0b4e397 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.h
+++ b/llvm/tools/llvm-cov/SourceCoverageView.h
@@ -180,6 +180,8 @@ class SourceCoverageView {
/// on display.
std::vector<InstantiationView> InstantiationSubViews;
+ bool BinaryCounters;
+
/// Get the first uncovered line number for the source file.
unsigned getFirstUncoveredLineNo();
@@ -266,6 +268,14 @@ protected:
/// digits.
static std::string formatCount(uint64_t N);
+ uint64_t BinaryCount(uint64_t N) const {
+ return (N && BinaryCounters ? 1 : N);
+ }
+
+ std::string formatBinaryCount(uint64_t N) const {
+ return formatCount(BinaryCount(N));
+ }
+
/// Check if region marker output is expected for a line.
bool shouldRenderRegionMarkers(const LineCoverageStats &LCS) const;
@@ -276,7 +286,8 @@ protected:
const CoverageViewOptions &Options,
CoverageData &&CoverageInfo)
: SourceName(SourceName), File(File), Options(Options),
- CoverageInfo(std::move(CoverageInfo)) {}
+ CoverageInfo(std::move(CoverageInfo)),
+ BinaryCounters(Options.BinaryCounters) {}
public:
static std::unique_ptr<SourceCoverageView>