[llvm] [libsycl] add sycl::exception ctors with context (PR #220551)
Kseniya Tikhomirova via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 07:50:21 PDT 2026
================
@@ -75,19 +77,61 @@ _LIBSYCL_EXPORT const std::error_category &sycl_category() noexcept;
/// default exception handler. Virtual inheritance is mandated by SYCL 2020.
class _LIBSYCL_EXPORT exception : public virtual std::exception {
public:
- exception(std::error_code, const char *);
- exception(std::error_code Ec, const std::string &Msg)
- : exception(Ec, Msg.c_str()) {}
+ /// Constructs a SYCL exception without an associated context.
+ ///
+ /// \param EC Error code identifying the SYCL error.
+ /// \param Msg Message describing the error condition.
+ exception(std::error_code EC, const char *Msg)
+ : exception(EC, nullptr, Msg) {}
+ /// \overload
+ exception(std::error_code EC, const std::string &Msg)
+ : exception(EC, Msg.c_str()) {}
+
+ /// \overload
exception(std::error_code EC) : exception(EC, "") {}
+
+ /// \overload
exception(int EV, const std::error_category &ECat, const std::string &WhatArg)
: exception(EV, ECat, WhatArg.c_str()) {}
+
+ /// \overload
exception(int EV, const std::error_category &ECat, const char *WhatArg)
: exception({EV, ECat}, WhatArg) {}
+
+ /// \overload
exception(int EV, const std::error_category &ECat)
: exception({EV, ECat}, "") {}
- virtual ~exception();
+ // To avoid cross-dependency issues between sycl::context and sycl::exception,
+ // definition of ctors that require a context parameter are moved to
+ // context.hpp.
+
+ /// Constructs a SYCL exception with an associated SYCL context.
+ ///
+ /// \param ctx SYCL context associated with the exception.
+ /// \param ec Error code identifying the SYCL error.
+ /// \param what_arg Message describing the error condition.
+ exception(context ctx, std::error_code ec, const std::string &what_arg);
+
+ /// \overload
+ exception(context ctx, std::error_code ec, const char *what_arg);
+
+ /// \overload
+ exception(context ctx, std::error_code ec);
+
+ /// \overload
+ exception(context ctx, int ev, const std::error_category &ecat,
+ const std::string &what_arg);
+
+ /// \overload
+ exception(context ctx, int ev, const std::error_category &ecat,
+ const char *what_arg);
----------------
KseniyaTikhomirova wrote:
thanks for pointing to this. I did an alignment.
For SYCL API we follow specification naming which are not in CamelCase. I think I must have done a lot of similar style issues in other classes. I will follow up this separately.
https://github.com/llvm/llvm-project/pull/220551
More information about the llvm-commits
mailing list