The current coverage implementation doesn't handle region termination
very precisely. Take for example an if statement with a return:
void f() { if (true) { return; // The `if' body's region is terminated here. } // This line gets the same coverage as the `if' condition. }
If the function f is called, the line containing the comment will be
marked as having executed once, which is not correct. (Edit: To clarify,
I meant the second comment.)
The solution here is to create a deferred region after terminating a
region. The deferred region is completed once the start location of the
next statement is known, and is then pushed onto the region stack.
In the cases where it's not possible to complete a deferred region, it
can safely be dropped.
Example output (pre-patch):
Example output (post-patch):
Testing: lit test updates, a stage2 coverage-enabled build of clang
Might be better to use && to avoid extra work.