[llvm-bugs] [Bug 44011] New: line coverage shows coverage of unreachable whitespace in switch statements
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 15 07:00:06 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=44011
Bug ID: 44011
Summary: line coverage shows coverage of unreachable whitespace
in switch statements
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: hans at chromium.org
CC: efriedma at quicinc.com, htmldeveloper at gmail.com,
llvm-bugs at lists.llvm.org, vsk at apple.com
Example:
$ cat /tmp/c.c
int main(int argc, char **argv) {
switch (argc) {
case 1:
return 0;
default:
return 1;
}
}
$ bin/clang -fcoverage-mapping -fprofile-instr-generate /tmp/c.c -Xclang
-dump-coverage-mapping && ./a.out && bin/llvm-profdata merge default.profraw -o
default.profdata && bin/llvm-cov show a.out -instr-profile=default.profdata
main:
File 0, 1:33 -> 10:2 = #0
File 0, 4:3 -> 5:13 = #2
File 0, 7:3 -> 8:13 = #3
1| 1|int main(int argc, char **argv) {
2| 1| switch (argc) {
3| 1|
4| 1| case 1:
5| 1| return 0;
6| 1|
7| 1| default:
8| 0| return 1;
9| 1| }
10| 1|}
Note how lines 3 and 6 are shown as covered, even though control can never pass
through those lines.
Line 7 is also marked as executed, though a color terminal reveals it's only
the whitespace before "default" that was hit.
I think what's happening is that the whitespace inside the switch ends up in
region #0, which is used for the function body, which is obviously marked
executed.
Looking at https://bugs.llvm.org/show_bug.cgi?id=34612, perhaps the fix here is
to insert "gap" regions in between the switch cases. Or, would it work if we
emitted one big "gap" region for the whole switch body, kind of nested
underneath the regions for the cases?
+eli and +vedant who seem familiar with this area.
There are several similar bugs. I'm guessing most are due to the same problem:
https://bugs.llvm.org/show_bug.cgi?id=37072
https://bugs.llvm.org/show_bug.cgi?id=37124
https://bugs.llvm.org/show_bug.cgi?id=41821
(This was reported in Chromium: https://crbug.com/1024987)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191115/2e4dfd4e/attachment.html>
More information about the llvm-bugs
mailing list