[cfe-dev] [llvm-cov] Differences in coverage report and the JSON summary object
Vedant Kumar via cfe-dev
cfe-dev at lists.llvm.org
Fri Apr 28 11:24:55 PDT 2017
Hi Łukasz,
> On Apr 26, 2017, at 4:32 AM, Łukasz Machowski via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> Hello everyone,
>
> During my llvm-cov usage I found some difference in llvm-cov out between llvm-cov generated text report and the JSON summary. I have presented it by the simple class.hpp file:
>
> 1) "llvm-cov show ..." output:
> -----------------------------------------------------------------
> Coverage Report
> Created: 2017-04-26 09:52
> /home/lumc/llvm_cov_test/class.hpp:
> 1| |template<typename T>
> 2| |class SampleTemplate
> 3| |{
> 4| |public:
> 5| | inline T SampleMethod(const T& a, const T& b)
> 6| 1| {
> 7| 1| #if DEFINE
> 8| | T ret = b;
> 9| | #else
> 10| 1| T ret = a;
> 11| 1| #endif
> 12| 1| return ret;
> 13| 1| }
> 14| |};
> -----------------------------------------------------------------
> here in the repert for class.hpp file I have 6 lines covered.
>
> 2) part of json generated by "llvm-cov export ...":
> -----------------------------------------------------------------
> ...
> "expansions": [],
> "filename": "/home/lumc/llvm_cov_test/class.hpp",
> "segments": [
> [
> 6,
> 4,
> 1,
> 1,
> 1
> ],
> [
> 7,
> 8,
> 0,
> 0,
> 1
> ],
> [
> 9,
> 8,
> 1,
> 1,
> 0
> ],
> [
> 13,
> 5,
> 0,
> 0,
> 0
> ]
> ],
> "summary": {
> "functions": {
> "count": 1,
> "covered": 1,
> "percent": 100
> },
> "instantiations": {
> "count": 1,
> "covered": 1,
> "percent": 100
> },
> "lines": {
> "count": 5,
> "covered": 5,
> "percent": 100
> },
> "regions": {
> "count": 1,
> "covered": 1,
> "notcovered": 0,
> "percent": 100
> }
> }
> ...
> -----------------------------------------------------
> but in "summary" object for the class.hpp file I have 5 lines only.
>
> Can you explain me from where this difference comes?
llvm-cov tries to make coverage reports look more natural by remembering the final coverage segment from the previous line, and using it to help determine the line coverage for the next line. Sometimes, this creates discrepancies in the line coverage statistics.
Line coverage should probably just be computed in one place, instead of two. I'd like to get rid of the one in CoverageSummaryInfo.cpp..
vedant
>
> I have shared all used and generated files at: https://drive.google.com/open?id=0Bw3a4ra_CUr3S09OV0JOaDVmX00
>
> kind regards,
> Łukasz Machowski
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list