36 lines · cpp
1// RUN: %clang_cc1 -x c++ -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=nullability-assign | FileCheck %s2 3struct S1 {4 int *_Nonnull p;5};6 7struct S2 {8 S1 s1;9};10 11union U1 {12 S1 s1;13 S2 s2;14};15 16// CHECK-LABEL: define{{.*}} void @{{.*}}f117void f1(int *p) {18 U1 u;19 20 // CHECK: [[ICMP:%.*]] = icmp ne ptr {{.*}}, null, !nosanitize21 // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize22 // CHECK: call void @__ubsan_handle_type_mismatch{{.*}} !nosanitize23 // CHECK: store24 u.s1.p = p;25 26 // CHECK: [[ICMP:%.*]] = icmp ne ptr {{.*}}, null, !nosanitize27 // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize28 // CHECK: call void @__ubsan_handle_type_mismatch{{.*}} !nosanitize29 // CHECK: store30 u.s2.s1.p = p;31 32 // CHECK-NOT: __ubsan_handle_type_mismatch33 // CHECK-NOT: store34 // CHECK: ret void35}36