summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TextAPI/MachO
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/TextAPI/MachO')
-rw-r--r--llvm/lib/TextAPI/MachO/Platform.cpp33
-rw-r--r--llvm/lib/TextAPI/MachO/TextStub.cpp16
-rw-r--r--llvm/lib/TextAPI/MachO/TextStubCommon.cpp29
3 files changed, 74 insertions, 4 deletions
diff --git a/llvm/lib/TextAPI/MachO/Platform.cpp b/llvm/lib/TextAPI/MachO/Platform.cpp
index 66bb7df9aa5..588ec9a4d83 100644
--- a/llvm/lib/TextAPI/MachO/Platform.cpp
+++ b/llvm/lib/TextAPI/MachO/Platform.cpp
@@ -17,6 +17,20 @@
namespace llvm {
namespace MachO {
+PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim) {
+ switch (Platform) {
+ default:
+ return Platform;
+ case PlatformKind::iOS:
+ return WantSim ? PlatformKind::iOSSimulator : PlatformKind::iOS;
+ case PlatformKind::tvOS:
+ return WantSim ? PlatformKind::tvOSSimulator : PlatformKind::tvOS;
+ case PlatformKind::watchOS:
+ return WantSim ? PlatformKind::watchOSSimulator : PlatformKind::watchOS;
+ }
+ llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
+}
+
PlatformKind mapToPlatformKind(const Triple &Target) {
switch (Target.getOS()) {
default:
@@ -24,13 +38,20 @@ PlatformKind mapToPlatformKind(const Triple &Target) {
case Triple::MacOSX:
return PlatformKind::macOS;
case Triple::IOS:
+ if (Target.isSimulatorEnvironment())
+ return PlatformKind::iOSSimulator;
+ if (Target.getEnvironment() == Triple::MacABI)
+ return PlatformKind::macCatalyst;
return PlatformKind::iOS;
case Triple::TvOS:
- return PlatformKind::tvOS;
+ return Target.isSimulatorEnvironment() ? PlatformKind::tvOSSimulator
+ : PlatformKind::tvOS;
case Triple::WatchOS:
- return PlatformKind::watchOS;
+ return Target.isSimulatorEnvironment() ? PlatformKind::watchOSSimulator
+ : PlatformKind::watchOS;
// TODO: add bridgeOS once in llvm::Triple
}
+ llvm_unreachable("Unknown Target Triple");
}
PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets) {
@@ -54,6 +75,14 @@ StringRef getPlatformName(PlatformKind Platform) {
return "watchOS";
case PlatformKind::bridgeOS:
return "bridgeOS";
+ case PlatformKind::macCatalyst:
+ return "macCatalyst";
+ case PlatformKind::iOSSimulator:
+ return "iOS Simulator";
+ case PlatformKind::tvOSSimulator:
+ return "tvOS Simulator";
+ case PlatformKind::watchOSSimulator:
+ return "watchOS Simulator";
}
llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
}
diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp
index 1f1d39ee018..78c9f54ba22 100644
--- a/llvm/lib/TextAPI/MachO/TextStub.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStub.cpp
@@ -399,13 +399,25 @@ template <> struct MappingTraits<const InterfaceFile *> {
}
}
+ // TBD v1 - TBD v3 files only support one platform and several
+ // architectures. It is possible to have more than one platform for TBD v3
+ // files, but the architectures don't apply to all
+ // platforms, specifically to filter out the i386 slice from
+ // platform macCatalyst.
TargetList synthesizeTargets(ArchitectureSet Architectures,
- const PlatformSet &Platforms) {
+ const PlatformSet &Platforms) {
TargetList Targets;
for (auto Platform : Platforms) {
- for (const auto &&Architecture : Architectures)
+ Platform = mapToPlatformKind(Platform, Architectures.hasX86());
+
+ for (const auto &&Architecture : Architectures) {
+ if ((Architecture == AK_i386) &&
+ (Platform == PlatformKind::macCatalyst))
+ continue;
+
Targets.emplace_back(Architecture, Platform);
+ }
}
return Targets;
}
diff --git a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
index 313b040557b..806ca0324e1 100644
--- a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
@@ -43,6 +43,17 @@ void ScalarEnumerationTraits<ObjCConstraintType>::enumeration(
void ScalarTraits<PlatformSet>::output(const PlatformSet &Values, void *IO,
raw_ostream &OS) {
+
+ const auto *Ctx = reinterpret_cast<TextAPIContext *>(IO);
+ assert((!Ctx || Ctx && Ctx->FileKind != FileType::Invalid) &&
+ "File type is not set in context");
+
+ if ( Ctx && Ctx->FileKind == TBD_V3 && Values.count(PlatformKind::macOS) &&
+ Values.count(PlatformKind::macCatalyst) ) {
+ OS << "zippered";
+ return;
+ }
+
assert(Values.size() == 1U);
switch (*Values.begin()) {
default:
@@ -68,6 +79,19 @@ void ScalarTraits<PlatformSet>::output(const PlatformSet &Values, void *IO,
StringRef ScalarTraits<PlatformSet>::input(StringRef Scalar, void *IO,
PlatformSet &Values) {
+ const auto *Ctx = reinterpret_cast<TextAPIContext *>(IO);
+ assert((!Ctx || Ctx && Ctx->FileKind != FileType::Invalid) &&
+ "File type is not set in context");
+
+ if (Scalar == "zippered") {
+ if (Ctx && Ctx->FileKind == FileType::TBD_V3) {
+ Values.insert(PlatformKind::macOS);
+ Values.insert(PlatformKind::macCatalyst);
+ return {};
+ }
+ return "invalid platform";
+ }
+
auto Platform = StringSwitch<PlatformKind>(Scalar)
.Case("unknown", PlatformKind::unknown)
.Case("macosx", PlatformKind::macOS)
@@ -75,8 +99,13 @@ StringRef ScalarTraits<PlatformSet>::input(StringRef Scalar, void *IO,
.Case("watchos", PlatformKind::watchOS)
.Case("tvos", PlatformKind::tvOS)
.Case("bridgeos", PlatformKind::bridgeOS)
+ .Case("iosmac", PlatformKind::macCatalyst)
.Default(PlatformKind::unknown);
+ if (Platform == PlatformKind::macCatalyst)
+ if (Ctx && Ctx->FileKind != FileType::TBD_V3)
+ return "invalid platform";
+
if (Platform == PlatformKind::unknown)
return "unknown platform";
OpenPOWER on IntegriCloud