https://github.com/ributzka updated https://github.com/llvm/llvm-project/pull/69262
>From d6a4d1cc70e7d3a13b94ff397bef8a0a75e21257 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka <juer...@ributzka.de> Date: Mon, 28 Aug 2023 15:25:48 -0700 Subject: [PATCH 1/3] [llvm] Use XMACROS for MachO platforms. This change adds the PLATFORM XMACRO to simplify the addition of new MachO platforms and reduce the number of required changes. Many of the changes needed for adding a new platform are mechanical, such as adding new cases to a switch statement. This will help streamline the process by consolidating much of the necessary information into the MachO.def file. --- clang/lib/CodeGen/CGObjC.cpp | 2 +- llvm/include/llvm/BinaryFormat/MachO.def | 16 ++++++++++ llvm/include/llvm/BinaryFormat/MachO.h | 14 ++------- llvm/include/llvm/Object/MachO.h | 14 +++------ llvm/lib/MC/MCAsmStreamer.cpp | 16 +++------- llvm/lib/MC/MCParser/DarwinAsmParser.cpp | 14 ++++----- llvm/lib/TextAPI/Platform.cpp | 39 +++++------------------- llvm/lib/TextAPI/Target.cpp | 13 ++------ llvm/lib/TextAPI/TextStub.cpp | 38 +++-------------------- 9 files changed, 49 insertions(+), 117 deletions(-) diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 6c594b5db4bca1f..aa3a0ff57003d7c 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -3954,7 +3954,7 @@ static unsigned getBaseMachOPlatformID(const llvm::Triple &TT) { case llvm::Triple::DriverKit: return llvm::MachO::PLATFORM_DRIVERKIT; default: - return /*Unknown platform*/ 0; + return llvm::MachO::PLATFORM_UNKNOWN; } } diff --git a/llvm/include/llvm/BinaryFormat/MachO.def b/llvm/include/llvm/BinaryFormat/MachO.def index d841b42ee808b2e..70966952ca7efe1 100644 --- a/llvm/include/llvm/BinaryFormat/MachO.def +++ b/llvm/include/llvm/BinaryFormat/MachO.def @@ -120,5 +120,21 @@ LOAD_COMMAND_STRUCT(fileset_entry_command) #endif +#ifdef PLATFORM +// PLATFORM(platform, id, name, target, tapi_target, marketing) +PLATFORM(UNKNOWN, 0, unknown, unknown, unknown, unknown) +PLATFORM(MACOS, 1, macos, macos, macos, macOS) +PLATFORM(IOS, 2, ios, ios, ios, iOS) +PLATFORM(TVOS, 3, tvos, tvos, tvos, tvOS) +PLATFORM(WATCHOS, 4, watchos, watchos, watchos, watchOS) +PLATFORM(BRIDGEOS, 5, bridgeos, bridgeos, bridgeos, bridgeOS) +PLATFORM(MACCATALYST, 6, macCatalyst, ios-macabi, maccatalyst, macCatalyst) +PLATFORM(IOSSIMULATOR, 7, iossimulator, ios-simulator, ios-simulator, iOS Simulator) +PLATFORM(TVOSSIMULATOR, 8, tvossimulator, tvos-simulator, tvos-simulator, tvOS Simulator) +PLATFORM(WATCHOSSIMULATOR, 9, watchossimulator, watchos-simulator, watchos-simulator, watchOS Simulator) +PLATFORM(DRIVERKIT, 10, driverkit, driverkit, driverkit, DriverKit) +#endif + #undef HANDLE_LOAD_COMMAND #undef LOAD_COMMAND_STRUCT +#undef PLATFORM diff --git a/llvm/include/llvm/BinaryFormat/MachO.h b/llvm/include/llvm/BinaryFormat/MachO.h index f59cd14c1b5c055..6dfc115c7e905fc 100644 --- a/llvm/include/llvm/BinaryFormat/MachO.h +++ b/llvm/include/llvm/BinaryFormat/MachO.h @@ -497,17 +497,9 @@ enum { VM_PROT_READ = 0x1, VM_PROT_WRITE = 0x2, VM_PROT_EXECUTE = 0x4 }; // Values for platform field in build_version_command. enum PlatformType { - PLATFORM_UNKNOWN = 0, - PLATFORM_MACOS = 1, - PLATFORM_IOS = 2, - PLATFORM_TVOS = 3, - PLATFORM_WATCHOS = 4, - PLATFORM_BRIDGEOS = 5, - PLATFORM_MACCATALYST = 6, - PLATFORM_IOSSIMULATOR = 7, - PLATFORM_TVOSSIMULATOR = 8, - PLATFORM_WATCHOSSIMULATOR = 9, - PLATFORM_DRIVERKIT = 10, +#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + PLATFORM_##platform = id, +#include "MachO.def" }; // Values for tools enum in build_tool_version. diff --git a/llvm/include/llvm/Object/MachO.h b/llvm/include/llvm/Object/MachO.h index 894252db538f9e7..7bb2be76ff5b865 100644 --- a/llvm/include/llvm/Object/MachO.h +++ b/llvm/include/llvm/Object/MachO.h @@ -789,16 +789,10 @@ class MachOObjectFile : public ObjectFile { static std::string getBuildPlatform(uint32_t platform) { switch (platform) { - case MachO::PLATFORM_MACOS: return "macos"; - case MachO::PLATFORM_IOS: return "ios"; - case MachO::PLATFORM_TVOS: return "tvos"; - case MachO::PLATFORM_WATCHOS: return "watchos"; - case MachO::PLATFORM_BRIDGEOS: return "bridgeos"; - case MachO::PLATFORM_MACCATALYST: return "macCatalyst"; - case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator"; - case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator"; - case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator"; - case MachO::PLATFORM_DRIVERKIT: return "driverkit"; +#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + case MachO::PLATFORM_##platform: \ + return #name; +#include "llvm/BinaryFormat/MachO.def" default: std::string ret; raw_string_ostream ss(ret); diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 06de70ad2f395a2..01fc90513daca39 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -629,18 +629,10 @@ void MCAsmStreamer::emitVersionMin(MCVersionMinType Type, unsigned Major, static const char *getPlatformName(MachO::PlatformType Type) { switch (Type) { - case MachO::PLATFORM_UNKNOWN: /* silence warning*/ - break; - case MachO::PLATFORM_MACOS: return "macos"; - case MachO::PLATFORM_IOS: return "ios"; - case MachO::PLATFORM_TVOS: return "tvos"; - case MachO::PLATFORM_WATCHOS: return "watchos"; - case MachO::PLATFORM_BRIDGEOS: return "bridgeos"; - case MachO::PLATFORM_MACCATALYST: return "macCatalyst"; - case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator"; - case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator"; - case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator"; - case MachO::PLATFORM_DRIVERKIT: return "driverkit"; +#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + case MachO::PLATFORM_##platform: \ + return #name; +#include "llvm/BinaryFormat/MachO.def" } llvm_unreachable("Invalid Mach-O platform type"); } diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp index 7c390041b3698a4..287af822311cb63 100644 --- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp @@ -1167,14 +1167,12 @@ bool DarwinAsmParser::parseBuildVersion(StringRef Directive, SMLoc Loc) { return TokError("platform name expected"); unsigned Platform = StringSwitch<unsigned>(PlatformName) - .Case("macos", MachO::PLATFORM_MACOS) - .Case("ios", MachO::PLATFORM_IOS) - .Case("tvos", MachO::PLATFORM_TVOS) - .Case("watchos", MachO::PLATFORM_WATCHOS) - .Case("macCatalyst", MachO::PLATFORM_MACCATALYST) - .Case("driverkit", MachO::PLATFORM_DRIVERKIT) - .Default(0); - if (Platform == 0) + #define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + .Case(#name, MachO::PLATFORM_##platform) + #include "llvm/BinaryFormat/MachO.def" + .Default(MachO::PLATFORM_UNKNOWN); + + if (Platform == MachO::PLATFORM_UNKNOWN) return Error(PlatformLoc, "unknown platform name"); if (getLexer().isNot(AsmToken::Comma)) diff --git a/llvm/lib/TextAPI/Platform.cpp b/llvm/lib/TextAPI/Platform.cpp index d0575847a876a75..963acd2fe9f381c 100644 --- a/llvm/lib/TextAPI/Platform.cpp +++ b/llvm/lib/TextAPI/Platform.cpp @@ -62,28 +62,10 @@ PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets) { StringRef getPlatformName(PlatformType Platform) { switch (Platform) { - case PLATFORM_UNKNOWN: - return "unknown"; - case PLATFORM_MACOS: - return "macOS"; - case PLATFORM_IOS: - return "iOS"; - case PLATFORM_TVOS: - return "tvOS"; - case PLATFORM_WATCHOS: - return "watchOS"; - case PLATFORM_BRIDGEOS: - return "bridgeOS"; - case PLATFORM_MACCATALYST: - return "macCatalyst"; - case PLATFORM_IOSSIMULATOR: - return "iOS Simulator"; - case PLATFORM_TVOSSIMULATOR: - return "tvOS Simulator"; - case PLATFORM_WATCHOSSIMULATOR: - return "watchOS Simulator"; - case PLATFORM_DRIVERKIT: - return "DriverKit"; +#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + case PLATFORM_##platform: \ + return #marketing; +#include "llvm/BinaryFormat/MachO.def" } llvm_unreachable("Unknown llvm::MachO::PlatformType enum"); } @@ -91,16 +73,9 @@ StringRef getPlatformName(PlatformType Platform) { PlatformType getPlatformFromName(StringRef Name) { return StringSwitch<PlatformType>(Name) .Case("osx", PLATFORM_MACOS) - .Case("macos", PLATFORM_MACOS) - .Case("ios", PLATFORM_IOS) - .Case("tvos", PLATFORM_TVOS) - .Case("watchos", PLATFORM_WATCHOS) - .Case("bridgeos", PLATFORM_BRIDGEOS) - .Case("ios-macabi", PLATFORM_MACCATALYST) - .Case("ios-simulator", PLATFORM_IOSSIMULATOR) - .Case("tvos-simulator", PLATFORM_TVOSSIMULATOR) - .Case("watchos-simulator", PLATFORM_WATCHOSSIMULATOR) - .Case("driverkit", PLATFORM_DRIVERKIT) +#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + .Case(#tapi_target, PLATFORM_##platform) +#include "llvm/BinaryFormat/MachO.def" .Default(PLATFORM_UNKNOWN); } diff --git a/llvm/lib/TextAPI/Target.cpp b/llvm/lib/TextAPI/Target.cpp index e20842498331490..4ac442ea99d3cd1 100644 --- a/llvm/lib/TextAPI/Target.cpp +++ b/llvm/lib/TextAPI/Target.cpp @@ -21,16 +21,9 @@ Expected<Target> Target::create(StringRef TargetValue) { auto PlatformStr = Result.second; PlatformType Platform; Platform = StringSwitch<PlatformType>(PlatformStr) - .Case("macos", PLATFORM_MACOS) - .Case("ios", PLATFORM_IOS) - .Case("tvos", PLATFORM_TVOS) - .Case("watchos", PLATFORM_WATCHOS) - .Case("bridgeos", PLATFORM_BRIDGEOS) - .Case("maccatalyst", PLATFORM_MACCATALYST) - .Case("ios-simulator", PLATFORM_IOSSIMULATOR) - .Case("tvos-simulator", PLATFORM_TVOSSIMULATOR) - .Case("watchos-simulator", PLATFORM_WATCHOSSIMULATOR) - .Case("driverkit", PLATFORM_DRIVERKIT) +#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + .Case(#tapi_target, PLATFORM_##platform) +#include "llvm/BinaryFormat/MachO.def" .Default(PLATFORM_UNKNOWN); if (Platform == PLATFORM_UNKNOWN) { diff --git a/llvm/lib/TextAPI/TextStub.cpp b/llvm/lib/TextAPI/TextStub.cpp index 3b94f084b538c54..2eb67b8fb56078b 100644 --- a/llvm/lib/TextAPI/TextStub.cpp +++ b/llvm/lib/TextAPI/TextStub.cpp @@ -367,39 +367,11 @@ template <> struct ScalarTraits<Target> { static void output(const Target &Value, void *, raw_ostream &OS) { OS << Value.Arch << "-"; switch (Value.Platform) { - default: - OS << "unknown"; - break; - case PLATFORM_MACOS: - OS << "macos"; - break; - case PLATFORM_IOS: - OS << "ios"; - break; - case PLATFORM_TVOS: - OS << "tvos"; - break; - case PLATFORM_WATCHOS: - OS << "watchos"; - break; - case PLATFORM_BRIDGEOS: - OS << "bridgeos"; - break; - case PLATFORM_MACCATALYST: - OS << "maccatalyst"; - break; - case PLATFORM_IOSSIMULATOR: - OS << "ios-simulator"; - break; - case PLATFORM_TVOSSIMULATOR: - OS << "tvos-simulator"; - break; - case PLATFORM_WATCHOSSIMULATOR: - OS << "watchos-simulator"; - break; - case PLATFORM_DRIVERKIT: - OS << "driverkit"; - break; +#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + case PLATFORM_##platform: \ + OS << #tapi_target; \ + break; +#include "llvm/BinaryFormat/MachO.def" } } >From 33dbb29663dfc475a03f23ec1fe13646a3ded417 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka <juer...@ributzka.de> Date: Mon, 16 Oct 2023 16:22:23 -0700 Subject: [PATCH 2/3] Fix formating. --- llvm/lib/MC/MCParser/DarwinAsmParser.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp index 287af822311cb63..4a8fc7388ec88b9 100644 --- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp @@ -1167,11 +1167,11 @@ bool DarwinAsmParser::parseBuildVersion(StringRef Directive, SMLoc Loc) { return TokError("platform name expected"); unsigned Platform = StringSwitch<unsigned>(PlatformName) - #define PLATFORM(platform, id, name, target, tapi_target, marketing) \ - .Case(#name, MachO::PLATFORM_##platform) - #include "llvm/BinaryFormat/MachO.def" - .Default(MachO::PLATFORM_UNKNOWN); - +#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ + .Case(#name, MachO::PLATFORM_##platform) +#include "llvm/BinaryFormat/MachO.def" + .Default(MachO::PLATFORM_UNKNOWN); + if (Platform == MachO::PLATFORM_UNKNOWN) return Error(PlatformLoc, "unknown platform name"); >From 036206a188e3343a357ea214a26b9b0d6425d1d8 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka <juer...@ributzka.de> Date: Thu, 19 Oct 2023 13:55:52 -0700 Subject: [PATCH 3/3] Add .buildversion specific platform name. --- llvm/include/llvm/BinaryFormat/MachO.def | 24 ++++++++++++------------ llvm/include/llvm/BinaryFormat/MachO.h | 3 ++- llvm/include/llvm/Object/MachO.h | 3 ++- llvm/lib/MC/MCAsmStreamer.cpp | 5 +++-- llvm/lib/MC/MCParser/DarwinAsmParser.cpp | 5 +++-- llvm/lib/TextAPI/Platform.cpp | 6 ++++-- llvm/lib/TextAPI/Target.cpp | 3 ++- llvm/lib/TextAPI/TextStub.cpp | 3 ++- 8 files changed, 30 insertions(+), 22 deletions(-) diff --git a/llvm/include/llvm/BinaryFormat/MachO.def b/llvm/include/llvm/BinaryFormat/MachO.def index 70966952ca7efe1..df527b4a8ab7c3c 100644 --- a/llvm/include/llvm/BinaryFormat/MachO.def +++ b/llvm/include/llvm/BinaryFormat/MachO.def @@ -121,18 +121,18 @@ LOAD_COMMAND_STRUCT(fileset_entry_command) #endif #ifdef PLATFORM -// PLATFORM(platform, id, name, target, tapi_target, marketing) -PLATFORM(UNKNOWN, 0, unknown, unknown, unknown, unknown) -PLATFORM(MACOS, 1, macos, macos, macos, macOS) -PLATFORM(IOS, 2, ios, ios, ios, iOS) -PLATFORM(TVOS, 3, tvos, tvos, tvos, tvOS) -PLATFORM(WATCHOS, 4, watchos, watchos, watchos, watchOS) -PLATFORM(BRIDGEOS, 5, bridgeos, bridgeos, bridgeos, bridgeOS) -PLATFORM(MACCATALYST, 6, macCatalyst, ios-macabi, maccatalyst, macCatalyst) -PLATFORM(IOSSIMULATOR, 7, iossimulator, ios-simulator, ios-simulator, iOS Simulator) -PLATFORM(TVOSSIMULATOR, 8, tvossimulator, tvos-simulator, tvos-simulator, tvOS Simulator) -PLATFORM(WATCHOSSIMULATOR, 9, watchossimulator, watchos-simulator, watchos-simulator, watchOS Simulator) -PLATFORM(DRIVERKIT, 10, driverkit, driverkit, driverkit, DriverKit) +// PLATFORM(platform, id, name, build_name, target, tapi_target, marketing) +PLATFORM(UNKNOWN, 0, unknown, unknown, unknown, unknown, unknown) +PLATFORM(MACOS, 1, macos, macos, macos, macos, macOS) +PLATFORM(IOS, 2, ios, ios, ios, ios, iOS) +PLATFORM(TVOS, 3, tvos, tvos, tvos, tvos, tvOS) +PLATFORM(WATCHOS, 4, watchos, watchos, watchos, watchos, watchOS) +PLATFORM(BRIDGEOS, 5, bridgeos, bridgeos, bridgeos, bridgeos, bridgeOS) +PLATFORM(MACCATALYST, 6, macCatalyst, macCatalyst, ios-macabi, maccatalyst, macCatalyst) +PLATFORM(IOSSIMULATOR, 7, iossimulator, iossimulator, ios-simulator, ios-simulator, iOS Simulator) +PLATFORM(TVOSSIMULATOR, 8, tvossimulator, tvossimulator, tvos-simulator, tvos-simulator, tvOS Simulator) +PLATFORM(WATCHOSSIMULATOR, 9, watchossimulator, watchossimulator, watchos-simulator, watchos-simulator, watchOS Simulator) +PLATFORM(DRIVERKIT, 10, driverkit, driverkit, driverkit, driverkit, DriverKit) #endif #undef HANDLE_LOAD_COMMAND diff --git a/llvm/include/llvm/BinaryFormat/MachO.h b/llvm/include/llvm/BinaryFormat/MachO.h index 6dfc115c7e905fc..49991ebe7bfaf27 100644 --- a/llvm/include/llvm/BinaryFormat/MachO.h +++ b/llvm/include/llvm/BinaryFormat/MachO.h @@ -497,7 +497,8 @@ enum { VM_PROT_READ = 0x1, VM_PROT_WRITE = 0x2, VM_PROT_EXECUTE = 0x4 }; // Values for platform field in build_version_command. enum PlatformType { -#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ +#define PLATFORM(platform, id, name, build_name, target, tapi_target, \ + marketing) \ PLATFORM_##platform = id, #include "MachO.def" }; diff --git a/llvm/include/llvm/Object/MachO.h b/llvm/include/llvm/Object/MachO.h index 7bb2be76ff5b865..f91f21d837ce7b1 100644 --- a/llvm/include/llvm/Object/MachO.h +++ b/llvm/include/llvm/Object/MachO.h @@ -789,7 +789,8 @@ class MachOObjectFile : public ObjectFile { static std::string getBuildPlatform(uint32_t platform) { switch (platform) { -#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ +#define PLATFORM(platform, id, name, build_name, target, tapi_target, \ + marketing) \ case MachO::PLATFORM_##platform: \ return #name; #include "llvm/BinaryFormat/MachO.def" diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 01fc90513daca39..fb809f4010f77bd 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -629,9 +629,10 @@ void MCAsmStreamer::emitVersionMin(MCVersionMinType Type, unsigned Major, static const char *getPlatformName(MachO::PlatformType Type) { switch (Type) { -#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ +#define PLATFORM(platform, id, name, build_name, target, tapi_target, \ + marketing) \ case MachO::PLATFORM_##platform: \ - return #name; + return #build_name; #include "llvm/BinaryFormat/MachO.def" } llvm_unreachable("Invalid Mach-O platform type"); diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp index 4a8fc7388ec88b9..edea5a56bec3d3f 100644 --- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp @@ -1167,8 +1167,9 @@ bool DarwinAsmParser::parseBuildVersion(StringRef Directive, SMLoc Loc) { return TokError("platform name expected"); unsigned Platform = StringSwitch<unsigned>(PlatformName) -#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ - .Case(#name, MachO::PLATFORM_##platform) +#define PLATFORM(platform, id, name, build_name, target, tapi_target, \ + marketing) \ + .Case(#build_name, MachO::PLATFORM_##platform) #include "llvm/BinaryFormat/MachO.def" .Default(MachO::PLATFORM_UNKNOWN); diff --git a/llvm/lib/TextAPI/Platform.cpp b/llvm/lib/TextAPI/Platform.cpp index 963acd2fe9f381c..9d08469a41a89b7 100644 --- a/llvm/lib/TextAPI/Platform.cpp +++ b/llvm/lib/TextAPI/Platform.cpp @@ -62,7 +62,8 @@ PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets) { StringRef getPlatformName(PlatformType Platform) { switch (Platform) { -#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ +#define PLATFORM(platform, id, name, build_name, target, tapi_target, \ + marketing) \ case PLATFORM_##platform: \ return #marketing; #include "llvm/BinaryFormat/MachO.def" @@ -73,7 +74,8 @@ StringRef getPlatformName(PlatformType Platform) { PlatformType getPlatformFromName(StringRef Name) { return StringSwitch<PlatformType>(Name) .Case("osx", PLATFORM_MACOS) -#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ +#define PLATFORM(platform, id, name, build_name, target, tapi_target, \ + marketing) \ .Case(#tapi_target, PLATFORM_##platform) #include "llvm/BinaryFormat/MachO.def" .Default(PLATFORM_UNKNOWN); diff --git a/llvm/lib/TextAPI/Target.cpp b/llvm/lib/TextAPI/Target.cpp index 4ac442ea99d3cd1..7f4551973507410 100644 --- a/llvm/lib/TextAPI/Target.cpp +++ b/llvm/lib/TextAPI/Target.cpp @@ -21,7 +21,8 @@ Expected<Target> Target::create(StringRef TargetValue) { auto PlatformStr = Result.second; PlatformType Platform; Platform = StringSwitch<PlatformType>(PlatformStr) -#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ +#define PLATFORM(platform, id, name, build_name, target, tapi_target, \ + marketing) \ .Case(#tapi_target, PLATFORM_##platform) #include "llvm/BinaryFormat/MachO.def" .Default(PLATFORM_UNKNOWN); diff --git a/llvm/lib/TextAPI/TextStub.cpp b/llvm/lib/TextAPI/TextStub.cpp index 2eb67b8fb56078b..cbb185fd51c5dc0 100644 --- a/llvm/lib/TextAPI/TextStub.cpp +++ b/llvm/lib/TextAPI/TextStub.cpp @@ -367,7 +367,8 @@ template <> struct ScalarTraits<Target> { static void output(const Target &Value, void *, raw_ostream &OS) { OS << Value.Arch << "-"; switch (Value.Platform) { -#define PLATFORM(platform, id, name, target, tapi_target, marketing) \ +#define PLATFORM(platform, id, name, build_name, target, tapi_target, \ + marketing) \ case PLATFORM_##platform: \ OS << #tapi_target; \ break; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits