Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Follow rule of three in sycl headers #16080

Open
wants to merge 4 commits into
base: sycl
Choose a base branch
from

Conversation

ayylol
Copy link
Contributor

@ayylol ayylol commented Nov 13, 2024

Addresses rule-of-three coverity hits in sycl headers

Comment on lines +45 to +46
TempAssignGuard(const TempAssignGuard<T> &) = delete;
TempAssignGuard operator=(const TempAssignGuard<T> &) = delete;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whole point of this class is to use the constructor to temporary assign a value. Since the copy assignment/copy constructor cant take an extra assignment for the temp value to assign these functions are not useful.

Comment on lines +46 to +47
pipe_base() = default;
~pipe_base() = default;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exists so derived classes can instantiate pipe_base, so just marking as default explicitly.

@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class only has a state member variable, so the default destructor should be fine.

Comment on lines 134 to 135
tls_code_loc_t(const tls_code_loc_t &TLSCodeLoc) = default;
tls_code_loc_t &operator=(const tls_code_loc_t &TLSCodeLoc) = default;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class just has the MLocalScope member variable, so default works fine here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be delete instead. One of the main jobs of tls_code_loc_t is to maintain the global state in GCodeLocTLS. If we copy object, we could end up with the copy resetting the global state before the top-level copy of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fixed in the latest commit

Comment on lines 42 to 43
image_mem_impl(const image_mem_impl&) = delete;
image_mem_impl& operator=(const image_mem_impl&) = delete;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is managed by another class image_mem, which keeps this in a shared pointer. So it probably does not make sense to be able to copy.

@ayylol ayylol marked this pull request as ready for review November 18, 2024 22:05
@ayylol ayylol requested review from a team as code owners November 18, 2024 22:05
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ayylol
Copy link
Contributor Author

ayylol commented Nov 19, 2024

@steffenlarsen deleting the tls_code_loc_t copy constructor/copy assignment was ABI breaking, so I replaced this change with a todo comment. Does this work?

@steffenlarsen
Copy link
Contributor

@steffenlarsen deleting the tls_code_loc_t copy constructor/copy assignment was ABI breaking, so I replaced this change with a todo comment. Does this work?

Alternatively, you could put the deleted ctors under the __INTEL_PREVIEW_BREAKING_CHANGES mask. That would help us make sure we remember it when we next break ABI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants