-
Notifications
You must be signed in to change notification settings - Fork 13.5k
llvm-cov: Introduce --binary-counters
#120841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
llvm/tools/llvm-cov/CodeCoverage.cpp
Outdated
@@ -1023,6 +1023,11 @@ int CodeCoverageTool::doShow(int argc, const char **argv, | |||
cl::alias ShowOutputDirectoryA("o", cl::desc("Alias for --output-dir"), | |||
cl::aliasopt(ShowOutputDirectory)); | |||
|
|||
cl::opt<bool> BinaryCounters( | |||
"binary-counters", cl::Optional, | |||
cl::desc("Show 1/0 instead of actual counter values."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might help coverage noobs a little to make it clear that 1 == covered, 0 == covered.
Show when source is covered (1) or uncovered (0) instead of showing actual counter values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, with rewording lines/branches
since counters belong line and branches.
@@ -266,6 +268,10 @@ class SourceCoverageView { | |||
/// digits. | |||
static std::string formatCount(uint64_t N); | |||
|
|||
uint64_t Count1(uint64_t N) const { return (N && BinaryCounters ? 1 : N); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does more than count ones, can you give it a more descriptive name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer shorter names since they (Count1
and formatCount1
) are replacements of Count
and formatCount
.
That said, they appear in fewer lines. BinaryCount
/formatBinaryCount
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BinaryCount + formatBinaryCount SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -266,6 +268,10 @@ class SourceCoverageView { | |||
/// digits. | |||
static std::string formatCount(uint64_t N); | |||
|
|||
uint64_t Count1(uint64_t N) const { return (N && BinaryCounters ? 1 : N); } | |||
|
|||
std::string formatCount1(uint64_t N) const { return formatCount(Count1(N)); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
Conflicts: llvm/test/tools/llvm-cov/branch-macros.test llvm/test/tools/llvm-cov/showLineExecutionCounts.test
@MaskRay Could you take a look, please? Thanks! |
llvm/tools/llvm-cov/CodeCoverage.cpp
Outdated
@@ -1023,6 +1023,12 @@ int CodeCoverageTool::doShow(int argc, const char **argv, | |||
cl::alias ShowOutputDirectoryA("o", cl::desc("Alias for --output-dir"), | |||
cl::aliasopt(ShowOutputDirectory)); | |||
|
|||
cl::opt<bool> BinaryCounters( | |||
"binary-counters", cl::Optional, | |||
cl::desc("Show when lines/branches are covered (1) or uncovered (0) " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show binary counters instead of integer execution counts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "Show binary counters (1/0) in lines and branches instead of..."?
@@ -16,8 +17,10 @@ | |||
// | |||
// Test html output. | |||
// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.dir/html -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | |||
// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.dir/html.binary -binary-counters=true -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just -binary-counters
. =true
is a weird syntax that most command line parsing libraries don't allow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've dropped =true
. I like it, though.
`SingleByteCoverage` is not per-region attribute at least. Move it into `CoverageData` since it comes from `profdata`. Depends on: #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.