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// RUN: %clang_cc1 -triple x86_64-apple-macos10.15 -DCHECK_OS="macos 10.15.1" -emit-llvm -o - %s | FileCheck --check-prefix=CHECK_NO_GUARD %s 7// RUN: %clang_cc1 -triple arm64-apple-ios13.0 -DCHECK_OS="ios 14" -emit-llvm -o - %s | FileCheck --check-prefix=CHECK_NO_GUARD %s 8// RUN: %clang_cc1 -triple arm64-apple-tvos13.0 -DCHECK_OS="tvos 14" -emit-llvm -o - %s | FileCheck --check-prefix=CHECK_NO_GUARD %s 9// RUN: %clang_cc1 -triple arm64-apple-watchos6.0 -DCHECK_OS="watchos 7" -emit-llvm -o - %s | FileCheck --check-prefix=CHECK_NO_GUARD %s 10// RUN: %clang_cc1 -triple arm64-apple-ios12.0 -DCHECK_OS="ios 13" -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK_LINK_OPT %s 11// RUN: %clang_cc1 -triple arm64-apple-tvos12.0 -DCHECK_OS="tvos 13" -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK_LINK_OPT %s 12// RUN: %clang_cc1 -triple arm64-apple-watchos5.0 -DCHECK_OS="watchos 6" -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK_LINK_OPT %s 13 14#ifdef DEF_CF 15struct CFBundle; 16typedef struct CFBundle *CFBundleRef; 17unsigned CFBundleGetVersionNumber(CFBundleRef bundle); 18// CHECK_CF: declare i32 @CFBundleGetVersionNumber(%struct.CFBundle*) 19// CHECK_CF: @__clang_at_available_requires_core_foundation_framework 20// CHECK_CF-NEXT: call {{.*}}@CFBundleGetVersionNumber 21#endif 22 23#ifndef CHECK_OS 24#define CHECK_OS macos 10.12 25#endif 26 27void use_at_available() { 28#ifdef DEF_CF 29 CFBundleGetVersionNumber(0); 30#endif 31#ifdef USE_BUILTIN 32 if (__builtin_available(CHECK_OS, *)) 33 ; 34#else 35 if (@available(CHECK_OS, *)) 36 ; 37#endif 38} 39 40// CHECK: @llvm.compiler.used{{.*}}@__clang_at_available_requires_core_foundation_framework 41 42// CHECK: declare i32 @CFBundleGetVersionNumber(i8*) 43 44// CHECK-LABEL: linkonce hidden void @__clang_at_available_requires_core_foundation_framework 45// CHECK: call i32 @CFBundleGetVersionNumber(i8* null) 46// CHECK-NEXT: unreachable 47 48// CHECK_NO_GUARD-NOT: __clang_at_available_requires_core_foundation_framework 49// CHECK_NO_GUARD-NOT: CFBundleGetVersionNumber 50 51// CHECK_LINK_OPT: !llvm.linker.options = !{![[FRAMEWORK:[0-9]+]] 52// CHECK_LINK_OPT: ![[FRAMEWORK]] = !{!"-framework", !"CoreFoundation"} 53 54// CHECK_NO_GUARD-NOT: !llvm.linker.options 55// CHECK_NO_GUARD-NOT: CoreFoundation 56