Closed KineticTheory closed 4 months ago
Known bug/issue.
If you look at the gcov output, you will notice the unexercised end line. In some senses, lcov is a very simple translator which is showing you the data generated by another tool. Basically: lcov is just reporting bad data it got from gcov :-(
However: there is a workaround.
See the doc for the --filter
option in the 'genhtml' and/or 'lcov' man page.
In this case, you probably wanted:
$ lcov --capture -o filtered.info --filter brace -d myBuildDir ....
All the component tools support filtering - but you probably want to do it at the 'capture' stage rather than at HTML report generation.
The reason is that you really do want those artifacts eliminated - they are just wrong - and you might want clean data in the future, say for pre-release differential analysis. This is particularly true when some or all of the code is generated and so not easily available later on.
In contrast: region
filtering is probably best done late - as you may want to check your result with and without exclusions; experience suggests that bugs often hide there. (Differential reports with or without subsetting are an easy way to do this.)
You are likely to want to use --filter branch
if you want to measure branch coverage in C++ code - otherwise, the reports are just too noisy to be useful.
GCC is not alone in generating bogus artifacts. You will find them in llvm data as well. Sadly, some of the LLVM artifacts are not so easily eliminated.
Hope this helps
Henry
Forgot to mention: in certain cases, the coverpoint on the closing brace represents the 'else' of a terminal conditional. In that case, that it is meaningful - and should NOT be removed/ignored.
Thank you for providing a detailed explanation.
One more thing I forgot to mention:
This can be very confusing.
To help avoid the issue, lcov/genhtml/geninfo support a --version-script
callback mechanism - to insert version data into the coverage DB and to check for version consistency for filtering, aggregation, report generation, etc.
One more obvious statement (sorry!):
If you are interested to check what the filters actually did, you can capture data with filtering and again without filtering - then generate a differential report, comparing those two. If unfiltered is passed as --baseline-fille
and filter is passed as current, then the remove coverpoints will show up as EUB and ECB.
Summary
lcov
is reporting that the closing brace at the end of a function definition is untested -- even when thereturn
on the previous line is covered. This doesn't occur for most function blocks in my project but I am seeing dozens of these reports. This seems like a bug.Example:
Is this a known issue? I'm using
master
from Jan 24, 2024.