[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / open_memstream.cpp
blob196f39e2866f0344230b0ca5f98788a904d93f2f
1 // RUN: %clangxx -m64 -O0 -g -xc++ %s -o %t && %run %t
2 // RUN: %clangxx -m64 -O3 -g -xc++ %s -o %t && %run %t
3 // REQUIRES: x86_64-target-arch
5 #include <assert.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
10 #include "sanitizer_common/sanitizer_specific.h"
12 static void run(bool flush) {
13 char *buf;
14 size_t buf_len;
15 fprintf(stderr, " &buf %p, &buf_len %p\n", &buf, &buf_len);
16 FILE *fp = open_memstream(&buf, &buf_len);
17 fprintf(fp, "hello");
18 if (flush) {
19 fflush(fp);
20 check_mem_is_good(&buf, sizeof(buf));
21 check_mem_is_good(&buf_len, sizeof(buf_len));
22 check_mem_is_good(buf, buf_len);
25 char *p = new char[1024];
26 memset(p, 'a', 1023);
27 p[1023] = 0;
28 for (int i = 0; i < 100; ++i)
29 fprintf(fp, "%s", p);
30 delete[] p;
32 if (flush) {
33 fflush(fp);
34 fprintf(stderr, " %p addr %p, len %zu\n", &buf, buf, buf_len);
35 check_mem_is_good(&buf, sizeof(buf));
36 check_mem_is_good(&buf_len, sizeof(buf_len));
37 check_mem_is_good(buf, buf_len);\
40 fclose(fp);
41 check_mem_is_good(&buf, sizeof(buf));
42 check_mem_is_good(&buf_len, sizeof(buf_len));
43 check_mem_is_good(buf, buf_len);
45 free(buf);
48 int main(void) {
49 for (int i = 0; i < 100; ++i)
50 run(false);
51 for (int i = 0; i < 100; ++i)
52 run(true);
53 return 0;