[llvm] [orc-rt] Add Error / Exception interop. (PR #172247)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 14 20:55:55 PST 2025


================
@@ -127,10 +186,22 @@ class ORC_RT_NODISCARD Error {
 };
 
 /// Create an Error from an ErrorInfoBase.
-inline Error make_error(std::unique_ptr<ErrorInfoBase> Payload) {
+inline Error make_error(std::unique_ptr<ErrorInfoBase> Payload) noexcept {
   return Error(std::move(Payload));
 }
 
+#if ORC_RT_ENABLE_EXCEPTIONS
+
+template <typename ThisT, typename ParentT>
+Error ErrorExtends<ThisT, ParentT>::restoreError() noexcept {
+  return make_error(
+      std::unique_ptr<ThisT>(new ThisT(*static_cast<ThisT *>(this))));
----------------
lhames wrote:

Hrm. I was thinking that we can't assume that `ThisT`'s constructor is available to `make_unique`, it's as unlikely (or more so) that it'd be available to ErrorExtends, so using make_unique seems reasonable.

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


More information about the llvm-commits mailing list