@@ -274,32 +274,26 @@ Expected<std::unique_ptr<StaticLibraryDefinitionGenerator>>
274274StaticLibraryDefinitionGenerator::Load (
275275 ObjectLayer &L, const char *FileName,
276276 GetObjectFileInterface GetObjFileInterface) {
277- auto ArchiveBuffer = MemoryBuffer::getFile (FileName);
278-
279- if (!ArchiveBuffer)
280- return createFileError (FileName, ArchiveBuffer.getError ());
281-
282- return Create (L, std::move (*ArchiveBuffer), std::move (GetObjFileInterface));
283- }
284-
285- Expected<std::unique_ptr<StaticLibraryDefinitionGenerator>>
286- StaticLibraryDefinitionGenerator::Load (
287- ObjectLayer &L, const char *FileName, const Triple &TT,
288- GetObjectFileInterface GetObjFileInterface) {
289277
290278 auto B = object::createBinary (FileName);
291279 if (!B)
292280 return createFileError (FileName, B.takeError ());
293281
294282 // If this is a regular archive then create an instance from it.
295- if (isa<object::Archive>(B->getBinary ()))
296- return Create (L, std::move (B->takeBinary ().second ),
283+ if (isa<object::Archive>(B->getBinary ())) {
284+ auto [Archive, ArchiveBuffer] = B->takeBinary ();
285+ return Create (L, std::move (ArchiveBuffer),
286+ std::unique_ptr<object::Archive>(
287+ static_cast <object::Archive *>(Archive.release ())),
297288 std::move (GetObjFileInterface));
289+ }
298290
299291 // If this is a universal binary then search for a slice matching the given
300292 // Triple.
301293 if (auto *UB = cast<object::MachOUniversalBinary>(B->getBinary ())) {
302294
295+ const auto &TT = L.getExecutionSession ().getTargetTriple ();
296+
303297 auto SliceRange = getSliceRangeForArch (*UB, TT);
304298 if (!SliceRange)
305299 return SliceRange.takeError ();
@@ -346,30 +340,23 @@ StaticLibraryDefinitionGenerator::Create(
346340 ObjectLayer &L, std::unique_ptr<MemoryBuffer> ArchiveBuffer,
347341 GetObjectFileInterface GetObjFileInterface) {
348342
349- auto Archive = object::Archive::create (ArchiveBuffer->getMemBufferRef ());
350- if (!Archive)
351- return Archive.takeError ();
352-
353- return Create (L, std::move (ArchiveBuffer), std::move (*Archive),
354- std::move (GetObjFileInterface));
355- }
356-
357- Expected<std::unique_ptr<StaticLibraryDefinitionGenerator>>
358- StaticLibraryDefinitionGenerator::Create (
359- ObjectLayer &L, std::unique_ptr<MemoryBuffer> ArchiveBuffer,
360- const Triple &TT, GetObjectFileInterface GetObjFileInterface) {
361-
362343 auto B = object::createBinary (ArchiveBuffer->getMemBufferRef ());
363344 if (!B)
364345 return B.takeError ();
365346
366347 // If this is a regular archive then create an instance from it.
367348 if (isa<object::Archive>(*B))
368- return Create (L, std::move (ArchiveBuffer), std::move (GetObjFileInterface));
349+ return Create (L, std::move (ArchiveBuffer),
350+ std::unique_ptr<object::Archive>(
351+ static_cast <object::Archive *>(B->release ())),
352+ std::move (GetObjFileInterface));
369353
370354 // If this is a universal binary then search for a slice matching the given
371355 // Triple.
372356 if (auto *UB = cast<object::MachOUniversalBinary>(B->get ())) {
357+
358+ const auto &TT = L.getExecutionSession ().getTargetTriple ();
359+
373360 auto SliceRange = getSliceRangeForArch (*UB, TT);
374361 if (!SliceRange)
375362 return SliceRange.takeError ();
0 commit comments