Created attachment 24158
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.
temp-gcov-example.zip
(1739 bytes, application/x-zip-compressed)