Open
Description
In code with conditions in macros, the first line after the condition has the same count as the condition itself even if it is not executed.
llvm-cov show
results in the following:
1| |# define RET \
2| 1| if (0) \
3| 1| return 1; \
4| 1| return 0;
5| |
6| 1|int main() {
7| 1| RET
8| 1|}
With a purple line count 1
in line 2 and a red background on the return 1;
in line 3.
Using braces on dedicated lines kind of circumvents the issue:
1| |# define RET \
2| 1| if (0) \
3| 1| { \
4| 0| return 1; \
5| 0| } \
6| 1| return 0;
7| |
8| 1|int main() {
9| 1| RET
10| 1|}
Again, with a purple line count 1
in line 2, but now the red background spans from {
to }
.
Removing the macro while containing the backslashes leads to the correct line counts:
1| 1|int main() {
2| 1| if (0) \
3| 0| return 1; \
4| 1| return 0;
5| 1|}
The line count calculation inside and outside macros should be consistent.