<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - llvm-cov: wrong coverage for multiple calling a function with conditional operator statement"
href="https://bugs.llvm.org/show_bug.cgi?id=48818">48818</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llvm-cov: wrong coverage for multiple calling a function with conditional operator statement
</td>
</tr>
<tr>
<th>Product</th>
<td>Runtime Libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>libprofile library
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>yangyibiao@nju.edu.cn
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Consider this case:
...
$ cat small.c
int f(int i)
{
int r = (i-1) > 0 ? i : 0;
return r;
}
int main()
{
f(1);
f(2);
}
...
$ 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| |int f(int i)
2| 2|{
3| 1| int r = (i-1) > 0 ? i : 0;
4| 2| return r;
5| 2|}
6| |
7| |int main()
8| 1|{
9| 1| f(1);
10| 1| f(2);
11| 1|}
12| |
...
We can found that Line #3 is wrongly marked as execute 1 times. Line #3 should
be executed 2 times.
...
$ clang --version
Ubuntu clang version
12.0.0-++20210117052627+ed396212da41-1~exp1~20210117163329.287
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>