@@ -167,17 +167,17 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
167
167
ModuleFilenamePair fileNames (moduleName);
168
168
169
169
StringRef archName = Ctx.LangOpts .Target .getArchName ();
170
- ModuleFilenamePair archFileNames (archName);
170
+
171
+ SmallVector<ModuleFilenamePair, 4 > targetFileNamePairs;
172
+ targetFileNamePairs.push_back (archName);
171
173
172
174
// FIXME: We used to use "major architecture" names for these files---the
173
175
// names checked in "#if arch(...)". Fall back to that name in the one case
174
176
// where it's different from what Swift 4.2 supported: 32-bit ARM platforms.
175
177
// We should be able to drop this once there's an Xcode that supports the
176
178
// new names.
177
- StringRef alternateArchName;
178
179
if (Ctx.LangOpts .Target .getArch () == llvm::Triple::ArchType::arm)
179
- alternateArchName = " arm" ;
180
- ModuleFilenamePair alternateArchFileNames (alternateArchName);
180
+ targetFileNamePairs.push_back (StringRef (" arm" ));
181
181
182
182
auto &fs = *Ctx.SourceMgr .getFileSystem ();
183
183
isFramework = false ;
@@ -188,30 +188,25 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
188
188
// / was diagnosed, or None if neither one happened and the search should
189
189
// / continue.
190
190
auto findTargetSpecificModuleFiles = [&]() -> Optional<bool > {
191
- auto result = findModuleFilesInDirectory (moduleID, currPath,
192
- archFileNames.module ,
193
- archFileNames.moduleDoc ,
194
- moduleBuffer, moduleDocBuffer);
195
-
196
- if (result == std::errc::no_such_file_or_directory &&
197
- !alternateArchName.empty ()) {
198
- result = findModuleFilesInDirectory (moduleID, currPath,
199
- alternateArchFileNames.module ,
200
- alternateArchFileNames.moduleDoc ,
201
- moduleBuffer, moduleDocBuffer);
202
- }
203
-
204
- if (result == std::errc::no_such_file_or_directory) {
205
- if (maybeDiagnoseArchitectureMismatch (moduleID.second , moduleName,
206
- archName, currPath)) {
207
- return false ;
191
+ for (const auto &targetFileNames : targetFileNamePairs) {
192
+ auto result = findModuleFilesInDirectory (moduleID, currPath,
193
+ targetFileNames.module , targetFileNames.moduleDoc ,
194
+ moduleBuffer, moduleDocBuffer);
195
+ if (!result) {
196
+ return true ;
197
+ } else if (result != std::errc::no_such_file_or_directory) {
198
+ return None;
208
199
}
209
200
}
210
201
211
- if (!result)
212
- return true ;
213
- else
202
+ // We can only get here if all targetFileNamePairs failed with
203
+ // 'std::errc::no_such_file_or_directory'.
204
+ if (maybeDiagnoseArchitectureMismatch (moduleID.second ,
205
+ moduleName, archName, currPath)) {
206
+ return false ;
207
+ } else {
214
208
return None;
209
+ }
215
210
};
216
211
217
212
for (auto path : Ctx.SearchPathOpts .ImportSearchPaths ) {
0 commit comments