Skip to content

[llvm-cov] Improve line count for wrapped segments #143910

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

justincady
Copy link
Contributor

Adjust line coverage calculation to report the count of the wrapped
segment only if there are no regions starting on that line.

This resolves the nested macro scenario reported in #140893. Because
the inner macro creates a new region, the counter for the outer macro
is not considered.

As it stands the diff passes all existing tests, but the modifications
required indicate a broad reporting impact. I suspect when most users
absorbed this change their coverage numbers would decrease, though I
believe those numbers would be more accurate.

This is a significant change in reporting. I am not certain it is the
right approach, and thus I am posting it as a draft for consideration.
More testing is likely required to iron out other inconsistencies that
may be accidentally introduced. It's possible there are other, more
desirable approaches to resolve #140893 (and other similar issues noted
in that bug).

Fixes #140893

Adjust line coverage calculation to report the count of the wrapped
segment only if there are no regions starting on that line.

This resolves the nested macro scenario reported in llvm#140893. Because
the inner macro creates a new region, the counter for the outer macro
is not considered.

As it stands the diff passes all existing tests, but the modifications
required indicate a broad reporting impact. I suspect when most users
absorbed this change their coverage numbers would decrease, though I
believe those numbers would be more accurate.

This is a significant change in reporting. I am not certain it is the
right approach, and thus I am posting it as a draft for consideration.
More testing is likely required to iron out other inconsistencies that
may be accidentally introduced. It's possible there are other, more
desirable approaches to resolve llvm#140893 (and other similar issues noted
in that bug).

Fixes llvm#140893
@justincady justincady requested a review from chapuni June 12, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[coverage] nested macro with unused branch leads to incorrect coverage
1 participant