[llvm] [Offload] Use llvm::Error throughout liboffload internals (PR #140879)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Wed May 21 05:17:18 PDT 2025


================
@@ -13,20 +13,24 @@
 //===----------------------------------------------------------------------===//
 
 #include "OffloadAPI.h"
+#include "Shared/OffloadError.h"
+#include "llvm/Support/Error.h"
 
 #include <cstring>
 
 template <typename T, typename Assign>
-ol_errc_t getInfoImpl(size_t ParamValueSize, void *ParamValue,
-                      size_t *ParamValueSizeRet, T Value, size_t ValueSize,
-                      Assign &&AssignFunc) {
+llvm::Error getInfoImpl(size_t ParamValueSize, void *ParamValue,
+                        size_t *ParamValueSizeRet, T Value, size_t ValueSize,
+                        Assign &&AssignFunc) {
   if (!ParamValue && !ParamValueSizeRet) {
-    return OL_ERRC_INVALID_NULL_POINTER;
+    return error::createOffloadError(error::ErrorCode::INVALID_NULL_POINTER,
----------------
RossBrunton wrote:

There are already three overloads of `createOffloadError`, so this would double it to six, which feels like a lot (unless we do some fancy template shenanigans. I also think that it makes sense for C++ code to only use the C++ enums.

Of course, my views are subjective as well, and I'll add it if I'm outvoted.

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


More information about the llvm-commits mailing list