<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 25, 2018, at 12:46 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">(+ a few folks who've been involved in the reviews, etc)<br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Sep 24, 2018 at 12:34 PM Calixte Denizet via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">When making code coverage, there are some counters on closing braces.</div><div class="">In some case it's due to "return void" with a debugloc corresponding to '}' (see line 4) or due to cleanup stuff put at the end of a scope (see line 20, aaa's dtor is called).</div><div class="">Especially with c++, some "implicit" code (i.e. not written explicitly by the user) could be added at the beginning of a scope and at the end.<br class=""></div><div class="">Here are two example of outputs produced by clang and gcc.</div><div class=""><br class=""></div><div class="">With clang 7:<br class="">-:    1:struct A {<br class="">-:    2:<br class="">1:    3:    A() {}<br class="">-:    4:    <br class="">-:    5:    ~A() {<br class="">1:    6:    }<br class="">-:    7:};<br class="">-:    8:<br class="">-:    9:void foo(int K) {<br class="">1:   10:}<br class="">-:   11:<br class="">-:   12:int main() {<br class="">1:   13:    A aaa;<br class="">1:   14:    int x = 1;<br class="">1:   15:    foo(x);<br class="">1:   16:    x = x + 2;<br class="">-:   17:<br class="">1:   18:    return x;<br class="">1:   19:}<br class=""></div><br class=""><div class="">With gcc 8:<br class="">-:    1:struct A {<br class="">-:    2:<br class="">1:    3:    A() {}<br class="">-:    4:    <br class="">1:    5:    ~A() {<br class="">1:    6:    }<br class="">-:    7:};<br class="">-:    8:<br class="">1:    9:void foo(int K) {<br class="">1:   10:}<br class="">-:   11:<br class="">1:   12:int main() {<br class="">1:   13:    A aaa;<br class="">1:   14:    int x = 1;<br class="">1:   15:    foo(x);<br class="">1:   16:    x = x + 2;<br class="">-:   17:<br class="">1:   18:    return x;<br class="">-:   19:}</div><div class=""><br class=""></div><div class="">So I'd like to have coverage for lines which contain only "explicit" code to have a clear information to give to different kinds of people (I spent myself some time to understand why I had coverage on line like "} // namespace foo”).</div></div></div></div></div></div></blockquote></div></div></div></blockquote><div><br class=""></div>Makes sense, although I’ll note that there are cases where hiding coverage stats on closing braces might be doing a disservice, like:</div><div><br class=""></div><div>void foo() {</div><div>  if (…)</div><div>    return;</div><div>  if (…)</div><div>    return;</div><div>} //< The coverage here might be interesting if you care about how often you don’t return early.</div><div><br class=""></div><div>You can figure it out by subtracting the coverage counts on return statements from the function entry count, but that’s work the coverage tool could do for you.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">So we could add an option in clang (no idea of the name right now) to allow user to have coverage for explicit code.</div></div></div></div></div></div></blockquote></div></div></div></blockquote><div><br class=""></div><div>I’d rather not have a flag to control this behavior. I imagine that most users of a coverage tool will never change its default behavior. From a maintenance perspective, it’s easier to test one coverage mode than two.</div><div><br class=""></div><div>You’re making a compelling argument that hiding coverage stats on implicit code is the right thing to do (if for no other reason than “it’s what gcc does”). If most others agree with you, I’d rather have such a change made unconditionally even though it’s not my personal preference.</div><div><br class=""></div><div>Just my 2 cents — happy to defer to others maintaining/using gcov.</div><div><br class=""></div><div>thanks,</div><div>vedant</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">And so have this output:<br class="">-:    1:struct A {<br class="">-:    2:<br class="">1:    3:    A() {}<br class="">-:    4:    <br class="">1:    5:    ~A() {<br class="">-:    6:    }<br class="">-:    7:};<br class="">-:    8:<br class="">1:    9:void foo(int K) {<br class="">-:   10:}<br class="">-:   11:<br class="">1:   12:int main() {<br class="">1:   13:    A aaa;<br class="">1:   14:    int x = 1;<br class="">1:   15:    foo(x);<br class="">1:   16:    x = x + 2;<br class="">-:   17:<br class="">1:   18:    return x;<br class="">-:   19:}<br class=""></div><div class=""><br class=""></div><div class="">Calixte<br class=""></div></div></div></div></div></div>
_______________________________________________<br class="">
cfe-dev mailing list<br class="">
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="">
</blockquote></div></div>
</div></blockquote></div><br class=""></body></html>