[llvm-bugs] [Bug 50630] New: [LLVM-COV] No coverage for "destructor" function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 8 20:29:30 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50630

            Bug ID: 50630
           Summary: [LLVM-COV] No coverage for "destructor" function
           Product: Runtime Libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: cnwy1996 at outlook.com
                CC: llvm-bugs at lists.llvm.org

$ clang -v
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/wangyang/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ cat test.c
#include<stdio.h>
extern void abort(void);
extern void exit(int);
int i;

void __attribute__((constructor)) c2() {
  printf("1\n");
  if (i)
    abort();
}

void __attribute__((destructor)) d1() {
  printf("2\n");
  if (i)
    abort();
}

void main() {}

$ clang -w -O0 -g -fcoverage-mapping -fprofile-instr-generate=test.profraw
test.c; ./a.out; llvm-profdata merge test.profraw -o test.profdata; llvm-cov
show a.out -instr-profile=test.profdata test.c > test.lcov; cat test.lcov
1
2
    1|       |#include<stdio.h>
    2|       |extern void abort(void);
    3|       |extern void exit(int);
    4|       |int i;
    5|       |
    6|      1|void __attribute__((constructor)) c2() {
    7|      1|  printf("1\n");
    8|      1|  if (i)
    9|      0|    abort();
   10|      1|}
   11|       |
   12|      0|void __attribute__((destructor)) d1() {
   13|      0|  printf("2\n");
   14|      0|  if (i)
   15|      0|    abort();
   16|      0|}
   17|       |
   18|      1|void main() {}

Obviously,function d1 was executed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210609/b3675ad0/attachment.html>


More information about the llvm-bugs mailing list