<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 gcov does not add "(throw)" to branch statements"
href="https://bugs.llvm.org/show_bug.cgi?id=48162">48162</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llvm-cov gcov does not add "(throw)" to branch statements
</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>enhancement
</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>John.Forrest@gbgplc.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24158" name="attach_24158" title="Sample files">attachment 24158</a> <a href="attachment.cgi?id=24158&action=edit" title="Sample files">[details]</a></span>
Sample files
I am using clang++ to generate coverage reports as part of Sonarqube analysis.
This expects the output from gcovr and we use the latter telling it to use
"llvm-cov gcov" as documented. We've hit the common(?) problem where the
reported coverage figures are low, due it seems to extra branches being added
for exception support. The recommended approach is to add flags
--exclude-throw-branches --exclude-unreachable-branches to gcovr. This has been
observed to help a little but not much.
Experimentation suggests that this relates to the llvm toolchain. gcov itself
(obviously what gcovr expects) adds extra tags to the branch statements with
"(throw)" and "(fallthrough)". It is these tags that gcovr uses to support
--exclude-throw=branches. llvm-cov does not, so gcovr assumes they are "normal"
branches - it has no option. E.g. compare (gcc/gcov):
branch 1 taken 1 (fallthrough)
branch 2 taken 0 (throw)
with (clang/llvm-cov gcov):
branch 0 taken 1
branch 1 taken 0
The attached zip contains a sample program and the respective output of
compiling (with "-O0 -g --coverage"), running and then extracting coverage with
flags "--branch-counts --branch-probabilities --preserve-paths". gcc is v8.3.1.
llvm is 11.0.</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>