[llvm] [Offload] Add Error Codes to PluginInterface (PR #138258)
Ross Brunton via llvm-commits
llvm-commits at lists.llvm.org
Mon May 5 05:40:12 PDT 2025
================
@@ -0,0 +1,37 @@
+//===- Auto-generated file, part of the LLVM/Offload project --------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef OFFLOAD_ERRC
+#error Please define the macro OFFLOAD_ERRCODE(Name, Desc, Value)
+#endif
+
+// Error codes are shared between PluginInterface and liboffload.
+// To add new error codes, add them to offload/liboffload/API/Common.td and run
+// the GenerateOffload target.
+
+OFFLOAD_ERRC(SUCCESS, "Success", 0)
+OFFLOAD_ERRC(UNKNOWN, "Unknown or internal error", 1)
----------------
RossBrunton wrote:
`std::error_code` requires a `message` function that returns a string description of the error code, so if you pull the error code out of the llvm::Error and query it directly (or just create a new one out of the blue), it will print that message. I don't know why you'd do that, but you can.
I imagine having descriptions for the error codes is also probably useful for users of the C API that just want to use the error code.
https://github.com/llvm/llvm-project/pull/138258
More information about the llvm-commits
mailing list