Clang coverage marks ctor as uninstrumented

Source code: shill/wifi/wifi.cc - chromiumos/platform2 - Git at Google

We are using clang to run unit tests and generate coverage reports for this file.

The llvm marks the ctor block lines from 154-195 as uninstrumented. Infact we believe they should be marked as instrumented. I am attaching the screenshot of the code coverage report. As you can see the lines below 196 and lines above 145 are considered as instrumented, while lines 154-194 are not.

Can someone please clarify why ctor calls are not considered as src code lines by the compiler?

Because line 195 is the start position of the constructor (identified by left brace), lines 154-194 are not considered covered by frontend. Lines starting from 195 are instrumented and covered, so this constructor is instrumented.

Thank you for responding.

brace-init-list elements from 154 to 194 are evaluated in scope of the constructor, and result in executable instructions. Which means they have been executed. Why then they are considered uninstrumented?

I guess it’s simply because at the clang coverage instrumentation stage, the start location of a function is identified by the left brace of the function body. However, I think it can be improved to use ‘:’ after ctor as the start location if it exists otherwise use ‘{’.

On Thu, Sep 14, 2023 at 12:55 PM kshitij via LLVM Discussion Forums <notifications@llvm.discoursemail.com> wrote:

kshitij
September 14

Thank you for responding.

brace-init-list elements from 154 to 194 are evaluated in scope of the constructor, and result in executable instructions. Which means they have been executed. Why then they are considered uninstrumented?


Visit Topic or reply to this email to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, click here.

I just sent a [Coverage] Add coverage for constructor member initializers. by ZequanWu · Pull Request #66441 · llvm/llvm-project · GitHub to fix it.

Wow!

Thank you so much for the fix!
You are awesome.