diff options
Diffstat (limited to 'test/tsan/Darwin/libcxx-shared-ptr-recursive.mm')
-rw-r--r-- | test/tsan/Darwin/libcxx-shared-ptr-recursive.mm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/tsan/Darwin/libcxx-shared-ptr-recursive.mm b/test/tsan/Darwin/libcxx-shared-ptr-recursive.mm new file mode 100644 index 0000000000000..eea02dc561e10 --- /dev/null +++ b/test/tsan/Darwin/libcxx-shared-ptr-recursive.mm @@ -0,0 +1,36 @@ +// RUN: %clangxx_tsan %s -o %t -framework Foundation +// RUN: %env_tsan_opts=ignore_interceptors_accesses=1 %run %t 2>&1 | FileCheck %s + +#import <Foundation/Foundation.h> + +#import <memory> + +struct InnerStruct { + ~InnerStruct() { + fprintf(stderr, "~InnerStruct\n"); + } +}; + +struct MyStruct { + std::shared_ptr<InnerStruct> inner_object; + ~MyStruct() { + fprintf(stderr, "~MyStruct\n"); + } +}; + +int main(int argc, const char *argv[]) { + fprintf(stderr, "Hello world.\n"); + + { + std::shared_ptr<MyStruct> shared(new MyStruct()); + shared->inner_object = std::shared_ptr<InnerStruct>(new InnerStruct()); + } + + fprintf(stderr, "Done.\n"); +} + +// CHECK: Hello world. +// CHECK: ~MyStruct +// CHECK: ~InnerStruct +// CHECK: Done. +// CHECK-NOT: WARNING: ThreadSanitizer |