Hi @manuyavuz-pointr,
I gave a look at llvm-cov
format output and I don’t think it can be used to report branch coverage. In order to report branch coverage, for a given line we need to know how many branches exist and how many branches are covered, such information is not available in it.
By looking at the easy example below you can see that branch coverage information is not available in llvm-cov
, region coverage is just marking uncovered regions which is not at all equivalent to branch coverage. In the example below not all branches are covered but all regions are covered and llvm-cov
report 100% coverage.
+ cat foo.cpp
int main() {
int a = 0;
int b = 1;
if (a == 1 || b == 1) {
}
return 0;
}
+ clang -v
Apple clang version 11.0.3 (clang-1103.0.32.29)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+ clang++ -fprofile-instr-generate -fcoverage-mapping foo.cpp -o foo
+ LLVM_PROFILE_FILE=foo.profraw
+ ./foo
+ llvm-profdata merge -sparse foo.profraw -o foo.profdata
+ llvm-cov report ./foo -instr-profile=foo.profdata -use-color=0
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/tmp/llvm-cov-test/foo.cpp 5 0 100.00% 1 0 100.00% 7 0 100.00%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL 5 0 100.00% 1 0 100.00% 7 0 100.00%
+ llvm-cov show ./foo -instr-profile=foo.profdata -show-line-counts-or-regions -use-color=0
1| |
2| 1|int main() {
3| 1| int a = 0;
4| 1| int b = 1;
5| 1| if (a == 1 || b == 1) {
6| 1| }
7| 1| return 0;
8| 1|}
+ llvm-cov export ./foo -instr-profile=foo.profdata
+ cat foo.json
{"data":[{"files":[{"expansions":[],"filename":"/tmp/llvm-cov-test/foo.cpp","segments":[[2,12,1,true,true],[5,7,1,true,true],[5,13,1,true,false],[5,17,1,true,true],[5,23,1,true,false],[5,25,1,true,true],[6,4,1,true,false],[8,2,0,false,false]],"summary":{"functions":{"count":1,"covered":1,"percent":100},"instantiations":{"count":1,"covered":1,"percent":100},"lines":{"count":7,"covered":7,"percent":100},"regions":{"count":5,"covered":5,"notcovered":0,"percent":100}}}],"functions":[{"count":1,"filenames":["/tmp/llvm-cov-test/foo.cpp"],"name":"main","regions":[[2,12,8,2,1,0,0,0],[5,7,5,13,1,0,0,0],[5,7,5,23,1,0,0,0],[5,17,5,23,1,0,0,0],[5,24,5,25,1,0,0,3],[5,25,6,4,1,0,0,0]]}],"totals":{"functions":{"count":1,"covered":1,"percent":100},"instantiations":{"count":1,"covered":1,"percent":100},"lines":{"count":7,"covered":7,"percent":100},"regions":{"count":5,"covered":5,"notcovered":0,"percent":100}}}],"type":"llvm.coverage.json.export","version":"2.0.0"}