1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=unreachable | FileCheck %s
3 void abort() __attribute__((noreturn
));
5 // CHECK-LABEL: define{{.*}} void @_Z14calls_noreturnv()
6 void calls_noreturn() {
7 // Check absence (ptr) of call site attributes (including noreturn)
8 // CHECK: call void @_Z5abortv(){{[^#]*}}
11 // CHECK: __ubsan_handle_builtin_unreachable
16 // CHECK: declare void @_Z5abortv() [[EXTERN_FN_ATTR:#[0-9]+]]
18 // CHECK-LABEL: define linkonce_odr void @_ZN1A5call1Ev
20 // CHECK: call void @_ZN1A16does_not_return2Ev({{.*}}){{[^#]*}}
23 // CHECK: __ubsan_handle_builtin_unreachable
27 // Test static members. Checks are below after `struct A` scope ends.
28 static void does_not_return1() __attribute__((noreturn
)) {
32 // CHECK-LABEL: define linkonce_odr void @_ZN1A5call2Ev
34 // CHECK: call void @_ZN1A16does_not_return1Ev(){{[^#]*}}
37 // CHECK: __ubsan_handle_builtin_unreachable
41 // Test calls through pointers to non-static member functions.
42 typedef void (A::*MemFn
)() __attribute__((noreturn
));
44 // CHECK-LABEL: define linkonce_odr void @_ZN1A5call3Ev
46 MemFn MF
= &A::does_not_return2
;
47 // CHECK: call void %{{[0-9]+\(.*}}){{[^#]*}}
50 // CHECK: __ubsan_handle_builtin_unreachable
54 // Test regular members.
55 // CHECK-LABEL: define linkonce_odr void @_ZN1A16does_not_return2Ev({{.*}})
56 // CHECK-SAME: [[USER_FN_ATTR:#[0-9]+]]
57 void does_not_return2() __attribute__((noreturn
)) {
58 // CHECK: call void @_Z5abortv(){{[^#]*}}
61 // CHECK: call void @__ubsan_handle_builtin_unreachable
64 // CHECK: call void @__ubsan_handle_builtin_unreachable
69 // CHECK-LABEL: define linkonce_odr void @_ZN1A16does_not_return1Ev()
70 // CHECK-SAME: [[USER_FN_ATTR]]
71 // CHECK: call void @_Z5abortv(){{[^#]*}}
80 // `noreturn` should be removed from functions and call sites
81 // CHECK-LABEL: attributes
82 // CHECK-NOT: [[USER_FN_ATTR]] = { {{.*noreturn.*}} }
83 // CHECK-NOT: [[EXTERN_FN_ATTR]] = { {{.*noreturn.*}} }