@@ -109,29 +109,31 @@ static Optional<PlatformInfo> getPlatformInfo(const InputFile *input) {
109
109
110
110
using Header = typename LP::mach_header;
111
111
auto *hdr = reinterpret_cast <const Header *>(input->mb .getBufferStart ());
112
+
112
113
PlatformInfo platformInfo;
113
114
if (const auto *cmd =
114
115
findCommand<build_version_command>(hdr, LC_BUILD_VERSION)) {
115
116
platformInfo.target .Platform = static_cast <PlatformKind>(cmd->platform );
116
117
platformInfo.minimum = decodeVersion (cmd->minos );
117
118
return platformInfo;
118
- } else if (const auto *cmd =
119
- findCommand<version_min_command>(hdr, LC_VERSION_MIN_MACOSX)) {
120
- platformInfo.target .Platform = PlatformKind::macOS;
121
- platformInfo.minimum = decodeVersion (cmd->version );
122
- return platformInfo;
123
- } else if (const auto *cmd = findCommand<version_min_command>(
124
- hdr, LC_VERSION_MIN_IPHONEOS)) {
125
- platformInfo.target .Platform = PlatformKind::iOS;
126
- platformInfo.minimum = decodeVersion (cmd->version );
127
- return platformInfo;
128
- } else if (const auto *cmd =
129
- findCommand<version_min_command>(hdr, LC_VERSION_MIN_TVOS)) {
130
- platformInfo.target .Platform = PlatformKind::tvOS;
131
- platformInfo.minimum = decodeVersion (cmd->version );
132
- } else if (const auto *cmd = findCommand<version_min_command>(
133
- hdr, LC_VERSION_MIN_WATCHOS)) {
134
- platformInfo.target .Platform = PlatformKind::watchOS;
119
+ }
120
+ if (const auto *cmd = findCommand<version_min_command>(
121
+ hdr, LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS,
122
+ LC_VERSION_MIN_TVOS, LC_VERSION_MIN_WATCHOS)) {
123
+ switch (cmd->cmd ) {
124
+ case LC_VERSION_MIN_MACOSX:
125
+ platformInfo.target .Platform = PlatformKind::macOS;
126
+ break ;
127
+ case LC_VERSION_MIN_IPHONEOS:
128
+ platformInfo.target .Platform = PlatformKind::iOS;
129
+ break ;
130
+ case LC_VERSION_MIN_TVOS:
131
+ platformInfo.target .Platform = PlatformKind::tvOS;
132
+ break ;
133
+ case LC_VERSION_MIN_WATCHOS:
134
+ platformInfo.target .Platform = PlatformKind::watchOS;
135
+ break ;
136
+ }
135
137
platformInfo.minimum = decodeVersion (cmd->version );
136
138
return platformInfo;
137
139
}
0 commit comments