-
Notifications
You must be signed in to change notification settings - Fork 284
Meaning of multiple X and V next to if statements #283
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
Comments
Hi @deblauwetom, thanks for these ideas! Gcov/gcovr/lcov use assembly code level coverage data, so they show the true branch coverage in the binary. This is neither good or bad, but this leads to many compiler-generated branches being included in the coverage calculation. For some use cases, it would be wrong to hide this information. But most of the time, these invisible branches are confusing. I started typing a lengthy response explaining why post-processing of the source code should not be done, but the TL;DR is: parsing C/C++ is complex, especially considering macros, and how compiler optimizations might affect branches. Also note that there are many C operators that branch: Gcov actually distinguishes normal code from code that is only reachable by exceptions. Currently, gcovr uses that to ignore uncovered lines that are only exception-reachable, but doesn't ignore branches that are only taken by exceptions. The problem is, this also applies to While the branch to the catch-clause is uncovered (✗), the code in the catch clause itself is ignored (white background) because it is only exception-reachable. The corresponding gcov report is:
(Note that on the I think I'll change this:
This will not be perfect, but the information for a perfect solution is unavailable in this case. |
Thanks for the comment! Just so I understand correctly: So currently it's almost impossible to show intuitive information with the output gcov gives you because you can't know if the branches are "exception generated" branches or "if-test" branches? |
Your understanding is correct, gcov does not provide enough info to attribute a given branch to a specific operator. I've written a FAQ entry that discusses C++ branch coverage, and added a new You can test this option in the gcovr development version (see the installation guide) or wait for the 4.2 release which I'll probably do later this month. |
Hi,
I installed gcovr and it works very well, really easy to use(and fast in comparison with lcov !).
Now I have a question that I did not find in the documentation.
When I see an "if()" statement, it sometimes contains multiple X and V's but it is only a simple statement for example
if (isValid(obj)) {
. So after some searching I understood that some other people using lcov also had this problem and that it is due to some exception handling that could happen in that if-statement. Then I found this code from a guy who filters lcov files just before they generate html output to "clean up" the if statements. See: https://github.com/gsauthof/imapdl/blob/master/ci/filterbr.pyI don't know if maybe something similar could be added to gcovr? That would be cool! Or maybe just that it is clear what checkmarks are about the total if-statement itself, and what is about parts of it. That would already solve the problem for me.
Best regards,
Tom,
The text was updated successfully, but these errors were encountered: