summaryrefslogtreecommitdiff
path: root/test/FixIt
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-07-26 13:58:02 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-07-26 13:58:02 +0000
commit30f32e2463a9cc6ea3f4b21013b876912d5a5d53 (patch)
treec2cec749d8b63c0cb5368d42453650d667c6ccaa /test/FixIt
parent1a3ea7bcf31810c809716e53abe843f20fd523f4 (diff)
downloadclang-30f32e2463a9cc6ea3f4b21013b876912d5a5d53.tar.gz
unguarded availability: add a fixit for the "annotate '...'
with an availability attribute to silence" note rdar://33539233 Differential Revision: https://reviews.llvm.org/D35726 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/FixIt')
-rw-r--r--test/FixIt/fixit-availability.c8
-rw-r--r--test/FixIt/fixit-availability.mm31
2 files changed, 39 insertions, 0 deletions
diff --git a/test/FixIt/fixit-availability.c b/test/FixIt/fixit-availability.c
index 038dee08b1..4b3c8a4392 100644
--- a/test/FixIt/fixit-availability.c
+++ b/test/FixIt/fixit-availability.c
@@ -8,3 +8,11 @@ void use() {
// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (__builtin_available(macOS 10.12, *)) {\n "
// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n } else {\n // Fallback on earlier versions\n }"
}
+
+__attribute__((availability(macos, introduced=10.12)))
+struct New { };
+
+struct NoFixit {
+ struct New field;
+};
+// CHECK-NOT: API_AVAILABLE
diff --git a/test/FixIt/fixit-availability.mm b/test/FixIt/fixit-availability.mm
index d044a73efd..f6a1855694 100644
--- a/test/FixIt/fixit-availability.mm
+++ b/test/FixIt/fixit-availability.mm
@@ -109,3 +109,34 @@ void wrapDeclStmtUses() {
anotherFunction(y);
anotherFunction(x);
}
+
+#define API_AVAILABLE(X) __attribute__((availability(macos, introduced=10.12))) // dummy macro
+
+API_AVAILABLE(macos(10.12))
+@interface NewClass
+@end
+
+@interface OldButOfferFixit
+@property(copy) NewClass *prop;
+// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:1-[[@LINE-2]]:1}:"API_AVAILABLE(macos(10.12))\n"
+
+- (NewClass *)fixitMe;
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:22-[[@LINE-1]]:22}:" API_AVAILABLE(macos(10.12))"
+@end
+
+void oldButOfferFixitFn(NewClass *) {
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:1-[[@LINE-1]]:1}:"API_AVAILABLE(macos(10.12))\n"
+}
+
+template<typename T>
+struct OldButOfferFixitTag {
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:7-[[@LINE-1]]:7}:" API_AVAILABLE(macos(10.12))"
+ NewClass *x;
+};
+
+// Avoid a fixit for declarations that already have an attribute:
+__attribute__((availability(macos, introduced=10.11)))
+@interface WithoutFixit
+@property(copy) NewClass *prop;
+// CHECK-NOT: API_AVAILABLE
+@end