1 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK_LINK_OPT %s |
2 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - -D USE_BUILTIN %s | FileCheck --check-prefixes=CHECK,CHECK_LINK_OPT %s |
3 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - -D DEF_CF %s | FileCheck --check-prefixes=CHECK_CF,CHECK_LINK_OPT %s |
4 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12 -emit-llvm -o - %s | FileCheck --check-prefix=CHECK_NO_GUARD %s |
5 | // RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm -o - %s | FileCheck --check-prefix=CHECK_NO_GUARD %s |
6 | |
7 | #ifdef DEF_CF |
8 | struct CFBundle; |
9 | typedef struct CFBundle *CFBundleRef; |
10 | unsigned CFBundleGetVersionNumber(CFBundleRef bundle); |
11 | // CHECK_CF: declare i32 @CFBundleGetVersionNumber(%struct.CFBundle*) |
12 | // CHECK_CF: @__clang_at_available_requires_core_foundation_framework |
13 | // CHECK_CF-NEXT: call {{.*}}@CFBundleGetVersionNumber |
14 | #endif |
15 | |
16 | void use_at_available() { |
17 | #ifdef DEF_CF |
18 | CFBundleGetVersionNumber(0); |
19 | #endif |
20 | #ifdef USE_BUILTIN |
21 | if (__builtin_available(macos 10.12, *)) |
22 | ; |
23 | #else |
24 | if (@available(macos 10.12, *)) |
25 | ; |
26 | #endif |
27 | } |
28 | |
29 | // CHECK: @llvm.compiler.used{{.*}}@__clang_at_available_requires_core_foundation_framework |
30 | |
31 | // CHECK: declare i32 @CFBundleGetVersionNumber(i8*) |
32 | |
33 | // CHECK-LABEL: linkonce hidden void @__clang_at_available_requires_core_foundation_framework |
34 | // CHECK: call i32 @CFBundleGetVersionNumber(i8* null) |
35 | // CHECK-NEXT: unreachable |
36 | |
37 | // CHECK_NO_GUARD-NOT: __clang_at_available_requires_core_foundation_framework |
38 | // CHECK_NO_GUARD-NOT: CFBundleGetVersionNumber |
39 | |
40 | // CHECK_LINK_OPT: !llvm.linker.options = !{![[FRAMEWORK:[0-9]+]] |
41 | // CHECK_LINK_OPT: ![[FRAMEWORK]] = !{!"-framework", !"CoreFoundation"} |
42 | |
43 | // CHECK_NO_GUARD-NOT: !llvm.linker.options |
44 | // CHECK_NO_GUARD-NOT: CoreFoundation |
45 | |