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