<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 17 February 2017 at 03:03, Michał Pszona via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">I'm trying to get a reliable code coverage through Clang's<br>
Source-based Code Coverage and am heading some false negatives on<br>
virtual inheriting classes. In particular the inheriting class'<br>
constructor is displayed as NOT covered.<br>
<br>
Given this code:<br>
<br>
#include <iostream><br>
class Foo<br>
{<br>
public:<br>
    Foo()<br>
    {<br>
        std::cout << "in Foo()" << std::endl;<br>
    }<br>
};<br>
<br>
class Bar : virtual public Foo<br>
{<br>
public:<br>
   Bar()<br>
   {<br>
        std::cout << "in Bar()" << std::endl;  // supposedly not covered<br>
   };<br>
};<br>
<br>
int main (int argc, char* argv[])<br>
{<br>
    Bar b;<br>
}<br>
<br>
The output is, obviously:<br>
<br>
in Foo()<br>
in Bar()<br>
<br>
but the Bar's constructor is reported as uncovered.<br>
<br>
<br>
I'm folliwng the steps described on the above page ie.<br>
1. clang++ -fprofile-instr-generate -fcoverage-mapping main.cpp<br>
2. running the binary<br>
3. llvm-profdata merge default.profraw -o default.profdata<br>
4. llvm-cov-4.0 show a.out --instr-profile default.profdata<br>
<br>
Tried clang 4.0 and 5.0 (compiled from trunk) with same effect.<br>
<br>
<br>
Could anyone help me with this issue?<br>
Is there a way to workaround this issue?<br>
How can I debug it to see what's causing it?<br></blockquote><div><br></div><div>Hi, this looks like a bug in the source-based PGO, which is used to get the coverage. The problem is that we only collect PGO data for the base constructors on platforms whose ABI supports constructor variants, which usually isn't a problem since complete constructors invoke them. However, in the code sample that you provided, clang will emit a C1 complete object constructor for Bar that doesn't invoke the C2 base constructor for Bar. This means that our assumptions about constructors are incorrect and should be fixed.</div><div><br></div><div>I don't think there's a workaround for this issue unfortunately.</div><div><br></div><div>I have filed the following bug to track this issue: <a href="http://bugs.llvm.org/show_bug.cgi?id=31992">http://bugs.llvm.org/show_bug.cgi?id=31992</a> .</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
<br>
regards,<br>
Michał Pszona<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>