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

            Bug ID: 37072
           Summary: [LLVM-COV] wrong coverage of case in swith statement
           Product: Runtime Libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libprofile library
          Assignee: unassignedb...@nondot.org
          Reporter: yangyib...@nju.edu.cn
                CC: llvm-bugs@lists.llvm.org

$ clang -v
clang version 7.0.0- (trunk)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8.0.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8.0.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8.0.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ cat small.c

int
f (int a)
{
  switch (a)
    {
    case 0: return 0; break;
    case 1: return 1; break;
    default: return -1;
    }
}

int
main ()
{
  f(0);
  f(1);

  return 0;
}

$ clang -w -O0 -g -fcoverage-mapping -fprofile-instr-generate=small.profraw
small.c; ./a.out; llvm-profdata merge small.profraw -o small.profdata; llvm-cov
show a.out -instr-profile=small.profdata small.c > small.gcov; cat small.gcov
    1|       |
    2|       |int
    3|       |f (int a)
    4|      2|{
    5|      2|  switch (a)
    6|      2|    {
    7|      2|    case 0: return 0; break;
    8|      2|    case 1: return 1; break;
    9|      2|    default: return -1;
   10|      0|    }
   11|      0|}
   12|       |
   13|       |int
   14|       |main ()
   15|      1|{
   16|      1|  f(0);
   17|      1|  f(1);
   18|      1|
   19|      1|  return 0;
   20|      1|}


*****
Line #7, Line 8, and Line #9 are both wrongly marked as executed twice. 
Line #7 and Line #8 should respectively executed once, and Line #9 is not
executed .

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to