https://bugs.llvm.org/show_bug.cgi?id=48409
Bug ID: 48409
Summary: [LLVM-COV] A blank statement after the continue
statement is wrongly marked as executed in a while
loop
Product: Runtime Libraries
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: libprofile library
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
$ clang -v
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
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.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
$ cat main.c
#include <time.h>
#include <stdlib.h>
#include <stdbool.h>
bool is_predicate(int percent) {
int n = rand() % 100;
if (n < percent) {
return true;
}
return false;
}
int main(int argc,char *argv[]){
srand((unsigned)time(NULL));
while ( is_predicate(50) )
{
;
continue;
;
}
return 0;
}
$ clang -w -O0 -g -fcoverage-mapping -fprofle-instr-generate=main.profraw
main.c; ./a.out; llvm-profdata merge main.profraw -o main.profdata; llvm-cov
show a.out -instr-profile=main.profdata main.c > main.gcov; cat main.gcov
1| |#include <time.h>
2| |#include <stdlib.h>
3| |#include <stdbool.h>
4| 2|bool is_predicate(int percent) {
5| 2| int n = rand() % 100;
6| 2| if (n < percent) {
7| 1| return true;
8| 1| }
9| 1| return false;
10| 1|}
11| 1|int main(int argc,char *argv[]){
12| 1| srand((unsigned)time(NULL));
13| 2| while ( is_predicate(50) )
14| 1| {
15| 1| ;
16| 1| continue;
17| 1| ;
18| 0| }
19| 1|
20| 1| return 0;
21| 1|}
Line #17 is wrongly marked as executed.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs