summaryrefslogtreecommitdiff
path: root/test/tsan/Darwin/libcxx-shared-ptr-recursive.mm
blob: fc5482ac3dd40377d017c42bfbf5be2ae9e11853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// RUN: %clang_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