[cfe-dev] [llvm-cov] Differences in coverage report and the JSON summary object

Łukasz Machowski via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 26 04:32:55 PDT 2017


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?

I have shared all used and generated files at:
https://drive.google.com/open?id=0Bw3a4ra_CUr3S09OV0JOaDVmX00

kind regards,
Łukasz Machowski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170426/ae306416/attachment.html>


More information about the cfe-dev mailing list