@@ -128,23 +128,6 @@ static void addDiagnosticInfoForArchitectureMismatch(ASTContext &ctx,
128128 archName, foundArchs);
129129}
130130
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-
148131bool
149132SerializedModuleLoaderBase::findModule (AccessPathElem moduleID,
150133 std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
@@ -160,19 +143,19 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
160143 moduleDocFilename +=
161144 file_types::getExtension (file_types::TY_SwiftModuleDocFile);
162145
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);
165155
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+ }
176159
177160 llvm::SmallString<128 > scratch;
178161 llvm::SmallString<128 > currPath;
@@ -186,19 +169,10 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
186169 currPath = path;
187170 llvm::sys::path::append (currPath, moduleFilename.str ());
188171 err = openModuleFiles (currPath,
189- archFileNames. first , archFileNames. second ,
172+ archFile. str (), archDocFile. str () ,
190173 moduleBuffer, moduleDocBuffer,
191174 scratch);
192175
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-
202176 if (err == std::errc::no_such_file_or_directory) {
203177 addDiagnosticInfoForArchitectureMismatch (
204178 Ctx, moduleID.second , moduleName, archName, currPath);
@@ -223,18 +197,9 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
223197 }
224198
225199 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 (),
228201 moduleBuffer, moduleDocBuffer, scratch);
229202
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-
238203 if (err == std::errc::no_such_file_or_directory) {
239204 addDiagnosticInfoForArchitectureMismatch (
240205 Ctx, moduleID.second , moduleName, archName, currPath);
0 commit comments