Add OpenBSD to PlatformKinds.def.

In #31686 changes were introduced to ensure that capacity was stored in
the ManagedBuffer allocation, and @lorentey sugested that as a stopgap
measure for addressing the lack of platform malloc introspection on
OpenBSD, we use Swift availability attributes instead on the relevant
parts of ManagedBuffer and friends.

Since platform availability symbols must be specifically set up to be
used, this commit does so in advance of the above change.
This commit is contained in:
3405691582
2020-08-21 18:27:10 -04:00
parent 6aebda51ce
commit b59910ef5b
8 changed files with 25 additions and 0 deletions

View File

@@ -32,5 +32,6 @@ AVAILABILITY_PLATFORM(watchOSApplicationExtension, "application extensions for w
AVAILABILITY_PLATFORM(macOSApplicationExtension, "application extensions for macOS")
AVAILABILITY_PLATFORM(macCatalyst, "Mac Catalyst")
AVAILABILITY_PLATFORM(macCatalystApplicationExtension, "application extensions for Mac Catalyst")
AVAILABILITY_PLATFORM(OpenBSD, "OpenBSD")
#undef AVAILABILITY_PLATFORM

View File

@@ -87,6 +87,8 @@ static bool isPlatformActiveForTarget(PlatformKind Platform,
case PlatformKind::watchOS:
case PlatformKind::watchOSApplicationExtension:
return Target.isWatchOS();
case PlatformKind::OpenBSD:
return Target.isOSOpenBSD();
case PlatformKind::none:
llvm_unreachable("handled above");
}

View File

@@ -1930,6 +1930,10 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts)
"APIs deprecated as of macOS 10.9 and earlier are unavailable in Swift";
break;
case PlatformKind::OpenBSD:
deprecatedAsUnavailableMessage = "";
break;
case PlatformKind::none:
break;
}
@@ -1962,6 +1966,9 @@ bool PlatformAvailability::isPlatformRelevant(StringRef name) const {
case PlatformKind::watchOSApplicationExtension:
return name == "watchos" || name == "watchos_app_extension";
case PlatformKind::OpenBSD:
return name == "openbsd";
case PlatformKind::none:
return false;
}
@@ -2001,6 +2008,10 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable(
case PlatformKind::watchOSApplicationExtension:
// No deprecation filter on watchOS
return false;
case PlatformKind::OpenBSD:
// No deprecation filter on OpenBSD
return false;
}
llvm_unreachable("Unexpected platform");

View File

@@ -852,6 +852,9 @@ private:
case PlatformKind::watchOSApplicationExtension:
plat = "watchos_app_extension";
break;
case PlatformKind::OpenBSD:
plat = "openbsd";
break;
case PlatformKind::none:
llvm_unreachable("handled above");
}

View File

@@ -56,6 +56,8 @@ StringRef getDomain(const AvailableAttr &AvAttr) {
return { "tvOSAppExtension" };
case swift::PlatformKind::watchOSApplicationExtension:
return { "watchOSAppExtension" };
case swift::PlatformKind::OpenBSD:
return { "OpenBSD" };
case swift::PlatformKind::none:
return { "*" };
}

View File

@@ -249,6 +249,8 @@ getLinkerPlatformId(OriginallyDefinedInAttr::ActiveVersion Ver) {
switch(Ver.Platform) {
case swift::PlatformKind::none:
llvm_unreachable("cannot find platform kind");
case swift::PlatformKind::OpenBSD:
llvm_unreachable("not used for this platform");
case swift::PlatformKind::iOS:
case swift::PlatformKind::iOSApplicationExtension:
return Ver.IsSimulator ? LinkerPlatformId::iOS_sim:

View File

@@ -39,6 +39,7 @@ struct MyStruct {}
// 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: OpenBSD[#Platform#]; name=OpenBSD{{$}}
// AVAILABILITY1-NEXT: End completions
@available(*, #^AVAILABILITY2^#)

View File

@@ -674,6 +674,7 @@ static void reportAttributes(ASTContext &Ctx,
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 PlatformOpenBSD("source.availability.platform.openbsd");
std::vector<const DeclAttribute*> Scratch;
for (auto Attr : getDeclAttributes(D, Scratch)) {
@@ -702,6 +703,8 @@ static void reportAttributes(ASTContext &Ctx,
PlatformUID = PlatformtvOSAppExt; break;
case PlatformKind::watchOSApplicationExtension:
PlatformUID = PlatformWatchOSAppExt; break;
case PlatformKind::OpenBSD:
PlatformUID = PlatformOpenBSD; break;
}
AvailableAttrInfo Info;