Files
clang-p2996/compiler-rt/test/profile/Linux/coverage-do-while.c
Justin Cady 025639bc39 [Coverage] Fix mapping for do-while loops with terminating statements (#139777)
The current region mapping for do-while loops that contain statements
such as break or continue results in inaccurate line coverage reports
for the line following the loop.

This change handles terminating statements the same way that other loop
constructs do, correcting the region mapping for accurate reports. It
also fixes a fragile test relying on exact line numbers.

Fixes #139122
2025-05-19 15:49:26 -04:00

22 lines
1.0 KiB
C

// REQUIRES: lld-available
// XFAIL: powerpc64-target-arch
// RUN: %clangxx_profgen -fuse-ld=lld -fcoverage-mapping -o %t %s
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
// RUN: llvm-cov show %t -instr-profile=%t.profdata 2>&1 | FileCheck %s
#include <stdio.h>
// clang-format off
int main(int argc, char **argv) { // CHECK: [[@LINE]]| 1|int main(
do { // CHECK: [[@LINE]]| 1| do {
if (argc == 87) { // CHECK: [[@LINE]]| 1| if (argc
break; // CHECK: [[@LINE]]| 0| break
} // CHECK: [[@LINE]]| 0| }
} while (0); // CHECK: [[@LINE]]| 1| } while
printf("coverage after do is present\n"); // CHECK: [[@LINE]]| 1| printf(
return 0; // CHECK: [[@LINE]]| 1| return
} // CHECK: [[@LINE]]| 1|}
// clang-format on