1 // This test verifies that dispatch_sync() doesn't actually copy the block under TSan (without TSan, it doesn't).
3 // RUN: %clang_tsan %s -o %t_no_tsan -framework Foundation -fno-sanitize=thread
4 // RUN: %clang_tsan %s -o %t_with_tsan -framework Foundation
6 // RUN: %run %t_no_tsan 2>&1 | FileCheck %s
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];
25 void (^block)(void) = ^ {
31 dispatch_sync(q, block);
38 // CHECK-NOT: WARNING: ThreadSanitizer