My llvm-cov reports show phantom executable lines in some cases.
It's 100 reproducible.
It appears on random places (see attached images), even for unexistent lines.
My investigations show that it appears on __cxx_global_var_init* processing.
For example here is an output
-: 397:/*------------------------------------------------------------------------------------------------*/ -: 398:template<typename T> #####: 399:void putGlmVec(boost::property_tree::ptree* const parameter_node, -: 400: boost::any const& value, #####: 401: std::string const& type) -: 402:/*------------------------------------------------------------------------------------------------*/ -: 403:{
Line 401 is definitely false-positive. And here is debug data for this file for line 401
> gdb --args llvm-project/build/bin/llvm-cov gcov ./src/Settings/PersistenceAdapterSample/src/CMakeFiles/C_MXR_Settings_PersistenceAdapterSample_Base_Impl.dir/CPersistenceAdapterImpl.cpp.gcno (gdb) b GCOV.cpp:689 (gdb) condition 1 lineNum==401 (gdb) r (gdb) p si.filename.Data $4 = 0x19f3020 "src/Settings/PersistenceAdapterSample/src/CPersistenceAdapterImpl.cpp" (gdb) p f.Name $7 = {static npos = 18446744073709551615, Data = 0x7ffff784faa0 "__cxx_global_var_init.44", Length = 24} (gdb) p lineNum $8 = 401 (gdb) p f.blocks[4]->lines[0] $29 = (unsigned int &) @0x1aa0300: 401 (gdb) p f.startLine $9 = 0 (gdb) p f.startColumn $10 = 0 (gdb) p f.endLine $11 = 0
So, at line 401 llvm-cov found executable source code of function __cxx_global_var_init.44, while there is actually a definition of putGlmVec().
It's definitely bug. For project with ~100K lines I have many similar cases.
Probably, my patch is not the best way to fix it and there are better ways to filter such functions.
If so, please direct me.