[cfe-dev] Remove code coverage counter for "empty" lines

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 25 12:46:12 PDT 2018


(+ a few folks who've been involved in the reviews, etc)

On Mon, Sep 24, 2018 at 12:34 PM Calixte Denizet via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
> When making code coverage, there are some counters on closing braces.
> 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).
> 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.
> Here are two example of outputs produced by clang and gcc.
>
> With clang 7:
> -:    1:struct A {
> -:    2:
> 1:    3:    A() {}
> -:    4:
> -:    5:    ~A() {
> 1:    6:    }
> -:    7:};
> -:    8:
> -:    9:void foo(int K) {
> 1:   10:}
> -:   11:
> -:   12:int main() {
> 1:   13:    A aaa;
> 1:   14:    int x = 1;
> 1:   15:    foo(x);
> 1:   16:    x = x + 2;
> -:   17:
> 1:   18:    return x;
> 1:   19:}
>
> With gcc 8:
> -:    1:struct A {
> -:    2:
> 1:    3:    A() {}
> -:    4:
> 1:    5:    ~A() {
> 1:    6:    }
> -:    7:};
> -:    8:
> 1:    9:void foo(int K) {
> 1:   10:}
> -:   11:
> 1:   12:int main() {
> 1:   13:    A aaa;
> 1:   14:    int x = 1;
> 1:   15:    foo(x);
> 1:   16:    x = x + 2;
> -:   17:
> 1:   18:    return x;
> -:   19:}
>
> 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").
> So we could add an option in clang (no idea of the name right now) to
> allow user to have coverage for explicit code.
> And so have this output:
> -:    1:struct A {
> -:    2:
> 1:    3:    A() {}
> -:    4:
> 1:    5:    ~A() {
> -:    6:    }
> -:    7:};
> -:    8:
> 1:    9:void foo(int K) {
> -:   10:}
> -:   11:
> 1:   12:int main() {
> 1:   13:    A aaa;
> 1:   14:    int x = 1;
> 1:   15:    foo(x);
> 1:   16:    x = x + 2;
> -:   17:
> 1:   18:    return x;
> -:   19:}
>
> Calixte
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180925/99dba5d2/attachment.html>


More information about the cfe-dev mailing list