[clang] [llvm] [Offloading] Extend OffloadBinary format to support multiple metadata entries (PR #169425)

Yury Plyakhin via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 18 09:54:06 PST 2025


================
@@ -93,8 +93,12 @@ Expected<std::unique_ptr<Binary>> object::createBinary(MemoryBufferRef Buffer,
   case file_magic::spirv_object:
     // Unrecognized object file format.
     return errorCodeToError(object_error::invalid_file_type);
-  case file_magic::offload_binary:
-    return OffloadBinary::create(Buffer);
+  case file_magic::offload_binary: {
+    auto OffloadBinaryOrErr = OffloadBinary::create(Buffer);
+    if (!OffloadBinaryOrErr)
+      return OffloadBinaryOrErr.takeError();
+    return std::unique_ptr<Binary>(std::move(OffloadBinaryOrErr.get()[0]));
+  }
----------------
YuriPlyakhin wrote:

`create` returns Expected<SmallVector<std::unique_ptr<OffloadBinary>>> now, so I need to handle error, then access the first element of array. Though I don't need to construct new unique_ptr, I guess I can just do:
`return std::move(OffloadBinaryOrErr.get()[0]);`

https://github.com/llvm/llvm-project/pull/169425


More information about the llvm-commits mailing list