|
18 | 18 | #define SWIFT_AST_ASTCONTEXT_H
|
19 | 19 |
|
20 | 20 | #include "swift/AST/ASTAllocated.h"
|
| 21 | +#include "swift/AST/Availability.h" |
21 | 22 | #include "swift/AST/Evaluator.h"
|
22 | 23 | #include "swift/AST/GenericSignature.h"
|
23 | 24 | #include "swift/AST/Identifier.h"
|
@@ -876,159 +877,124 @@ class ASTContext final {
|
876 | 877 | addCleanup([&object]{ object.~T(); });
|
877 | 878 | }
|
878 | 879 |
|
879 |
| - /// Get the runtime availability of the class metadata update callback |
880 |
| - /// mechanism for the target platform. |
881 |
| - AvailabilityContext getObjCMetadataUpdateCallbackAvailability(); |
882 |
| - |
883 |
| - /// Get the runtime availability of the objc_getClass() hook for the target |
884 |
| - /// platform. |
885 |
| - AvailabilityContext getObjCGetClassHookAvailability(); |
886 |
| - |
887 |
| - /// Get the runtime availability of features introduced in the Swift 5.0 |
888 |
| - /// compiler for the target platform. |
889 |
| - AvailabilityContext getSwift50Availability(); |
890 |
| - |
891 |
| - /// Get the runtime availability of the opaque types language feature for the |
892 |
| - /// target platform. |
893 |
| - AvailabilityContext getOpaqueTypeAvailability(); |
894 |
| - |
895 |
| - /// Get the runtime availability of the objc_loadClassref() entry point for |
896 |
| - /// the target platform. |
897 |
| - AvailabilityContext getObjCClassStubsAvailability(); |
898 |
| - |
899 |
| - /// Get the runtime availability of features introduced in the Swift 5.1 |
900 |
| - /// compiler for the target platform. |
901 |
| - AvailabilityContext getSwift51Availability(); |
902 |
| - |
903 |
| - /// Get the runtime availability of |
904 |
| - /// swift_getTypeByMangledNameInContextInMetadataState. |
905 |
| - AvailabilityContext getTypesInAbstractMetadataStateAvailability(); |
906 |
| - |
907 |
| - /// Get the runtime availability of support for prespecialized generic |
908 |
| - /// metadata. |
909 |
| - AvailabilityContext getPrespecializedGenericMetadataAvailability(); |
910 |
| - |
911 |
| - /// Get the runtime availability of the swift_compareTypeContextDescriptors |
912 |
| - /// for the target platform. |
913 |
| - AvailabilityContext getCompareTypeContextDescriptorsAvailability(); |
914 |
| - |
915 |
| - /// Get the runtime availability of the |
916 |
| - /// swift_compareProtocolConformanceDescriptors entry point for the target |
917 |
| - /// platform. |
918 |
| - AvailabilityContext getCompareProtocolConformanceDescriptorsAvailability(); |
919 |
| - |
920 |
| - /// Get the runtime availability of support for inter-module prespecialized |
921 |
| - /// generic metadata. |
922 |
| - AvailabilityContext getIntermodulePrespecializedGenericMetadataAvailability(); |
923 |
| - |
924 |
| - /// Get the runtime availability of support for concurrency. |
925 |
| - AvailabilityContext getConcurrencyAvailability(); |
926 |
| - |
927 |
| - /// Get the runtime availability of task executors. |
928 |
| - AvailabilityContext getTaskExecutorAvailability(); |
929 |
| - |
930 |
| - /// Get the runtime availability of the `DiscardingTaskGroup`, |
931 |
| - /// and supporting runtime functions function |
932 |
| - AvailabilityContext getConcurrencyDiscardingTaskGroupAvailability(); |
933 |
| - |
934 |
| - /// Get the back-deployed availability for concurrency. |
935 |
| - AvailabilityContext getBackDeployedConcurrencyAvailability(); |
936 |
| - |
937 |
| - /// The the availability since when distributed actors are able to have custom |
938 |
| - /// executors. |
939 |
| - AvailabilityContext |
940 |
| - getConcurrencyDistributedActorWithCustomExecutorAvailability(); |
941 |
| - |
942 |
| - /// Get the runtime availability of support for differentiation. |
943 |
| - AvailabilityContext getDifferentiationAvailability(); |
944 |
| - |
945 |
| - /// Get the runtime availability of support for typed throws. |
946 |
| - AvailabilityContext getTypedThrowsAvailability(); |
947 |
| - |
948 |
| - /// Get the runtime availability of getters and setters of multi payload enum |
949 |
| - /// tag single payloads. |
950 |
| - AvailabilityContext getMultiPayloadEnumTagSinglePayload(); |
951 |
| - |
952 |
| - /// Get the runtime availability of the Objective-C enabled |
953 |
| - /// swift_isUniquelyReferenced functions. |
954 |
| - AvailabilityContext getObjCIsUniquelyReferencedAvailability(); |
| 880 | + /// Get the availability of features introduced in the specified version |
| 881 | + /// of the Swift compiler for the target platform. |
| 882 | + AvailabilityContext getSwiftAvailability(unsigned major, unsigned minor) const; |
| 883 | + |
| 884 | + // For each feature defined in FeatureAvailability, define two functions; |
| 885 | + // the latter, with the suffix RuntimeAvailabilty, is for use with |
| 886 | + // AvailabilityContext::forRuntimeTarget(), and only looks at the Swift |
| 887 | + // runtime version. |
| 888 | +#define FEATURE(N, V) \ |
| 889 | + inline AvailabilityContext get##N##Availability() const { \ |
| 890 | + return getSwiftAvailability V; \ |
| 891 | + } \ |
| 892 | + inline AvailabilityContext get##N##RuntimeAvailability() const { \ |
| 893 | + return AvailabilityContext(VersionRange::allGTE(llvm::VersionTuple V)); \ |
| 894 | + } |
955 | 895 |
|
956 |
| - /// Get the runtime availability of metadata manipulation runtime functions |
957 |
| - /// for extended existential types. |
958 |
| - AvailabilityContext getParameterizedExistentialRuntimeAvailability(); |
| 896 | + #include "swift/AST/FeatureAvailability.def" |
959 | 897 |
|
960 |
| - /// Get the runtime availability of array buffers placed in constant data |
961 |
| - /// sections. |
962 |
| - AvailabilityContext getStaticReadOnlyArraysAvailability(); |
| 898 | + /// Get the runtime availability of features that have been introduced in the |
| 899 | + /// Swift compiler for future versions of the target platform. |
| 900 | + AvailabilityContext getSwiftFutureAvailability() const; |
963 | 901 |
|
964 |
| - /// Get the runtime availability of runtime functions for |
965 |
| - /// variadic generic types. |
966 |
| - AvailabilityContext getVariadicGenericTypeAvailability(); |
| 902 | + /// Returns `true` if versioned availability annotations are supported for the |
| 903 | + /// target triple. |
| 904 | + bool supportsVersionedAvailability() const; |
967 | 905 |
|
968 |
| - /// Get the runtime availability of the conformsToProtocol runtime entrypoint |
969 |
| - /// that takes a signed protocol descriptor pointer. |
970 |
| - AvailabilityContext getSignedConformsToProtocolAvailability(); |
| 906 | + //===--------------------------------------------------------------------===// |
| 907 | + // Compatibility availability functions |
| 908 | + //===--------------------------------------------------------------------===// |
971 | 909 |
|
972 |
| - /// Get the runtime availability of runtime entrypoints that take signed type |
973 |
| - /// descriptors. |
974 |
| - AvailabilityContext getSignedDescriptorAvailability(); |
| 910 | + // Note: Don't add more of these version-specific availability functions; |
| 911 | + // just use getSwiftAvailability() instead. |
975 | 912 |
|
976 |
| - /// Get the runtime availability of the swift_initRawStructMetadata entrypoint |
977 |
| - /// that fixes up the value witness table of @_rawLayout dependent types. |
978 |
| - AvailabilityContext getInitRawStructMetadataAvailability(); |
| 913 | + /// Get the runtime availability of features introduced in the Swift 5.0 |
| 914 | + /// compiler for the target platform. |
| 915 | + inline AvailabilityContext getSwift50Availability() const { |
| 916 | + return getSwiftAvailability(5, 0); |
| 917 | + } |
979 | 918 |
|
980 |
| - /// Get the runtime availability of being able to use symbolic references to |
981 |
| - /// objective c protocols. |
982 |
| - AvailabilityContext getObjCSymbolicReferencesAvailability(); |
| 919 | + /// Get the runtime availability of features introduced in the Swift 5.1 |
| 920 | + /// compiler for the target platform. |
| 921 | + inline AvailabilityContext getSwift51Availability() const { |
| 922 | + return getSwiftAvailability(5, 1); |
| 923 | + } |
983 | 924 |
|
984 | 925 | /// Get the runtime availability of features introduced in the Swift 5.2
|
985 | 926 | /// compiler for the target platform.
|
986 |
| - AvailabilityContext getSwift52Availability(); |
| 927 | + inline AvailabilityContext getSwift52Availability() const { |
| 928 | + return getSwiftAvailability(5, 2); |
| 929 | + } |
987 | 930 |
|
988 | 931 | /// Get the runtime availability of features introduced in the Swift 5.3
|
989 | 932 | /// compiler for the target platform.
|
990 |
| - AvailabilityContext getSwift53Availability(); |
| 933 | + inline AvailabilityContext getSwift53Availability() const { |
| 934 | + return getSwiftAvailability(5, 3); |
| 935 | + } |
991 | 936 |
|
992 | 937 | /// Get the runtime availability of features introduced in the Swift 5.4
|
993 | 938 | /// compiler for the target platform.
|
994 |
| - AvailabilityContext getSwift54Availability(); |
| 939 | + inline AvailabilityContext getSwift54Availability() const { |
| 940 | + return getSwiftAvailability(5, 4); |
| 941 | + } |
995 | 942 |
|
996 | 943 | /// Get the runtime availability of features introduced in the Swift 5.5
|
997 | 944 | /// compiler for the target platform.
|
998 |
| - AvailabilityContext getSwift55Availability(); |
| 945 | + inline AvailabilityContext getSwift55Availability() const { |
| 946 | + return getSwiftAvailability(5, 5); |
| 947 | + } |
999 | 948 |
|
1000 | 949 | /// Get the runtime availability of features introduced in the Swift 5.6
|
1001 | 950 | /// compiler for the target platform.
|
1002 |
| - AvailabilityContext getSwift56Availability(); |
| 951 | + inline AvailabilityContext getSwift56Availability() const { |
| 952 | + return getSwiftAvailability(5, 6); |
| 953 | + } |
1003 | 954 |
|
1004 | 955 | /// Get the runtime availability of features introduced in the Swift 5.7
|
1005 | 956 | /// compiler for the target platform.
|
1006 |
| - AvailabilityContext getSwift57Availability(); |
| 957 | + inline AvailabilityContext getSwift57Availability() const { |
| 958 | + return getSwiftAvailability(5, 7); |
| 959 | + } |
1007 | 960 |
|
1008 | 961 | /// Get the runtime availability of features introduced in the Swift 5.8
|
1009 | 962 | /// compiler for the target platform.
|
1010 |
| - AvailabilityContext getSwift58Availability(); |
| 963 | + inline AvailabilityContext getSwift58Availability() const { |
| 964 | + return getSwiftAvailability(5, 8); |
| 965 | + } |
1011 | 966 |
|
1012 | 967 | /// Get the runtime availability of features introduced in the Swift 5.9
|
1013 | 968 | /// compiler for the target platform.
|
1014 |
| - AvailabilityContext getSwift59Availability(); |
| 969 | + inline AvailabilityContext getSwift59Availability() const { |
| 970 | + return getSwiftAvailability(5, 9); |
| 971 | + } |
1015 | 972 |
|
1016 |
| - /// Get the runtime availability of features introduced in the Swift 5.9 |
| 973 | + /// Get the runtime availability of features introduced in the Swift 5.10 |
1017 | 974 | /// compiler for the target platform.
|
1018 |
| - AvailabilityContext getSwift511Availability(); |
1019 |
| - |
1020 |
| - // Note: Update this function if you add a new getSwiftXYAvailability above. |
1021 |
| - /// Get the runtime availability for a particular version of Swift (5.0+). |
1022 |
| - AvailabilityContext |
1023 |
| - getSwift5PlusAvailability(llvm::VersionTuple swiftVersion); |
| 975 | + inline AvailabilityContext getSwift510Availability() const { |
| 976 | + return getSwiftAvailability(5, 10); |
| 977 | + } |
1024 | 978 |
|
1025 |
| - /// Get the runtime availability of features that have been introduced in the |
1026 |
| - /// Swift compiler for future versions of the target platform. |
1027 |
| - AvailabilityContext getSwiftFutureAvailability(); |
| 979 | + /// Get the runtime availability of features introduced in the Swift 5.11 |
| 980 | + /// compiler for the target platform. |
| 981 | + inline AvailabilityContext getSwift511Availability() const { |
| 982 | + return getSwiftAvailability(5, 11); |
| 983 | + } |
1028 | 984 |
|
1029 |
| - /// Returns `true` if versioned availability annotations are supported for the |
1030 |
| - /// target triple. |
1031 |
| - bool supportsVersionedAvailability() const; |
| 985 | + /// Get the runtime availability for a particular version of Swift (5.0+). |
| 986 | + inline AvailabilityContext |
| 987 | + getSwift5PlusAvailability(llvm::VersionTuple swiftVersion) const { |
| 988 | + return getSwiftAvailability(swiftVersion.getMajor(), |
| 989 | + *swiftVersion.getMinor()); |
| 990 | + } |
| 991 | + |
| 992 | + /// Get the runtime availability of getters and setters of multi payload enum |
| 993 | + /// tag single payloads. |
| 994 | + inline AvailabilityContext getMultiPayloadEnumTagSinglePayload() const { |
| 995 | + // This didn't fit the pattern, so needed renaming |
| 996 | + return getMultiPayloadEnumTagSinglePayloadAvailability(); |
| 997 | + } |
1032 | 998 |
|
1033 | 999 | //===--------------------------------------------------------------------===//
|
1034 | 1000 | // Diagnostics Helper functions
|
|
0 commit comments