1 // Test that the specified output merges the profiling data.
2 // Run the program twice so that the counters accumulate.
3 // RUN: %clang_profgen -fcoverage-mapping -o %t %s
4 // RUN: rm -f %t.merging.profraw %t.merging.profdata
5 // RUN: %run %t %t.merging.profraw
6 // RUN: %run %t %t.merging.profraw
7 // RUN: test -f %t.merging.profraw
8 // RUN: llvm-profdata merge -o %t.merging.profdata %t.merging.profraw
9 // RUN: llvm-cov show -instr-profile %t.merging.profdata %t | FileCheck %s --match-full-lines
12 extern void __llvm_profile_set_file_object(FILE *, int);
14 int main(int argc
, const char *argv
[]) {
18 FILE *F
= fopen(argv
[1], "r+b");
20 // File might not exist, try opening with truncation
21 F
= fopen(argv
[1], "w+b");
23 __llvm_profile_set_file_object(F
, 1);
27 // CHECK: 10| |#include <stdio.h>
29 // CHECK: 12| |extern void __llvm_profile_set_file_object(FILE *, int);
31 // CHECK: 14| 2|int main(int argc, const char *argv[]) {
32 // CHECK: 15| 2| if (argc < 2)
33 // CHECK: 16| 0| return 1;
35 // CHECK: 18| 2| FILE *F = fopen(argv[1], "r+b");
36 // CHECK: 19| 2| if (!F) {
37 // CHECK: 20| | // File might not exist, try opening with truncation
38 // CHECK: 21| 1| F = fopen(argv[1], "w+b");
40 // CHECK: 23| 2| __llvm_profile_set_file_object(F, 1);
42 // CHECK: 25| 2| return 0;