1 // This test verifies that dispatch_sync() doesn't actually copy the block under TSan (without TSan, it doesn't).
3 // RUN: %clang_tsan -fno-sanitize=thread %s -o %t_no_tsan -framework Foundation
4 // RUN: %run %t_no_tsan 2>&1 | FileCheck %s
6 // RUN: %clang_tsan %s -o %t_with_tsan -framework Foundation
7 // RUN: %run %t_with_tsan 2>&1 | FileCheck %s
9 #import <Foundation/Foundation.h>
11 @interface MyClass : NSObject
14 @implementation MyClass
15 - (instancetype)retain {
16 // Copying the dispatch_sync'd block below will increment the retain count of
17 // this object. Abort if that happens.
22 int main(int argc, const char* argv[]) {
23 dispatch_queue_t q = dispatch_queue_create("my.queue", NULL);
24 id object = [[MyClass alloc] init];
34 // CHECK-NOT: WARNING: ThreadSanitizer