mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
[TextAPI] Switch back to a custom Platform enum.
Moving to PlatformType from BinaryFormat had some UB fallout when handing unknown platforms or malformed input files. This should fix the sanitizer bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347836 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -515,11 +515,11 @@ template <> struct MappingTraits<const InterfaceFile *> {
|
||||
|
||||
std::vector<Architecture> Architectures;
|
||||
std::vector<UUID> UUIDs;
|
||||
PlatformType Platform;
|
||||
PlatformKind Platform{PlatformKind::unknown};
|
||||
StringRef InstallName;
|
||||
PackedVersion CurrentVersion;
|
||||
PackedVersion CompatibilityVersion;
|
||||
SwiftVersion SwiftABIVersion;
|
||||
SwiftVersion SwiftABIVersion{0};
|
||||
ObjCConstraintType ObjCConstraint{ObjCConstraintType::None};
|
||||
TBDFlags Flags{TBDFlags::None};
|
||||
StringRef ParentUmbrella;
|
||||
|
||||
@@ -43,43 +43,44 @@ void ScalarEnumerationTraits<ObjCConstraintType>::enumeration(
|
||||
IO.enumCase(Constraint, "gc", ObjCConstraintType::GC);
|
||||
}
|
||||
|
||||
void ScalarTraits<PlatformType>::output(const PlatformType &Value, void *,
|
||||
void ScalarTraits<PlatformKind>::output(const PlatformKind &Value, void *,
|
||||
raw_ostream &OS) {
|
||||
switch (Value) {
|
||||
case PLATFORM_MACOS:
|
||||
default:
|
||||
llvm_unreachable("unexpected platform");
|
||||
break;
|
||||
case PlatformKind::macOS:
|
||||
OS << "macosx";
|
||||
break;
|
||||
case PLATFORM_IOS:
|
||||
case PlatformKind::iOS:
|
||||
OS << "ios";
|
||||
break;
|
||||
case PLATFORM_WATCHOS:
|
||||
case PlatformKind::watchOS:
|
||||
OS << "watchos";
|
||||
break;
|
||||
case PLATFORM_TVOS:
|
||||
case PlatformKind::tvOS:
|
||||
OS << "tvos";
|
||||
break;
|
||||
case PLATFORM_BRIDGEOS:
|
||||
case PlatformKind::bridgeOS:
|
||||
OS << "bridgeos";
|
||||
break;
|
||||
}
|
||||
}
|
||||
StringRef ScalarTraits<PlatformType>::input(StringRef Scalar, void *,
|
||||
PlatformType &Value) {
|
||||
int Result = StringSwitch<unsigned>(Scalar)
|
||||
.Case("macosx", PLATFORM_MACOS)
|
||||
.Case("ios", PLATFORM_IOS)
|
||||
.Case("watchos", PLATFORM_WATCHOS)
|
||||
.Case("tvos", PLATFORM_TVOS)
|
||||
.Case("bridgeos", PLATFORM_BRIDGEOS)
|
||||
.Default(0);
|
||||
StringRef ScalarTraits<PlatformKind>::input(StringRef Scalar, void *,
|
||||
PlatformKind &Value) {
|
||||
Value = StringSwitch<PlatformKind>(Scalar)
|
||||
.Case("macosx", PlatformKind::macOS)
|
||||
.Case("ios", PlatformKind::iOS)
|
||||
.Case("watchos", PlatformKind::watchOS)
|
||||
.Case("tvos", PlatformKind::tvOS)
|
||||
.Case("bridgeos", PlatformKind::bridgeOS)
|
||||
.Default(PlatformKind::unknown);
|
||||
|
||||
if (!Result)
|
||||
if (Value == PlatformKind::unknown)
|
||||
return "unknown platform";
|
||||
|
||||
Value = static_cast<PlatformType>(Result);
|
||||
return {};
|
||||
}
|
||||
QuotingType ScalarTraits<PlatformType>::mustQuote(StringRef) {
|
||||
QuotingType ScalarTraits<PlatformKind>::mustQuote(StringRef) {
|
||||
return QuotingType::None;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ template <> struct ScalarEnumerationTraits<MachO::ObjCConstraintType> {
|
||||
static void enumeration(IO &, MachO::ObjCConstraintType &);
|
||||
};
|
||||
|
||||
template <> struct ScalarTraits<MachO::PlatformType> {
|
||||
static void output(const MachO::PlatformType &, void *, raw_ostream &);
|
||||
static StringRef input(StringRef, void *, MachO::PlatformType &);
|
||||
template <> struct ScalarTraits<MachO::PlatformKind> {
|
||||
static void output(const MachO::PlatformKind &, void *, raw_ostream &);
|
||||
static StringRef input(StringRef, void *, MachO::PlatformKind &);
|
||||
static QuotingType mustQuote(StringRef);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user