Closed musnows closed 7 months ago
lcov/geninfo/genhtml try to apply filtering only to languages whose syntax they think they understand - so we filter C/C++ and Verilog - but not python/java/etc.
The tool identifies the language of particular source file by looking at the filename - by default, 'c|h|i||C|H|I|icc|cpp|cc|cxx|hh|hpp|hxx'
.
You can change this via your lcovrc file or via the command line option --rc c_file_extension='h|inl|...'
See the lcovrc man page for more details.
The man page description of the --filter
option should probably be modified to clarify how the tool decides to apply filtering (or not), and perhaps the tools should notify the user when filtering is being skipped due to lack of language support. (Such notification would need to be off by default - which would kind of defeat the purpose, as you would need to know about language restrictions to know to turn on the notification...and which point, you didn't need to be notified.)
thanks for your help, I checkout the lcovrc man page, it works after add this options to lcov/genhtml command
--rc c_file_extensions=c,cpp,hpp,h,inl
Here is a lite demo for this error
code file
myfunc.h
myfunc.inl
test.cpp
complie command & tools version
tools version:
(Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
lcov result
In this demo, the
test_string_plus
andtest_string_plus_inl
are exactly the same, but lcov report shows like this.gcov result
I also run
gcov -b -c -o . test.cpp
command to generate gcov file. The branch coverage of these two functions is the same in the gcov file, so I think the problem here is that the--filter branch
option does not have an effect on the.inl
file.Excerpt from gcov file 👇
myfunc.h
myfunc.inl
The temporary solution I am currently using is to move the contents of
.inl
back to the.h
file and change.h
to.hpp
, which--filter branch
options could work perfectly.