Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/swift/AST/PlatformKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ AVAILABILITY_PLATFORM(visionOSApplicationExtension, "application extensions for
AVAILABILITY_PLATFORM(macOSApplicationExtension, "application extensions for macOS")
AVAILABILITY_PLATFORM(macCatalyst, "Mac Catalyst")
AVAILABILITY_PLATFORM(macCatalystApplicationExtension, "application extensions for Mac Catalyst")
AVAILABILITY_PLATFORM(DriverKit, "DriverKit")
/// A meta-platform representing the built-in Swift runtime.
AVAILABILITY_PLATFORM(Swift, "Swift")
/// A meta-platform for Apple operating systems with unified versioning.
AVAILABILITY_PLATFORM(anyAppleOS, "any Apple OS")
AVAILABILITY_PLATFORM(FreeBSD, "FreeBSD")
AVAILABILITY_PLATFORM(OpenBSD, "OpenBSD")
AVAILABILITY_PLATFORM(Windows, "Windows")
Expand Down
16 changes: 16 additions & 0 deletions lib/AST/PlatformKindUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ swift::basePlatformForExtensionPlatform(PlatformKind Platform) {
case PlatformKind::tvOS:
case PlatformKind::watchOS:
case PlatformKind::visionOS:
case PlatformKind::DriverKit:
case PlatformKind::Swift:
case PlatformKind::anyAppleOS:
case PlatformKind::FreeBSD:
case PlatformKind::OpenBSD:
case PlatformKind::Windows:
Expand Down Expand Up @@ -159,6 +162,11 @@ static bool isPlatformActiveForTarget(PlatformKind Platform,
case PlatformKind::visionOS:
case PlatformKind::visionOSApplicationExtension:
return Target.isXROS();
case PlatformKind::DriverKit:
return Target.isDriverKit();
case PlatformKind::Swift:
case PlatformKind::anyAppleOS:
return Target.isOSDarwin();
case PlatformKind::OpenBSD:
return Target.isOSOpenBSD();
case PlatformKind::FreeBSD:
Expand Down Expand Up @@ -292,6 +300,11 @@ swift::tripleOSTypeForPlatform(PlatformKind platform) {
case PlatformKind::visionOS:
case PlatformKind::visionOSApplicationExtension:
return llvm::Triple::XROS;
case PlatformKind::DriverKit:
return llvm::Triple::DriverKit;
case PlatformKind::Swift:
case PlatformKind::anyAppleOS:
return std::nullopt;
case PlatformKind::FreeBSD:
return llvm::Triple::FreeBSD;
case PlatformKind::OpenBSD:
Expand Down Expand Up @@ -332,6 +345,9 @@ bool swift::isPlatformSPI(PlatformKind Platform) {
case PlatformKind::watchOSApplicationExtension:
case PlatformKind::visionOS:
case PlatformKind::visionOSApplicationExtension:
case PlatformKind::DriverKit:
case PlatformKind::Swift:
case PlatformKind::anyAppleOS:
case PlatformKind::OpenBSD:
case PlatformKind::FreeBSD:
case PlatformKind::Windows:
Expand Down
24 changes: 24 additions & 0 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,14 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts)
case PlatformKind::visionOSApplicationExtension:
break;

case PlatformKind::DriverKit:
deprecatedAsUnavailableMessage = "";
break;

case PlatformKind::Swift:
case PlatformKind::anyAppleOS:
llvm_unreachable("Unexpected platform");

case PlatformKind::FreeBSD:
deprecatedAsUnavailableMessage = "";
break;
Expand Down Expand Up @@ -2616,6 +2624,13 @@ bool PlatformAvailability::isPlatformRelevant(StringRef name) const {
return name == "xros" || name == "xros_app_extension" ||
name == "visionos" || name == "visionos_app_extension";

case PlatformKind::DriverKit:
return name == "driverkit";

case PlatformKind::Swift:
case PlatformKind::anyAppleOS:
break; // Unexpected

case PlatformKind::FreeBSD:
return name == "freebsd";

Expand Down Expand Up @@ -2693,6 +2708,15 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable(
// No deprecation filter on xrOS
return false;

case PlatformKind::DriverKit:
// No deprecation filter on DriverKit
// FIXME: [availability] This should probably have a value.
return false;

case PlatformKind::Swift:
case PlatformKind::anyAppleOS:
break; // Unexpected

case PlatformKind::FreeBSD:
// No deprecation filter on FreeBSD
return false;
Expand Down
7 changes: 7 additions & 0 deletions lib/IRGen/TBDGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ getLinkerPlatformId(OriginallyDefinedInAttr::ActiveVersion Ver,
switch(Ver.Platform) {
case swift::PlatformKind::none:
llvm_unreachable("cannot find platform kind");
case swift::PlatformKind::DriverKit:
llvm_unreachable("not used for this platform");
case swift::PlatformKind::Swift:
llvm_unreachable("not used for this platform");
case PlatformKind::anyAppleOS:
llvm_unreachable("not used for this platform");
case swift::PlatformKind::FreeBSD:
llvm_unreachable("not used for this platform");
case swift::PlatformKind::OpenBSD:
Expand All @@ -253,6 +259,7 @@ getLinkerPlatformId(OriginallyDefinedInAttr::ActiveVersion Ver,
llvm_unreachable("not used for this platform");
case swift::PlatformKind::Android:
llvm_unreachable("not used for this platform");

case swift::PlatformKind::iOS:
case swift::PlatformKind::iOSApplicationExtension:
if (target && target->isMacCatalystEnvironment())
Expand Down
8 changes: 8 additions & 0 deletions lib/PrintAsClang/DeclAndTypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,14 @@ class DeclAndTypePrinter::Implementation
case PlatformKind::visionOSApplicationExtension:
plat = "visionos_app_extension";
break;
case PlatformKind::DriverKit:
plat = "driverkit";
break;
case PlatformKind::Swift:
case PlatformKind::anyAppleOS:
// FIXME: [runtime availability] Figure out how to support this.
ASSERT(0);
break;
case PlatformKind::FreeBSD:
plat = "freebsd";
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 970; // return_borrow
const uint16_t SWIFTMODULE_VERSION_MINOR = 971; // new platform kinds

/// A standard hash seed used for all string hashes in a serialized module.
///
Expand Down
6 changes: 6 additions & 0 deletions lib/SymbolGraphGen/AvailabilityMixin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ StringRef getDomain(const SemanticAvailableAttr &AvAttr) {
return { "watchOSAppExtension" };
case swift::PlatformKind::visionOSApplicationExtension:
return { "visionOSAppExtension" };
case PlatformKind::DriverKit:
return { "DriverKit" };
case swift::PlatformKind::Swift:
return { "Swift" };
case PlatformKind::anyAppleOS:
return { "Any Apple OS" };
case swift::PlatformKind::FreeBSD:
return { "FreeBSD" };
case swift::PlatformKind::OpenBSD:
Expand Down
3 changes: 3 additions & 0 deletions test/IDE/complete_decl_attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ actor MyGenericGlobalActor<T> {
// AVAILABILITY1-NEXT: Keyword/None: macOSApplicationExtension[#Platform#]; name=macOSApplicationExtension{{$}}
// AVAILABILITY1-NEXT: Keyword/None: macCatalyst[#Platform#]; name=macCatalyst
// AVAILABILITY1-NEXT: Keyword/None: macCatalystApplicationExtension[#Platform#]; name=macCatalystApplicationExtension
// AVAILABILITY1-NEXT: Keyword/None: DriverKit[#Platform#]; name=DriverKit{{$}}
// AVAILABILITY1-NEXT: Keyword/None: Swift[#Platform#]; name=Swift{{$}}
// AVAILABILITY1-NEXT: Keyword/None: anyAppleOS[#Platform#]; name=anyAppleOS{{$}}
// AVAILABILITY1-NEXT: Keyword/None: FreeBSD[#Platform#]; name=FreeBSD{{$}}
// AVAILABILITY1-NEXT: Keyword/None: OpenBSD[#Platform#]; name=OpenBSD{{$}}
// AVAILABILITY1-NEXT: Keyword/None: Windows[#Platform#]; name=Windows{{$}}
Expand Down
14 changes: 13 additions & 1 deletion tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ static void reportAvailabilityAttributes(ASTContext &Ctx, const Decl *D,
static UIdent PlatformOSXAppExt("source.availability.platform.osx_app_extension");
static UIdent PlatformtvOSAppExt("source.availability.platform.tvos_app_extension");
static UIdent PlatformWatchOSAppExt("source.availability.platform.watchos_app_extension");
static UIdent PlatformDriverKit("source.availability.platform.driverkit");
static UIdent PlatformSwift("source.availability.platform.swift");
static UIdent PlatformAnyAppleOS("source.availability.platform.any_apple_os");
static UIdent PlatformFreeBSD("source.availability.platform.freebsd");
static UIdent PlatformOpenBSD("source.availability.platform.openbsd");
static UIdent PlatformWindows("source.availability.platform.windows");
Expand Down Expand Up @@ -743,6 +746,15 @@ static void reportAvailabilityAttributes(ASTContext &Ctx, const Decl *D,
// FIXME: Formal platform support in SourceKit is needed.
PlatformUID = UIdent();
break;
case PlatformKind::DriverKit:
PlatformUID = PlatformDriverKit;
break;
case PlatformKind::Swift:
PlatformUID = PlatformSwift;
break;
case PlatformKind::anyAppleOS:
PlatformUID = PlatformAnyAppleOS;
break;
case PlatformKind::OpenBSD:
PlatformUID = PlatformOpenBSD;
break;
Expand All @@ -756,7 +768,7 @@ static void reportAvailabilityAttributes(ASTContext &Ctx, const Decl *D,
PlatformUID = PlatformAndroid;
break;
}
// FIXME: [availability] Handle other availability domains?
// FIXME: [availability] Handle non-platform availability domains?

AvailableAttrInfo Info;
Info.AttrKind = AvailableAttrKind;
Expand Down