@@ -128,23 +128,6 @@ static void addDiagnosticInfoForArchitectureMismatch(ASTContext &ctx,
128
128
archName, foundArchs);
129
129
}
130
130
131
- static std::pair<llvm::SmallString<16 >, llvm::SmallString<16 >>
132
- getArchSpecificModuleFileNames (StringRef archName) {
133
- llvm::SmallString<16 > archFile, archDocFile;
134
-
135
- if (!archName.empty ()) {
136
- archFile += archName;
137
- archFile += ' .' ;
138
- archFile += file_types::getExtension (file_types::TY_SwiftModuleFile);
139
-
140
- archDocFile += archName;
141
- archDocFile += ' .' ;
142
- archDocFile += file_types::getExtension (file_types::TY_SwiftModuleDocFile);
143
- }
144
-
145
- return {archFile, archDocFile};
146
- }
147
-
148
131
bool
149
132
SerializedModuleLoaderBase::findModule (AccessPathElem moduleID,
150
133
std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
@@ -160,19 +143,19 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
160
143
moduleDocFilename +=
161
144
file_types::getExtension (file_types::TY_SwiftModuleDocFile);
162
145
163
- StringRef archName = Ctx.LangOpts .Target .getArchName ();
164
- auto archFileNames = getArchSpecificModuleFileNames (archName);
146
+ // FIXME: Which name should we be using here? Do we care about CPU subtypes?
147
+ // FIXME: At the very least, don't hardcode "arch".
148
+ llvm::SmallString<16 > archName{
149
+ Ctx.LangOpts .getPlatformConditionValue (PlatformConditionKind::Arch)};
150
+ llvm::SmallString<16 > archFile{archName};
151
+ llvm::SmallString<16 > archDocFile{archName};
152
+ if (!archFile.empty ()) {
153
+ archFile += ' .' ;
154
+ archFile += file_types::getExtension (file_types::TY_SwiftModuleFile);
165
155
166
- // FIXME: We used to use "major architecture" names for these files---the
167
- // names checked in "#if arch(...)". Fall back to that name in the one case
168
- // where it's different from what Swift 4.2 supported: 32-bit ARM platforms.
169
- // We should be able to drop this once there's an Xcode that supports the
170
- // new names.
171
- StringRef alternateArchName;
172
- if (Ctx.LangOpts .Target .getArch () == llvm::Triple::ArchType::arm)
173
- alternateArchName = " arm" ;
174
- auto alternateArchFileNames =
175
- getArchSpecificModuleFileNames (alternateArchName);
156
+ archDocFile += ' .' ;
157
+ archDocFile += file_types::getExtension (file_types::TY_SwiftModuleDocFile);
158
+ }
176
159
177
160
llvm::SmallString<128 > scratch;
178
161
llvm::SmallString<128 > currPath;
@@ -186,19 +169,10 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
186
169
currPath = path;
187
170
llvm::sys::path::append (currPath, moduleFilename.str ());
188
171
err = openModuleFiles (currPath,
189
- archFileNames. first , archFileNames. second ,
172
+ archFile. str (), archDocFile. str () ,
190
173
moduleBuffer, moduleDocBuffer,
191
174
scratch);
192
175
193
- if (err == std::errc::no_such_file_or_directory &&
194
- !alternateArchName.empty ()) {
195
- err = openModuleFiles (currPath,
196
- alternateArchFileNames.first ,
197
- alternateArchFileNames.second ,
198
- moduleBuffer, moduleDocBuffer,
199
- scratch);
200
- }
201
-
202
176
if (err == std::errc::no_such_file_or_directory) {
203
177
addDiagnosticInfoForArchitectureMismatch (
204
178
Ctx, moduleID.second , moduleName, archName, currPath);
@@ -223,18 +197,9 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
223
197
}
224
198
225
199
llvm::sys::path::append (currPath, " Modules" , moduleFilename.str ());
226
- auto err = openModuleFiles (currPath,
227
- archFileNames.first , archFileNames.second ,
200
+ auto err = openModuleFiles (currPath, archFile.str (), archDocFile.str (),
228
201
moduleBuffer, moduleDocBuffer, scratch);
229
202
230
- if (err == std::errc::no_such_file_or_directory &&
231
- !alternateArchName.empty ()) {
232
- err = openModuleFiles (currPath,
233
- alternateArchFileNames.first ,
234
- alternateArchFileNames.second ,
235
- moduleBuffer, moduleDocBuffer, scratch);
236
- }
237
-
238
203
if (err == std::errc::no_such_file_or_directory) {
239
204
addDiagnosticInfoForArchitectureMismatch (
240
205
Ctx, moduleID.second , moduleName, archName, currPath);
0 commit comments