Skip to content

[XPTI] Follow rule of three in XPTI headers #16123

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

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion xpti/include/xpti/xpti_trace_framework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ class SpinLock {
struct finally {
std::function<void()> MFunc;

finally(const finally &) = default;
finally &operator=(const finally &) = default;
~finally() {
if (xptiTraceEnabled())
MFunc();
Expand Down Expand Up @@ -663,6 +665,11 @@ class stash_tuple {
(xptiStashTuple(key, value) == xpti::result_t::XPTI_RESULT_SUCCESS);
}

// Copy and copy assignment are deleted since we dont want to stash the same
// key-value pair multiple times
stash_tuple(const stash_tuple &) = delete;
stash_tuple &operator=(const stash_tuple &) = delete;

/// @brief Destroys the stash_tuple object and unstashes the key-value pair if
/// it was stashed successfully earlier.
///
Expand Down Expand Up @@ -734,6 +741,8 @@ class uid_object_t {
MUId.instance = 0;
};

~uid_object_t() = 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.

Only has one data member to deal with (xpti::uid128_t MUId), so default destructor should be fine


/// @brief Copy constructor for creating a uid_object_t object as a copy of
/// another.
///
Expand Down Expand Up @@ -1613,6 +1622,10 @@ class tracepoint_t {
}
}
}

tracepoint_t(const tracepoint_t &) = delete;
tracepoint_t &operator=(const tracepoint_t &) = delete;
Comment on lines +1626 to +1627
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if a tracepoint_t object with m_top set to true is copied we would call xptiSetUniversalId(xpti::invalid_uid) twice on both of their destructions, so we likely do not want to be able to copy.


~tracepoint_t() {
// If tracing is not enabled, don't do anything
if (!xptiTraceEnabled())
Expand Down Expand Up @@ -1779,4 +1792,4 @@ class tracepoint_t {
///
/// @param self A pointer to the current function.
///
#define XPTI_USE_TRACE_SCOPE() xpti::framework::tracepoint_scope_t TP(true);
#define XPTI_USE_TRACE_SCOPE() xpti::framework::tracepoint_scope_t TP(true);
Loading