-
Notifications
You must be signed in to change notification settings - Fork 253
Closed as not planned
Closed as not planned
Copy link
Description
Versions
Running LCOV version 1.12
on macOS Sierra 10.12.5
and g++ Apple LLVM version 8.1.0 (clang-802.0.42)
Code snippet
Consider the following simple c++ code:
#include <iostream>
int myFn(int x) {
return x * x;
}
int main(int argc, char *argv[]) {
--argc, ++argv;
std::cout << myFn(12) << std::endl;
return 0;
}
Coverage result
Line data Source code
1 : #include <iostream>
2 :
3 0 : int myFn(int x) {
4 1 : return x * x;
5 : }
6 :
7 0 : int main(int argc, char *argv[]) {
8 1 : --argc, ++argv;
9 :
10 1 : std::cout << myFn(12) << std::endl;
11 1 : return 0;
12 : }
PROBLEM: lines 3 and 7 are reported executable but not hit, leading to mis coverage report.
Steps to reproduce
echo "--------------"
echo "-- Building --"
g++ --coverage -O0 -g0 test.cpp
echo "----------------------"
echo "-- Zeroing counters --"
lcov --zerocounters -d ./
echo "---------------------"
echo "-- Initial capture --"
lcov --capture --no-external --initial -d ./ --gcov-tool covwrap.sh -o base.info
echo "-------------"
echo "-- Running --"
./a.out
echo "---------------"
echo "-- Capturing --"
lcov --capture -d ./ --gcov-tool covwrap.sh -o test.info
echo "---------------"
echo "-- Combining --"
lcov -a base.info -a test.info -o total.info
echo "----------"
echo "-- HTML --"
genhtml total.info -o ./html
(where covwrap.sh
is simply:
#!/bin/bash
exec llvm-cov-mp-3.9 gcov "$@"
Output
--------------
-- Building --
----------------------
-- Zeroing counters --
Deleting all .da files in ./ and subdirectories
Done.
---------------------
-- Initial capture --
Capturing coverage data from ./
Found gcov version: 3.9.1
Found LLVM gcov version 3.4, which emulates gcov version 4.2
Scanning ./ for .gcno files ...
Found 1 graph files in ./
Processing test.gcno
ignoring data for external file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale
ignoring data for external file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios
ignoring data for external file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream
Finished .info-file creation
-------------
-- Running --
144
---------------
-- Capturing --
Capturing coverage data from ./
Found gcov version: 3.9.1
Found LLVM gcov version 3.4, which emulates gcov version 4.2
Scanning ./ for .gcda files ...
Found 1 data files in ./
Processing test.gcda
Finished .info-file creation
---------------
-- Combining --
Combining tracefiles.
Reading tracefile base.info
Reading tracefile test.info
Writing data to total.info
Summary coverage rate:
lines......: 78.6% (11 of 14 lines)
functions..: 100.0% (7 of 7 functions)
branches...: no data found
----------
-- HTML --
Reading data file total.info
Found 4 entries.
Found common filename prefix "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++"
Writing .css and .png files.
Generating output.
Processing file v1/ostream
Processing file v1/__locale
Processing file v1/ios
Processing file /bb/tmp/test.cpp
Writing directory view page.
Overall coverage rate:
lines......: 78.6% (11 of 14 lines)
functions..: 100.0% (7 of 7 functions)
Metadata
Metadata
Assignees
Labels
No labels