| 1 | // RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=nonnull-attribute %s -o - -w | FileCheck %s |
| 2 | |
| 3 | @interface A |
| 4 | |
| 5 | -(void) one_arg: (__attribute__((nonnull)) int *) arg1; |
| 6 | |
| 7 | -(void) varargs: (__attribute__((nonnull)) int *) arg1, ...; |
| 8 | |
| 9 | +(void) clsmethod: (__attribute__((nonnull)) int *) arg1; |
| 10 | |
| 11 | @end |
| 12 | |
| 13 | @implementation A |
| 14 | |
| 15 | // CHECK-LABEL: define internal void @"\01-[A one_arg:]" |
| 16 | // CHECK-SAME: i32* nonnull |
| 17 | -(void) one_arg: (__attribute__((nonnull)) int *) arg1 {} |
| 18 | |
| 19 | // CHECK-LABEL: define internal void @"\01-[A varargs:]" |
| 20 | // CHECK-SAME: i32* nonnull |
| 21 | -(void) varargs: (__attribute__((nonnull)) int *) arg1, ... {} |
| 22 | |
| 23 | // CHECK-LABEL: define internal void @"\01+[A clsmethod:]" |
| 24 | // CHECK-SAME: i32* nonnull |
| 25 | +(void) clsmethod: (__attribute__((nonnull)) int *) arg1 {} |
| 26 | |
| 27 | @end |
| 28 | |
| 29 | // CHECK-LABEL: define void @call_A |
| 30 | void call_A(A *a, int *p) { |
| 31 | // CHECK: [[ICMP:%.*]] = icmp ne i32* [[P1:%.*]], null, !nosanitize |
| 32 | // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize |
| 33 | // CHECK: call void @__ubsan_handle_nonnull_arg{{.*}} !nosanitize |
| 34 | // CHECK: call void {{.*}} @objc_msgSend {{.*}} ({{.*}}, i32* [[P1]]) |
| 35 | [a one_arg: p]; |
| 36 | |
| 37 | // CHECK: [[ICMP:%.*]] = icmp ne i32* [[P2:%.*]], null, !nosanitize |
| 38 | // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize |
| 39 | // CHECK: call void @__ubsan_handle_nonnull_arg{{.*}} !nosanitize |
| 40 | // CHECK: call void {{.*}} @objc_msgSend {{.*}} ({{.*}}, i32* [[P2]], {{.*}}) |
| 41 | [a varargs: p, p]; |
| 42 | |
| 43 | // CHECK: [[ICMP:%.*]] = icmp ne i32* [[P3:%.*]], null, !nosanitize |
| 44 | // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize |
| 45 | // CHECK: call void @__ubsan_handle_nonnull_arg{{.*}} !nosanitize |
| 46 | // CHECK: call void {{.*}} @objc_msgSend {{.*}} ({{.*}}, i32* [[P3]]) |
| 47 | [A clsmethod: p]; |
| 48 | } |
| 49 | |