[llvm-bugs] [Bug 49438] New: [LLVM-COV] Wrong coverage with "abort" function

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 4 04:48:42 PST 2021


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

            Bug ID: 49438
           Summary: [LLVM-COV] Wrong coverage with "abort" function
           Product: Runtime Libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          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
extern void abort(void);

#define f(x) x

int main() {
#if f(1) == f /**/ (/**/ 1 /**/)
  int x;
#endif
  x = 0;
  while(x<2){
  if (f
      /**/ (
          /**/ 0 /**/
          /**/))
    abort();
  x++;
}
  return 0;
}

$ 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|       |extern void abort(void);
    2|       |
    3|      4|#define f(x) x
    4|       |
    5|      1|int main() {
    6|      1|#if f(1) == f /**/ (/**/ 1 /**/)
    7|      1|  int x;
    8|      1|#endif
    9|      1|  x = 0;
   10|      3|  while(x<2){
   11|      2|  if (f
   12|      2|      /**/ (
   13|      2|          /**/ 0 /**/
   14|      2|          /**/))
   15|      2|    abort();
   16|      2|  x++;
   17|      2|}
   18|      1|  return 0;
   19|      1|}


Line #15 should not be 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/20210304/796c4504/attachment-0001.html>


More information about the llvm-bugs mailing list