Skip to content

Commit b59910e

Browse files
committed
Add OpenBSD to PlatformKinds.def.
In swiftlang#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.
1 parent 6aebda5 commit b59910e

File tree

8 files changed

+25
-0
lines changed

8 files changed

+25
-0
lines changed

include/swift/AST/PlatformKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ AVAILABILITY_PLATFORM(watchOSApplicationExtension, "application extensions for w
3232
AVAILABILITY_PLATFORM(macOSApplicationExtension, "application extensions for macOS")
3333
AVAILABILITY_PLATFORM(macCatalyst, "Mac Catalyst")
3434
AVAILABILITY_PLATFORM(macCatalystApplicationExtension, "application extensions for Mac Catalyst")
35+
AVAILABILITY_PLATFORM(OpenBSD, "OpenBSD")
3536

3637
#undef AVAILABILITY_PLATFORM

lib/AST/PlatformKind.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ static bool isPlatformActiveForTarget(PlatformKind Platform,
8787
case PlatformKind::watchOS:
8888
case PlatformKind::watchOSApplicationExtension:
8989
return Target.isWatchOS();
90+
case PlatformKind::OpenBSD:
91+
return Target.isOSOpenBSD();
9092
case PlatformKind::none:
9193
llvm_unreachable("handled above");
9294
}

lib/ClangImporter/ClangImporter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,10 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts)
19301930
"APIs deprecated as of macOS 10.9 and earlier are unavailable in Swift";
19311931
break;
19321932

1933+
case PlatformKind::OpenBSD:
1934+
deprecatedAsUnavailableMessage = "";
1935+
break;
1936+
19331937
case PlatformKind::none:
19341938
break;
19351939
}
@@ -1962,6 +1966,9 @@ bool PlatformAvailability::isPlatformRelevant(StringRef name) const {
19621966
case PlatformKind::watchOSApplicationExtension:
19631967
return name == "watchos" || name == "watchos_app_extension";
19641968

1969+
case PlatformKind::OpenBSD:
1970+
return name == "openbsd";
1971+
19651972
case PlatformKind::none:
19661973
return false;
19671974
}
@@ -2001,6 +2008,10 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable(
20012008
case PlatformKind::watchOSApplicationExtension:
20022009
// No deprecation filter on watchOS
20032010
return false;
2011+
2012+
case PlatformKind::OpenBSD:
2013+
// No deprecation filter on OpenBSD
2014+
return false;
20042015
}
20052016

20062017
llvm_unreachable("Unexpected platform");

lib/PrintAsObjC/DeclAndTypePrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,9 @@ class DeclAndTypePrinter::Implementation
852852
case PlatformKind::watchOSApplicationExtension:
853853
plat = "watchos_app_extension";
854854
break;
855+
case PlatformKind::OpenBSD:
856+
plat = "openbsd";
857+
break;
855858
case PlatformKind::none:
856859
llvm_unreachable("handled above");
857860
}

lib/SymbolGraphGen/AvailabilityMixin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ StringRef getDomain(const AvailableAttr &AvAttr) {
5656
return { "tvOSAppExtension" };
5757
case swift::PlatformKind::watchOSApplicationExtension:
5858
return { "watchOSAppExtension" };
59+
case swift::PlatformKind::OpenBSD:
60+
return { "OpenBSD" };
5961
case swift::PlatformKind::none:
6062
return { "*" };
6163
}

lib/TBDGen/TBDGen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ getLinkerPlatformId(OriginallyDefinedInAttr::ActiveVersion Ver) {
249249
switch(Ver.Platform) {
250250
case swift::PlatformKind::none:
251251
llvm_unreachable("cannot find platform kind");
252+
case swift::PlatformKind::OpenBSD:
253+
llvm_unreachable("not used for this platform");
252254
case swift::PlatformKind::iOS:
253255
case swift::PlatformKind::iOSApplicationExtension:
254256
return Ver.IsSimulator ? LinkerPlatformId::iOS_sim:

test/IDE/complete_decl_attribute.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct MyStruct {}
3939
// AVAILABILITY1-NEXT: Keyword/None: macOSApplicationExtension[#Platform#]; name=macOSApplicationExtension{{$}}
4040
// AVAILABILITY1-NEXT: Keyword/None: macCatalyst[#Platform#]; name=macCatalyst
4141
// AVAILABILITY1-NEXT: Keyword/None: macCatalystApplicationExtension[#Platform#]; name=macCatalystApplicationExtension
42+
// AVAILABILITY1-NEXT: Keyword/None: OpenBSD[#Platform#]; name=OpenBSD{{$}}
4243
// AVAILABILITY1-NEXT: End completions
4344

4445
@available(*, #^AVAILABILITY2^#)

tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ static void reportAttributes(ASTContext &Ctx,
674674
static UIdent PlatformOSXAppExt("source.availability.platform.osx_app_extension");
675675
static UIdent PlatformtvOSAppExt("source.availability.platform.tvos_app_extension");
676676
static UIdent PlatformWatchOSAppExt("source.availability.platform.watchos_app_extension");
677+
static UIdent PlatformOpenBSD("source.availability.platform.openbsd");
677678
std::vector<const DeclAttribute*> Scratch;
678679

679680
for (auto Attr : getDeclAttributes(D, Scratch)) {
@@ -702,6 +703,8 @@ static void reportAttributes(ASTContext &Ctx,
702703
PlatformUID = PlatformtvOSAppExt; break;
703704
case PlatformKind::watchOSApplicationExtension:
704705
PlatformUID = PlatformWatchOSAppExt; break;
706+
case PlatformKind::OpenBSD:
707+
PlatformUID = PlatformOpenBSD; break;
705708
}
706709

707710
AvailableAttrInfo Info;

0 commit comments

Comments
 (0)