[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-07-20 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa8262a383bc6: [clang][darwin] add support for Mac Catalyst 
availability (authored by arphaman).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105052/new/

https://reviews.llvm.org/D105052

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenObjC/availability-check-maccatalyst.m
  clang/test/FixIt/fixit-availability-maccatalyst.m
  clang/test/Sema/attr-availability-maccatalyst.c
  clang/test/SemaObjC/unguarded-availability-maccatalyst.m

Index: clang/test/SemaObjC/unguarded-availability-maccatalyst.m
===
--- /dev/null
+++ clang/test/SemaObjC/unguarded-availability-maccatalyst.m
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xobjective-c++ -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -triple x86_64-apple-ios14.1-macabi -DNO_WARNING -fblocks -fsyntax-only -verify %s
+
+#ifdef NO_WARNING
+  // expected-no-diagnostics
+#endif
+
+#define AVAILABLE_PREV __attribute__((availability(macCatalyst, introduced = 13.1)))
+#define AVAILABLE_CURRENT __attribute__((availability(macCatalyst, introduced = 14)))
+#define AVAILABLE_NEXT __attribute__((availability(macCatalyst, introduced = 14.1)))
+
+void previouslyAvailable() AVAILABLE_PREV;
+void currentlyAvailable() AVAILABLE_CURRENT;
+void willBeAvailabile() AVAILABLE_NEXT;
+#ifndef NO_WARNING
+// expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+
+typedef struct {
+
+} Record AVAILABLE_NEXT;
+#ifndef NO_WARNING
+// expected-note@-2 {{'Record' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+AVAILABLE_PREV
+Record var;
+#ifndef NO_WARNING
+// expected-warning@-2 {{'Record' is only available on macCatalyst 14.1 or newer}}
+// expected-note@-3 {{annotate 'var' with an availability attribute to silence this warnin}}
+#endif
+
+AVAILABLE_NEXT
+Record var2;
+
+void test() {
+  previouslyAvailable();
+  currentlyAvailable();
+  willBeAvailabile();
+#ifndef NO_WARNING
+  // expected-warning@-2 {{'willBeAvailabile' is only available on macCatalyst 14.1 or newer}}
+  // expected-note@-3 {{enclose 'willBeAvailabile' in an @available check to silence this warning}}
+#endif
+  if (@available(maccatalyst 14.1, *))
+willBeAvailabile(); // OK
+  if (@available(ios 14.1, *))
+willBeAvailabile(); // Also OK
+  if (@available(macCatalyst 14.1, *))
+willBeAvailabile(); // OK
+}
+
+void previouslyAvailableIOS() __attribute__((availability(ios, introduced = 10)));
+void currentlyAvailableIOS() __attribute__((availability(ios, introduced = 14)));
+void willBeAvailabileIOS() __attribute__((availability(ios, introduced = 14.1)));
+#ifndef NO_WARNING
+// expected-note@-2 {{'willBeAvailabileIOS' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+void testIOSAvailabilityAlsoWorks() {
+  previouslyAvailableIOS();
+  currentlyAvailableIOS();
+  willBeAvailabileIOS();
+#ifndef NO_WARNING
+  // expected-warning@-2 {{'willBeAvailabileIOS' is only available on macCatalyst 14.1 or newer}}
+  // expected-note@-3 {{enclose 'willBeAvailabileIOS' in an @available check to silence this warning}}
+#endif
+  if (@available(macCatalyst 14.1, *))
+willBeAvailabileIOS(); // OK
+  if (@available(ios 14.1, *))
+willBeAvailabile(); // Also OK
+}
+
+typedef struct {
+
+} Record2 __attribute__((availability(ios, introduced = 14.1)));
+#ifndef NO_WARNING
+// expected-note@-2 {{'Record2' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+__attribute__((availability(ios, introduced = 10)))
+Record2 var11;
+#ifndef NO_WARNING
+// expected-warning@-2 {{'Record2' is only available on macCatalyst 14.1 or newer}}
+// expected-note@-3 {{annotate 'var11' with an availability attribute to silence this warnin}}
+#endif
+
+__attribute__((availability(ios, introduced = 14.1)))
+Record2 var12;
Index: clang/test/Sema/attr-availability-maccatalyst.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-maccatalyst.c
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -fapplication-extension -D APPEXT -fsyntax-only -verify %s
+
+#ifdef APPEXT
+
+#define maccatalyst maccatalyst_app_extension
+#define 

[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-07-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105052/new/

https://reviews.llvm.org/D105052

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-07-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 358457.
arphaman added a comment.

Sorry, took a bit longer than anticipated. I updated the patch to address 
reviewer's comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105052/new/

https://reviews.llvm.org/D105052

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenObjC/availability-check-maccatalyst.m
  clang/test/FixIt/fixit-availability-maccatalyst.m
  clang/test/Sema/attr-availability-maccatalyst.c
  clang/test/SemaObjC/unguarded-availability-maccatalyst.m

Index: clang/test/SemaObjC/unguarded-availability-maccatalyst.m
===
--- /dev/null
+++ clang/test/SemaObjC/unguarded-availability-maccatalyst.m
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xobjective-c++ -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -triple x86_64-apple-ios14.1-macabi -DNO_WARNING -fblocks -fsyntax-only -verify %s
+
+#ifdef NO_WARNING
+  // expected-no-diagnostics
+#endif
+
+#define AVAILABLE_PREV __attribute__((availability(macCatalyst, introduced = 13.1)))
+#define AVAILABLE_CURRENT __attribute__((availability(macCatalyst, introduced = 14)))
+#define AVAILABLE_NEXT __attribute__((availability(macCatalyst, introduced = 14.1)))
+
+void previouslyAvailable() AVAILABLE_PREV;
+void currentlyAvailable() AVAILABLE_CURRENT;
+void willBeAvailabile() AVAILABLE_NEXT;
+#ifndef NO_WARNING
+// expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+
+typedef struct {
+
+} Record AVAILABLE_NEXT;
+#ifndef NO_WARNING
+// expected-note@-2 {{'Record' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+AVAILABLE_PREV
+Record var;
+#ifndef NO_WARNING
+// expected-warning@-2 {{'Record' is only available on macCatalyst 14.1 or newer}}
+// expected-note@-3 {{annotate 'var' with an availability attribute to silence this warnin}}
+#endif
+
+AVAILABLE_NEXT
+Record var2;
+
+void test() {
+  previouslyAvailable();
+  currentlyAvailable();
+  willBeAvailabile();
+#ifndef NO_WARNING
+  // expected-warning@-2 {{'willBeAvailabile' is only available on macCatalyst 14.1 or newer}}
+  // expected-note@-3 {{enclose 'willBeAvailabile' in an @available check to silence this warning}}
+#endif
+  if (@available(maccatalyst 14.1, *))
+willBeAvailabile(); // OK
+  if (@available(ios 14.1, *))
+willBeAvailabile(); // Also OK
+  if (@available(macCatalyst 14.1, *))
+willBeAvailabile(); // OK
+}
+
+void previouslyAvailableIOS() __attribute__((availability(ios, introduced = 10)));
+void currentlyAvailableIOS() __attribute__((availability(ios, introduced = 14)));
+void willBeAvailabileIOS() __attribute__((availability(ios, introduced = 14.1)));
+#ifndef NO_WARNING
+// expected-note@-2 {{'willBeAvailabileIOS' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+void testIOSAvailabilityAlsoWorks() {
+  previouslyAvailableIOS();
+  currentlyAvailableIOS();
+  willBeAvailabileIOS();
+#ifndef NO_WARNING
+  // expected-warning@-2 {{'willBeAvailabileIOS' is only available on macCatalyst 14.1 or newer}}
+  // expected-note@-3 {{enclose 'willBeAvailabileIOS' in an @available check to silence this warning}}
+#endif
+  if (@available(macCatalyst 14.1, *))
+willBeAvailabileIOS(); // OK
+  if (@available(ios 14.1, *))
+willBeAvailabile(); // Also OK
+}
+
+typedef struct {
+
+} Record2 __attribute__((availability(ios, introduced = 14.1)));
+#ifndef NO_WARNING
+// expected-note@-2 {{'Record2' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+__attribute__((availability(ios, introduced = 10)))
+Record2 var11;
+#ifndef NO_WARNING
+// expected-warning@-2 {{'Record2' is only available on macCatalyst 14.1 or newer}}
+// expected-note@-3 {{annotate 'var11' with an availability attribute to silence this warnin}}
+#endif
+
+__attribute__((availability(ios, introduced = 14.1)))
+Record2 var12;
Index: clang/test/Sema/attr-availability-maccatalyst.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-maccatalyst.c
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -fapplication-extension -D APPEXT -fsyntax-only -verify %s
+
+#ifdef APPEXT
+
+#define maccatalyst maccatalyst_app_extension
+#define macCatalyst maccatalyst_app_extension
+#define ios ios_app_extension
+
+#endif
+
+void f0(int) 

[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-06-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Thanks for the feedback, I'll update this patch tomorrow.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105052/new/

https://reviews.llvm.org/D105052

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-06-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Btw, the CI failures look to be unrelated to the patch. (It's pretty 
unfortunate how often this is the case lately...)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105052/new/

https://reviews.llvm.org/D105052

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-06-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:860
+ .Case("maccatalyst", "macCatalyst")
+ .Case("maccatalyst_app_extension", "macCatalyst App Extension")
  .Case("swift", "Swift")

Should this be `(App Extension)` instead (consistent with the other cases)?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2564
+IdentifierInfo *NewII = nullptr;
+auto MinIOSMacVersion = [](const VersionTuple ) -> VersionTuple {
+  if (V.empty())

Do you need the trailing return type here?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2572-2573
+};
+llvm::function_ref VersionRemapper =
+MinIOSMacVersion;
+if (II->getName() == "ios")

Why do you need a `function_ref` here -- can we not just call 
`MinIOSMacVersion()` instead?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105052/new/

https://reviews.llvm.org/D105052

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-06-28 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM, but since this hasn't been up for long maybe leave it open for a bit in 
case someone else has a comment.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105052/new/

https://reviews.llvm.org/D105052

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105052: [clang][darwin] add support for Mac Catalyst availability

2021-06-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: dexonsmith, dcoughlin, Bigcheese.
Herald added a subscriber: ributzka.
Herald added a reviewer: aaron.ballman.
arphaman requested review of this revision.

This patch adds support for Mac Catalyst availability attribute, as supported 
by the Apple clang compiler. A follow-up patch will provide additional support 
for inferring Mac Catalyst availability from macOS availability using the 
mapping in the SDKSettings.json.


https://reviews.llvm.org/D105052

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenObjC/availability-check-maccatalyst.m
  clang/test/FixIt/fixit-availability-maccatalyst.m
  clang/test/Sema/attr-availability-maccatalyst.c
  clang/test/SemaObjC/unguarded-availability-maccatalyst.m

Index: clang/test/SemaObjC/unguarded-availability-maccatalyst.m
===
--- /dev/null
+++ clang/test/SemaObjC/unguarded-availability-maccatalyst.m
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xobjective-c++ -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -triple x86_64-apple-ios14.1-macabi -DNO_WARNING -fblocks -fsyntax-only -verify %s
+
+#ifdef NO_WARNING
+  // expected-no-diagnostics
+#endif
+
+#define AVAILABLE_PREV __attribute__((availability(macCatalyst, introduced = 13.1)))
+#define AVAILABLE_CURRENT __attribute__((availability(macCatalyst, introduced = 14)))
+#define AVAILABLE_NEXT __attribute__((availability(macCatalyst, introduced = 14.1)))
+
+void previouslyAvailable() AVAILABLE_PREV;
+void currentlyAvailable() AVAILABLE_CURRENT;
+void willBeAvailabile() AVAILABLE_NEXT;
+#ifndef NO_WARNING
+// expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+
+typedef struct {
+
+} Record AVAILABLE_NEXT;
+#ifndef NO_WARNING
+// expected-note@-2 {{'Record' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+AVAILABLE_PREV
+Record var;
+#ifndef NO_WARNING
+// expected-warning@-2 {{'Record' is only available on macCatalyst 14.1 or newer}}
+// expected-note@-3 {{annotate 'var' with an availability attribute to silence this warnin}}
+#endif
+
+AVAILABLE_NEXT
+Record var2;
+
+void test() {
+  previouslyAvailable();
+  currentlyAvailable();
+  willBeAvailabile();
+#ifndef NO_WARNING
+  // expected-warning@-2 {{'willBeAvailabile' is only available on macCatalyst 14.1 or newer}}
+  // expected-note@-3 {{enclose 'willBeAvailabile' in an @available check to silence this warning}}
+#endif
+  if (@available(maccatalyst 14.1, *))
+willBeAvailabile(); // OK
+  if (@available(ios 14.1, *))
+willBeAvailabile(); // Also OK
+  if (@available(macCatalyst 14.1, *))
+willBeAvailabile(); // OK
+}
+
+void previouslyAvailableIOS() __attribute__((availability(ios, introduced = 10)));
+void currentlyAvailableIOS() __attribute__((availability(ios, introduced = 14)));
+void willBeAvailabileIOS() __attribute__((availability(ios, introduced = 14.1)));
+#ifndef NO_WARNING
+// expected-note@-2 {{'willBeAvailabileIOS' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+void testIOSAvailabilityAlsoWorks() {
+  previouslyAvailableIOS();
+  currentlyAvailableIOS();
+  willBeAvailabileIOS();
+#ifndef NO_WARNING
+  // expected-warning@-2 {{'willBeAvailabileIOS' is only available on macCatalyst 14.1 or newer}}
+  // expected-note@-3 {{enclose 'willBeAvailabileIOS' in an @available check to silence this warning}}
+#endif
+  if (@available(macCatalyst 14.1, *))
+willBeAvailabileIOS(); // OK
+  if (@available(ios 14.1, *))
+willBeAvailabile(); // Also OK
+}
+
+typedef struct {
+
+} Record2 __attribute__((availability(ios, introduced = 14.1)));
+#ifndef NO_WARNING
+// expected-note@-2 {{'Record2' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
+#endif
+
+__attribute__((availability(ios, introduced = 10)))
+Record2 var11;
+#ifndef NO_WARNING
+// expected-warning@-2 {{'Record2' is only available on macCatalyst 14.1 or newer}}
+// expected-note@-3 {{annotate 'var11' with an availability attribute to silence this warnin}}
+#endif
+
+__attribute__((availability(ios, introduced = 14.1)))
+Record2 var12;
Index: clang/test/Sema/attr-availability-maccatalyst.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-maccatalyst.c
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -fapplication-extension -D APPEXT