<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/78096>78096</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
coverage regions should be for each subexpressions instead of whole blocks like function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hanickadot
</td>
</tr>
</table>
<pre>
Because coverage region is created for whole function and if there is no condition. Statements after throwing expression will be marked as covered, but they are not.
```c++
void this_will_throw() {
throw 42;
}
void bad_coverage_for_exceptions() {
puts("before");
this_will_throw();
puts("this shouldn't be covered but is");
}
void exception_test() {
try {
bad_coverage_for_exceptions();
puts("this shouldn't be covered but is");
} catch (int) {
puts("exception");
}
}
```
When called `exception_test()` the resulting coverage is:
<img width="518" alt="Screenshot 2024-01-14 at 12 12 28" src="https://github.com/llvm/llvm-project/assets/6557263/67ac7f5c-d870-44be-85e6-ac4b27f66166">
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVMuO6zYM_Rp5QySQ5WcWXnRumh-4iy4DPWhbHUUKJHpy5-8LOU9MByiKCwiJRNLH5xzRlCnZySMOrHljzb6QC80hDrP0Vr9LE6hQwXwOb6jlkhB0-MAoJ4SIkw0ebAIdURIaGEOEyxwcwrh4TTkrvQE7As0YMZf6ADp4Y3NyCz9JEp7QUwI5EkagOYaL9RPgr3PElDLExToHCuEk4zsakOlKAQ0TP0AtlME_QUYEH2jL-J7xP26_Lb8uzcRbXmv0I1gDNNt0zMjH9ZVM9EzsgHW3GrgygVqw6hZi3f4Ve0VR0hzvfhzHEI_4S-M5a0v_RjwvdI0KhWOIyIRgYvfA_57SM_3yfK6ENIfFGc9ER9mdmyerITZ9wf6O-4PqkTDRNwbEz5fjfyp9IfpbVAFYtwctSc_ARG89feH1iv4g8RXkKfixuffCqxF_zehBS-fQAGv5d5awlucGg4hpcZRb8_EB2MSqe6dVP-xpgos1NLNqz4RoykwQpKPr-aeOiD7NgUBwUW94uSlrkASlyGuVAynqa_VMdF7RxYGJw2RpXtRWhxMTB-c-7n-bcwx_oyYmDjIlzK4c2qbpRFvlXSd1NzZ6Y_qOb-pa4aZvsN1IXSvRjW1btm32rfrzqqEwQ2V21U4WOJQdb0TFd21VzEOjjRyNanrVKOxH3XHkKBRveS8rJfvCDlkSL8u6LMuWi23TGrlrStEJ09St4qzmeJLWbTPrbYhTYVNacOh6vmsLJxW6tI4fITxeYE1mas2-iMOqVC1TYjV3NlF6opAlh8OXiXTvt9xqeSKh1DOkRT1HSgLrE6E0EMbbwFIu6PcEzr4_h1exRDf875tYyeebWMX9EwAA__9rmaSY">