@@ -274,32 +274,26 @@ Expected<std::unique_ptr<StaticLibraryDefinitionGenerator>>
274
274
StaticLibraryDefinitionGenerator::Load (
275
275
ObjectLayer &L, const char *FileName,
276
276
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) {
289
277
290
278
auto B = object::createBinary (FileName);
291
279
if (!B)
292
280
return createFileError (FileName, B.takeError ());
293
281
294
282
// 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 ())),
297
288
std::move (GetObjFileInterface));
289
+ }
298
290
299
291
// If this is a universal binary then search for a slice matching the given
300
292
// Triple.
301
293
if (auto *UB = cast<object::MachOUniversalBinary>(B->getBinary ())) {
302
294
295
+ const auto &TT = L.getExecutionSession ().getTargetTriple ();
296
+
303
297
auto SliceRange = getSliceRangeForArch (*UB, TT);
304
298
if (!SliceRange)
305
299
return SliceRange.takeError ();
@@ -346,30 +340,23 @@ StaticLibraryDefinitionGenerator::Create(
346
340
ObjectLayer &L, std::unique_ptr<MemoryBuffer> ArchiveBuffer,
347
341
GetObjectFileInterface GetObjFileInterface) {
348
342
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
-
362
343
auto B = object::createBinary (ArchiveBuffer->getMemBufferRef ());
363
344
if (!B)
364
345
return B.takeError ();
365
346
366
347
// If this is a regular archive then create an instance from it.
367
348
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));
369
353
370
354
// If this is a universal binary then search for a slice matching the given
371
355
// Triple.
372
356
if (auto *UB = cast<object::MachOUniversalBinary>(B->get ())) {
357
+
358
+ const auto &TT = L.getExecutionSession ().getTargetTriple ();
359
+
373
360
auto SliceRange = getSliceRangeForArch (*UB, TT);
374
361
if (!SliceRange)
375
362
return SliceRange.takeError ();
0 commit comments