[llvm-bugs] [Bug 45849] New: llvm-cov: macro constant in if expression lead to incorrect coverage
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 8 11:29:03 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45849
Bug ID: 45849
Summary: llvm-cov: macro constant in if expression lead to
incorrect coverage
Product: Runtime Libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: libprofile library
Assignee: unassignedbugs at nondot.org
Reporter: yangyibiao at hust.edu.cn
CC: llvm-bugs at lists.llvm.org
$ clang --version
clang version 11.0.0 (/home/yibiao/.cache/yay/llvm-git/llvm-project
871beba234a83a2a02da9dedbd59b91a1bfbd7af)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang -O0 -w -fcoverage-mapping -fprofile-instr-generate=small.profraw
small.c; ./a.out; llvm-profdata merge small.profraw -o small.profdata; llvm-cov
show a.out -instr-profile=small.profdata small.c > small.c.lcov; cat
small.c.lcov
1| 1|#define N 6
2| |
3| 1|int main() {
4| 1| if (10 < 6)
5| 0| return 1;
6| 1| if (10 < N)
7| 1| return 2;
8| 1|}
N is a constant 6 which defined as macro in Line 1.
Line 7 is wrongly marked as executed. The execution count of Line 5 is correct.
$ cat small.c
#define N 6
int main() {
if (10 < 6)
return 1;
if (10 < N)
return 2;
}
--
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/20200508/dd7de06a/attachment-0001.html>
More information about the llvm-bugs
mailing list