Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / lsan / TestCases / Darwin / dispatch_continuations.mm
blobd0420d85bae7d3417aea80bc6282f25f70d69030
1 // Test that dispatch continuation memory region is scanned.
2 // RUN: %clangxx_lsan %s  -o %t -framework Foundation
3 // RUN: %env_lsan_opts="report_objects=1" %run %t 2>&1 && echo "" | FileCheck %s
5 #include <dispatch/dispatch.h>
6 #include <sanitizer/lsan_interface.h>
8 int main() {
9   // Reduced from `CFRunLoopCreate`
10   dispatch_queue_t fake_rl_queue = dispatch_get_global_queue(2, 0);
11   dispatch_source_t timer =
12       dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, fake_rl_queue);
13   dispatch_source_set_event_handler(timer, ^{
14                                     });
15   dispatch_source_set_timer(timer, DISPATCH_TIME_FOREVER, DISPATCH_TIME_FOREVER,
16                             321);
17   dispatch_resume(timer);
18   __lsan_do_leak_check();
19   dispatch_source_cancel(timer);
20   dispatch_release(timer);
21   return 0;
24 // CHECK-NOT: LeakSanitizer: detected memory leaks