mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[4/N] Fix cppcoreguidelines-special-member-functions warnings (#139027)
Follows #138796 Pull Request resolved: https://github.com/pytorch/pytorch/pull/139027 Approved by: https://github.com/ezyang
This commit is contained in:
@ -378,6 +378,9 @@ struct RegisterPRIVATEUSE1Dispatch {
|
||||
name##_DECLARE_DISPATCH_type() = default; \
|
||||
name##_DECLARE_DISPATCH_type(const name##_DECLARE_DISPATCH_type&) = delete; \
|
||||
name##_DECLARE_DISPATCH_type& operator=(const name##_DECLARE_DISPATCH_type&) = delete; \
|
||||
name##_DECLARE_DISPATCH_type(name##_DECLARE_DISPATCH_type&&) = delete; \
|
||||
name##_DECLARE_DISPATCH_type& operator=(name##_DECLARE_DISPATCH_type&&) = delete; \
|
||||
~name##_DECLARE_DISPATCH_type() = default; \
|
||||
}; \
|
||||
extern TORCH_API struct name##_DECLARE_DISPATCH_type name;
|
||||
|
||||
|
@ -230,6 +230,7 @@ struct NestedNode {
|
||||
NestedNode& operator=(const NestedNode&) = delete;
|
||||
NestedNode(NestedNode&&) noexcept = default;
|
||||
NestedNode& operator=(NestedNode&&) noexcept = default;
|
||||
~NestedNode() = default;
|
||||
inline bool is_leaf() const {
|
||||
return _is_leaf;
|
||||
}
|
||||
|
@ -24,12 +24,6 @@ C10_API void warnDeprecatedDataPtr();
|
||||
// used when throwing an exception when data_ptr is accessed.
|
||||
struct C10_API StorageExtraMeta {
|
||||
std::optional<std::string> custom_data_ptr_error_msg_ = std::nullopt;
|
||||
StorageExtraMeta() = default;
|
||||
StorageExtraMeta(const StorageExtraMeta& other) {
|
||||
if (other.custom_data_ptr_error_msg_) {
|
||||
custom_data_ptr_error_msg_ = other.custom_data_ptr_error_msg_;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// A storage represents the underlying backing data buffer for a
|
||||
|
@ -20,6 +20,7 @@ class VirtualGuardImpl final : public DeviceGuardImplInterface {
|
||||
VirtualGuardImpl& operator=(const VirtualGuardImpl&) = default;
|
||||
VirtualGuardImpl(VirtualGuardImpl&&) noexcept = default;
|
||||
VirtualGuardImpl& operator=(VirtualGuardImpl&&) noexcept = default;
|
||||
~VirtualGuardImpl() override = default;
|
||||
|
||||
DeviceType type() const override {
|
||||
return impl_->type();
|
||||
|
@ -376,6 +376,11 @@ struct ExpandableSegment {
|
||||
C10_CUDA_DRIVER_CHECK(DriverAPI::get()->cuMemAddressReserve_(
|
||||
&ptr_, segment_size_ * max_handles_, 0ULL, 0, 0ULL));
|
||||
}
|
||||
ExpandableSegment(const ExpandableSegment&) = delete;
|
||||
ExpandableSegment(ExpandableSegment&&) = delete;
|
||||
ExpandableSegment operator=(const ExpandableSegment&) = delete;
|
||||
ExpandableSegment operator=(ExpandableSegment&&) = delete;
|
||||
|
||||
// begin must be aligned to segment_size_.
|
||||
// returns the actual range mapped, which may be
|
||||
// greater than requested if size is not aligned to segment_size_.
|
||||
@ -820,6 +825,9 @@ struct PrivatePool {
|
||||
PrivatePool(const PrivatePool&) = delete;
|
||||
PrivatePool(PrivatePool&&) = delete;
|
||||
PrivatePool& operator=(const PrivatePool&) = delete;
|
||||
PrivatePool& operator=(PrivatePool&&) = delete;
|
||||
~PrivatePool() = default;
|
||||
|
||||
// Number of live graphs using this pool
|
||||
int use_count{1};
|
||||
// Number of unfreed cudaMallocs made for this pool. When use_count and
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <c10/util/Exception.h>
|
||||
#include <c10/util/Registry.h>
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@ -498,6 +497,10 @@ struct C10_CUDA_API MemPool {
|
||||
MemPool(
|
||||
CUDACachingAllocator::CUDAAllocator* allocator = nullptr,
|
||||
bool is_user_created = true);
|
||||
MemPool(const MemPool&) = delete;
|
||||
MemPool(MemPool&&) = default;
|
||||
MemPool& operator=(const MemPool&) = delete;
|
||||
MemPool& operator=(MemPool&&) = default;
|
||||
~MemPool();
|
||||
|
||||
MempoolId_t id();
|
||||
|
@ -22,6 +22,11 @@ struct C10_CUDA_API CUDAStreamCaptureModeGuard {
|
||||
: strictness_(desired) {
|
||||
C10_CUDA_CHECK(cudaThreadExchangeStreamCaptureMode(&strictness_));
|
||||
}
|
||||
CUDAStreamCaptureModeGuard(const CUDAStreamCaptureModeGuard&) = delete;
|
||||
CUDAStreamCaptureModeGuard(CUDAStreamCaptureModeGuard&&) = delete;
|
||||
CUDAStreamCaptureModeGuard& operator=(const CUDAStreamCaptureModeGuard&) =
|
||||
delete;
|
||||
CUDAStreamCaptureModeGuard& operator=(CUDAStreamCaptureModeGuard&&) = delete;
|
||||
~CUDAStreamCaptureModeGuard() {
|
||||
C10_CUDA_CHECK_WARN(cudaThreadExchangeStreamCaptureMode(&strictness_));
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ struct CUDAGuard {
|
||||
// Move is not allowed (there is no uninitialized state)
|
||||
CUDAGuard(CUDAGuard&& other) = delete;
|
||||
CUDAGuard& operator=(CUDAGuard&& other) = delete;
|
||||
~CUDAGuard() = default;
|
||||
|
||||
/// Sets the CUDA device to the given device. Errors if the given device
|
||||
/// is not a CUDA device.
|
||||
@ -93,6 +94,7 @@ struct OptionalCUDAGuard {
|
||||
|
||||
// See Note [Move assignment for RAII guards is tricky]
|
||||
OptionalCUDAGuard& operator=(OptionalCUDAGuard&& other) = delete;
|
||||
~OptionalCUDAGuard() = default;
|
||||
|
||||
/// Sets the CUDA device to the given device, initializing the guard if it
|
||||
/// is not already initialized. Errors if the given device is not a CUDA
|
||||
@ -228,6 +230,7 @@ struct OptionalCUDAStreamGuard {
|
||||
|
||||
// See Note [Move assignment for RAII guards is tricky]
|
||||
OptionalCUDAStreamGuard& operator=(OptionalCUDAStreamGuard&& other) = delete;
|
||||
~OptionalCUDAStreamGuard() = default;
|
||||
|
||||
/// Resets the currently set CUDA stream to the original stream and
|
||||
/// the currently set device to the original device. Then,
|
||||
@ -285,6 +288,7 @@ struct CUDAMultiStreamGuard {
|
||||
|
||||
// See Note [Move assignment for RAII guards is tricky]
|
||||
CUDAMultiStreamGuard& operator=(CUDAMultiStreamGuard&& other) = delete;
|
||||
~CUDAMultiStreamGuard() = default;
|
||||
|
||||
private:
|
||||
c10::impl::InlineMultiStreamGuard<impl::CUDAGuardImpl> guard_;
|
||||
|
@ -38,6 +38,7 @@ struct UsageStream {
|
||||
UsageStream(UsageStream&& us) noexcept = default;
|
||||
UsageStream& operator=(const UsageStream& other) = default;
|
||||
UsageStream& operator=(UsageStream&& other) noexcept = default;
|
||||
~UsageStream() = default;
|
||||
};
|
||||
|
||||
bool operator==(const UsageStream& lhs, const UsageStream& rhs) {
|
||||
|
@ -17,6 +17,10 @@ namespace {
|
||||
class DeleteTracker {
|
||||
public:
|
||||
explicit DeleteTracker(int& delete_count) : delete_count_(delete_count) {}
|
||||
DeleteTracker(const DeleteTracker&) = delete;
|
||||
DeleteTracker(DeleteTracker&&) = delete;
|
||||
DeleteTracker& operator=(const DeleteTracker&) = delete;
|
||||
DeleteTracker& operator=(DeleteTracker&&) = delete;
|
||||
~DeleteTracker() {
|
||||
++delete_count_;
|
||||
}
|
||||
@ -109,6 +113,10 @@ TEST(lazy_clone_storage_test, no_context) {
|
||||
struct MyDeleterContext {
|
||||
MyDeleterContext(void* bytes) : bytes(bytes) {}
|
||||
|
||||
MyDeleterContext(const MyDeleterContext&) = delete;
|
||||
MyDeleterContext(MyDeleterContext&&) = delete;
|
||||
MyDeleterContext& operator=(const MyDeleterContext&) = delete;
|
||||
MyDeleterContext& operator=(MyDeleterContext&&) = delete;
|
||||
~MyDeleterContext() {
|
||||
delete[] static_cast<std::byte*>(bytes);
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ class AbortHandlerHelper {
|
||||
public:
|
||||
AbortHandlerHelper(AbortHandlerHelper const&) = delete;
|
||||
void operator=(AbortHandlerHelper const&) = delete;
|
||||
AbortHandlerHelper(AbortHandlerHelper&&) = delete;
|
||||
void operator=(AbortHandlerHelper&&) = delete;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
@ -37,6 +37,7 @@ struct bitset final {
|
||||
// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68754.
|
||||
bitset& operator=(const bitset&) noexcept = default;
|
||||
bitset& operator=(bitset&&) noexcept = default;
|
||||
~bitset() = default;
|
||||
|
||||
constexpr void set(size_t index) noexcept {
|
||||
bitset_ |= (static_cast<long long int>(1) << index);
|
||||
|
@ -37,6 +37,9 @@ class once_flag {
|
||||
once_flag() noexcept = default;
|
||||
once_flag(const once_flag&) = delete;
|
||||
once_flag& operator=(const once_flag&) = delete;
|
||||
once_flag(once_flag&&) = delete;
|
||||
once_flag& operator=(once_flag&&) = delete;
|
||||
~once_flag() = default;
|
||||
|
||||
private:
|
||||
template <typename Flag, typename F, typename... Args>
|
||||
|
@ -40,6 +40,10 @@ struct C10_API PythonGILHooksRegisterer {
|
||||
explicit PythonGILHooksRegisterer(PythonGILHooks* factory) {
|
||||
SetPythonGILHooks(factory);
|
||||
}
|
||||
PythonGILHooksRegisterer(const PythonGILHooksRegisterer&) = delete;
|
||||
PythonGILHooksRegisterer(PythonGILHooksRegisterer&&) = delete;
|
||||
PythonGILHooksRegisterer& operator=(const PythonGILHooksRegisterer&) = delete;
|
||||
PythonGILHooksRegisterer& operator=(PythonGILHooksRegisterer&&) = delete;
|
||||
~PythonGILHooksRegisterer() {
|
||||
SetPythonGILHooks(nullptr);
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ class Registry {
|
||||
typedef std::function<ObjectPtrType(Args...)> Creator;
|
||||
|
||||
Registry(bool warning = true) : registry_(), priority_(), warning_(warning) {}
|
||||
~Registry() = default;
|
||||
|
||||
void Register(
|
||||
const SrcType& key,
|
||||
@ -152,6 +153,10 @@ class Registry {
|
||||
terminate_ = terminate;
|
||||
}
|
||||
|
||||
C10_DISABLE_COPY_AND_ASSIGN(Registry);
|
||||
Registry(Registry&&) = delete;
|
||||
Registry& operator=(Registry&&) = delete;
|
||||
|
||||
private:
|
||||
std::unordered_map<SrcType, Creator> registry_;
|
||||
std::unordered_map<SrcType, RegistryPriority> priority_;
|
||||
@ -159,8 +164,6 @@ class Registry {
|
||||
const bool warning_;
|
||||
std::unordered_map<SrcType, std::string> help_message_;
|
||||
std::mutex register_mutex_;
|
||||
|
||||
C10_DISABLE_COPY_AND_ASSIGN(Registry);
|
||||
};
|
||||
|
||||
template <class SrcType, class ObjectPtrType, class... Args>
|
||||
|
@ -35,6 +35,7 @@ class Synchronized final {
|
||||
Synchronized(Synchronized&&) = delete;
|
||||
Synchronized operator=(Synchronized const&) = delete;
|
||||
Synchronized operator=(Synchronized&&) = delete;
|
||||
~Synchronized() = default;
|
||||
|
||||
/**
|
||||
* To use, call withLock<T> with a callback that accepts T either
|
||||
|
@ -30,6 +30,11 @@ class DynamicBackendWrapper : public WaitCounterBackendIf {
|
||||
public:
|
||||
explicit DynamicBackendWrapper(WaitCounterDynamicBackend impl)
|
||||
: impl_{impl} {}
|
||||
|
||||
DynamicBackendWrapper(const DynamicBackendWrapper&) = delete;
|
||||
DynamicBackendWrapper(DynamicBackendWrapper&&) = delete;
|
||||
DynamicBackendWrapper& operator=(const DynamicBackendWrapper&) = delete;
|
||||
DynamicBackendWrapper& operator=(DynamicBackendWrapper&&) = delete;
|
||||
~DynamicBackendWrapper() override {
|
||||
impl_.destroy(impl_.self);
|
||||
}
|
||||
|
@ -107,8 +107,6 @@ FatalSignalHandler& FatalSignalHandler::getInstance() {
|
||||
return *handler;
|
||||
}
|
||||
|
||||
FatalSignalHandler::~FatalSignalHandler() = default;
|
||||
|
||||
FatalSignalHandler::FatalSignalHandler()
|
||||
: fatalSignalHandlersInstalled(false),
|
||||
fatalSignalReceived(false),
|
||||
|
@ -27,6 +27,11 @@ class C10_API SignalHandler {
|
||||
|
||||
// Constructor. Specify what action to take when a signal is received.
|
||||
SignalHandler(Action SIGINT_action, Action SIGHUP_action);
|
||||
|
||||
SignalHandler(const SignalHandler&) = delete;
|
||||
SignalHandler(SignalHandler&&) = delete;
|
||||
SignalHandler& operator=(const SignalHandler&) = delete;
|
||||
SignalHandler& operator=(SignalHandler&&) = delete;
|
||||
~SignalHandler();
|
||||
|
||||
Action CheckForSignals();
|
||||
@ -49,7 +54,11 @@ class C10_API FatalSignalHandler {
|
||||
C10_API void setPrintStackTracesOnFatalSignal(bool print);
|
||||
C10_API bool printStackTracesOnFatalSignal();
|
||||
static FatalSignalHandler& getInstance();
|
||||
virtual ~FatalSignalHandler();
|
||||
FatalSignalHandler(const FatalSignalHandler&) = delete;
|
||||
FatalSignalHandler(FatalSignalHandler&&) = delete;
|
||||
FatalSignalHandler& operator=(const FatalSignalHandler&) = delete;
|
||||
FatalSignalHandler& operator=(FatalSignalHandler&&) = delete;
|
||||
virtual ~FatalSignalHandler() = default;
|
||||
|
||||
protected:
|
||||
explicit FatalSignalHandler();
|
||||
|
@ -434,6 +434,7 @@ class SparseBitVector {
|
||||
: Elements(RHS.Elements), CurrElementIter(Elements.begin()) {}
|
||||
SparseBitVector(SparseBitVector&& RHS) noexcept
|
||||
: Elements(std::move(RHS.Elements)), CurrElementIter(Elements.begin()) {}
|
||||
~SparseBitVector() = default;
|
||||
|
||||
// Clear.
|
||||
void clear() {
|
||||
|
Reference in New Issue
Block a user