Alex Lorenz | a8fbef4 | 2017-03-23 11:14:27 +0000 | [diff] [blame] | 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 | |
Peter Collingbourne | 89061b2 | 2017-06-12 20:10:48 +0000 | [diff] [blame] | 40 | // CHECK_LINK_OPT: !llvm.linker.options = !{![[FRAMEWORK:[0-9]+]] |
Alex Lorenz | a8fbef4 | 2017-03-23 11:14:27 +0000 | [diff] [blame] | 41 | // CHECK_LINK_OPT: ![[FRAMEWORK]] = !{!"-framework", !"CoreFoundation"} |
| 42 | |
Peter Collingbourne | 89061b2 | 2017-06-12 20:10:48 +0000 | [diff] [blame] | 43 | // CHECK_NO_GUARD-NOT: !llvm.linker.options |
Alex Lorenz | a8fbef4 | 2017-03-23 11:14:27 +0000 | [diff] [blame] | 44 | // CHECK_NO_GUARD-NOT: CoreFoundation |