1 // RUN: %clang_cc1 -no-enable-noundef-analysis -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool -o - -w < %s | FileCheck %s -check-prefixes=SHARED,OBJC
2 // RUN: %clang_cc1 -no-enable-noundef-analysis -x objective-c++ -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool -o - -w < %s | FileCheck %s -check-prefixes=SHARED,OBJC
3 // RUN: %clang_cc1 -no-enable-noundef-analysis -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool -o - < %s | FileCheck %s -check-prefixes=SHARED,C
5 typedef signed char BOOL;
7 // SHARED-LABEL: define{{.*}}f1
9 // OBJC: call void @__ubsan_handle_load_invalid_value
10 // C-NOT: call void @__ubsan_handle_load_invalid_value
20 // SHARED-LABEL: define{{.*}}f2
21 BOOL f2(struct S1 *s) {
22 // OBJC: [[LOAD:%.*]] = load i8, ptr {{.*}}
23 // OBJC: [[SHL:%.*]] = shl i8 [[LOAD]], 7
24 // OBJC: [[ASHR:%.*]] = ashr i8 [[SHL]], 7
25 // OBJC: icmp ule i8 [[ASHR]], 1, !nosanitize
26 // OBJC: call void @__ubsan_handle_load_invalid_value
28 // C-NOT: call void @__ubsan_handle_load_invalid_value
38 @property (nonatomic) BOOL b1;
44 // Check the synthesized getter.
45 // OBJC-LABEL: define internal signext i8 @"\01-[I1 b1]"
46 // OBJC: [[IVAR:%.*]] = load i64, ptr @"OBJC_IVAR_$_I1.b1"
47 // OBJC: [[ADDR:%.*]] = getelementptr inbounds i8, ptr {{.*}}, i64 [[IVAR]]
48 // OBJC: [[LOAD:%.*]] = load i8, ptr {{.*}}
49 // OBJC: [[SHL:%.*]] = shl i8 [[LOAD]], 7
50 // OBJC: [[ASHR:%.*]] = ashr i8 [[SHL]], 7
51 // OBJC: icmp ule i8 [[ASHR]], 1, !nosanitize
52 // OBJC: call void @__ubsan_handle_load_invalid_value
54 // Also check direct accesses to the ivar.
55 // OBJC-LABEL: define{{.*}}f3
57 // OBJC: [[LOAD:%.*]] = load i8, ptr {{.*}}
58 // OBJC: [[SHL:%.*]] = shl i8 [[LOAD]], 7
59 // OBJC: [[ASHR:%.*]] = ashr i8 [[SHL]], 7
60 // OBJC: icmp ule i8 [[ASHR]], 1, !nosanitize
61 // OBJC: call void @__ubsan_handle_load_invalid_value