From c833d8ae52fdcaef6eef2b43a486b925f11eef61 Mon Sep 17 00:00:00 2001 From: David Garcia Orozco Date: Thu, 21 Nov 2024 08:14:42 -0700 Subject: [PATCH] [SYCL] Follow rule of three in sycl headers (#16080) Addresses rule-of-three coverity hits in sycl headers --- sycl/include/sycl/detail/common.hpp | 7 +++++++ sycl/include/sycl/detail/util.hpp | 2 ++ sycl/include/sycl/ext/intel/experimental/pipes.hpp | 4 ++-- sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp | 3 +++ sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index bde3d96f32356..19f4d85ab30d3 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -134,6 +134,13 @@ class __SYCL_EXPORT tls_code_loc_t { /// @brief Iniitializes TLS with CodeLoc if a TLS entry not present /// @param CodeLoc The code location information to set up the TLS slot with. tls_code_loc_t(const detail::code_location &CodeLoc); + +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + // Used to maintain global state (GCodeLocTLS), so we do not want to copy + tls_code_loc_t(const tls_code_loc_t &) = delete; + tls_code_loc_t &operator=(const tls_code_loc_t &) = delete; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES + /// If the code location is set up by this instance, reset it. ~tls_code_loc_t(); /// @brief Query the information in the TLS slot diff --git a/sycl/include/sycl/detail/util.hpp b/sycl/include/sycl/detail/util.hpp index 56d4b12df2bc9..2f8bbcc7b5588 100644 --- a/sycl/include/sycl/detail/util.hpp +++ b/sycl/include/sycl/detail/util.hpp @@ -45,6 +45,8 @@ template struct TempAssignGuard { TempAssignGuard(T &fld, T tempVal) : field(fld), restoreValue(fld) { field = tempVal; } + TempAssignGuard(const TempAssignGuard &) = delete; + TempAssignGuard operator=(const TempAssignGuard &) = delete; ~TempAssignGuard() { field = restoreValue; } }; diff --git a/sycl/include/sycl/ext/intel/experimental/pipes.hpp b/sycl/include/sycl/ext/intel/experimental/pipes.hpp index c09ad05547759..76b0acf7c8d42 100644 --- a/sycl/include/sycl/ext/intel/experimental/pipes.hpp +++ b/sycl/include/sycl/ext/intel/experimental/pipes.hpp @@ -43,8 +43,8 @@ namespace experimental { class pipe_base { protected: - pipe_base(); - ~pipe_base(); + pipe_base() = default; + ~pipe_base() = default; __SYCL_EXPORT static std::string get_pipe_name(const void *HostPipePtr); __SYCL_EXPORT static bool wait_non_blocking(const event &E); diff --git a/sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp b/sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp index fa5cf7d396871..da3e254036baa 100644 --- a/sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp +++ b/sycl/include/sycl/ext/oneapi/bindless_images_memory.hpp @@ -39,6 +39,9 @@ class image_mem_impl { const context &syclContext); __SYCL_EXPORT ~image_mem_impl(); + image_mem_impl(const image_mem_impl &) = delete; + image_mem_impl &operator=(const image_mem_impl &) = delete; + raw_handle_type get_handle() const { return handle; } const image_descriptor &get_descriptor() const { return descriptor; } sycl::device get_device() const { return syclDevice; } diff --git a/sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp b/sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp index 0bc63859bb579..4c473fb88a8f1 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp @@ -33,6 +33,7 @@ class barrier { barrier(barrier &&other) noexcept = delete; barrier &operator=(const barrier &other) = delete; barrier &operator=(barrier &&other) noexcept = delete; + ~barrier() = default; void initialize(uint32_t expected_count) { #ifdef __SYCL_DEVICE_ONLY__