Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / asan_update_allocation.cpp
blobf6b54373af6f7235ec866b62b2ea0985dddb4401
1 // RUN: %clangxx_asan -O0 %s --std=c++14 -o %t
3 // RUN: not %run %t 10 0 2>&1 | FileCheck %s --check-prefixes=CHECK,T0
4 // RUN: not %run %t 10000000 0 2>&1 | FileCheck %s --check-prefixes=CHECK,T0
6 // RUN: not %run %t 10 1 2>&1 | FileCheck %s --check-prefixes=CHECK,T1
7 // RUN: not %run %t 10000000 1 2>&1 | FileCheck %s --check-prefixes=CHECK,T1
9 // REQUIRES: stable-runtime
11 #include <sanitizer/asan_interface.h>
12 #include <stdlib.h>
13 #include <thread>
15 void UPDATE(void *p) {
16 __asan_update_allocation_context(p);
19 int main(int argc, char *argv[]) {
20 char *x = (char *)malloc(atoi(argv[1]) * sizeof(char));
21 if (atoi(argv[2]))
22 std::thread([&]() { UPDATE(x); }).join();
23 else
24 UPDATE(x);
25 free(x);
26 return x[5];
27 // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
28 // CHECK: READ of size 1 at {{.*}} thread T0
29 // T0: allocated by thread T0 here
30 // T1: allocated by thread T1 here
31 // CHECK: UPDATE