diff options
author | Erik Pilkington <erik.pilkington@gmail.com> | 2017-02-23 21:08:08 +0000 |
---|---|---|
committer | Erik Pilkington <erik.pilkington@gmail.com> | 2017-02-23 21:08:08 +0000 |
commit | 11e7407389c4b2a6f51cb8983972b591573a4645 (patch) | |
tree | 22df56c981f03ee240e02d9c72b9e644a17e09df /test/CodeGenObjC | |
parent | c08b4f6784e0b35540d436ff63b4bb545df40500 (diff) |
[ObjC][CodeGen] CodeGen support for @available.
CodeGens uses of @available into calls to the compiler-rt function
__isOSVersionAtLeast.
This commit is part of a feature that I proposed here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html
Differential revision: https://reviews.llvm.org/D27827
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296015 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenObjC')
-rw-r--r-- | test/CodeGenObjC/availability-check.m | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/CodeGenObjC/availability-check.m b/test/CodeGenObjC/availability-check.m new file mode 100644 index 0000000000..71c5ff77c9 --- /dev/null +++ b/test/CodeGenObjC/availability-check.m @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck %s + +void use_at_available() { + // CHECK: call i32 @__isOSVersionAtLeast(i32 10, i32 12, i32 0) + // CHECK-NEXT: icmp ne + if (__builtin_available(macos 10.12, *)) + ; + + // CHECK: call i32 @__isOSVersionAtLeast(i32 10, i32 12, i32 0) + // CHECK-NEXT: icmp ne + if (@available(macos 10.12, *)) + ; + + // CHECK: call i32 @__isOSVersionAtLeast(i32 10, i32 12, i32 42) + // CHECK-NEXT: icmp ne + if (__builtin_available(ios 10, macos 10.12.42, *)) + ; + + // CHECK-NOT: call i32 @__isOSVersionAtLeast + // CHECK: br i1 true + if (__builtin_available(ios 10, *)) + ; + + // This check should be folded: our deployment target is 10.11. + // CHECK-NOT: call i32 @__isOSVersionAtLeast + // CHECK: br i1 true + if (__builtin_available(macos 10.11, *)) + ; +} + +// CHECK: declare i32 @__isOSVersionAtLeast(i32, i32, i32) |