mirror of
https://github.com/NixOS/nix.git
synced 2025-12-22 17:01:08 +01:00
treewide: Follow rule of five
Good to explicitly declare things to not accidentally do twice the work by preventing that kind of misuse. This is essentially just cppcoreguidelines-special-member-functions lint in clang-tidy.
This commit is contained in:
parent
8c74aadbf7
commit
54d2268d84
10 changed files with 68 additions and 14 deletions
|
|
@ -741,6 +741,11 @@ public:
|
||||||
inDebugger = true;
|
inDebugger = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebuggerGuard(DebuggerGuard &&) = delete;
|
||||||
|
DebuggerGuard(const DebuggerGuard &) = delete;
|
||||||
|
DebuggerGuard & operator=(DebuggerGuard &&) = delete;
|
||||||
|
DebuggerGuard & operator=(const DebuggerGuard &) = delete;
|
||||||
|
|
||||||
~DebuggerGuard()
|
~DebuggerGuard()
|
||||||
{
|
{
|
||||||
inDebugger = false;
|
inDebugger = false;
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,8 @@ private:
|
||||||
Bindings & operator=(const Bindings &) = delete;
|
Bindings & operator=(const Bindings &) = delete;
|
||||||
Bindings & operator=(Bindings &&) = delete;
|
Bindings & operator=(Bindings &&) = delete;
|
||||||
|
|
||||||
|
~Bindings() = default;
|
||||||
|
|
||||||
friend class BindingsBuilder;
|
friend class BindingsBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,6 @@ public:
|
||||||
Value ** elems;
|
Value ** elems;
|
||||||
ListBuilder(EvalMemory & mem, size_t size);
|
ListBuilder(EvalMemory & mem, size_t size);
|
||||||
|
|
||||||
// NOTE: Can be noexcept because we are just copying integral values and
|
|
||||||
// raw pointers.
|
|
||||||
ListBuilder(ListBuilder && x) noexcept
|
ListBuilder(ListBuilder && x) noexcept
|
||||||
: size(x.size)
|
: size(x.size)
|
||||||
, inlineElems{x.inlineElems[0], x.inlineElems[1]}
|
, inlineElems{x.inlineElems[0], x.inlineElems[1]}
|
||||||
|
|
@ -173,6 +171,11 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListBuilder(const ListBuilder &) = delete;
|
||||||
|
ListBuilder & operator=(ListBuilder &&) = delete;
|
||||||
|
ListBuilder & operator=(const ListBuilder &) = delete;
|
||||||
|
~ListBuilder() = default;
|
||||||
|
|
||||||
Value *& operator[](size_t n)
|
Value *& operator[](size_t n)
|
||||||
{
|
{
|
||||||
return elems[n];
|
return elems[n];
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,10 @@ struct FdLock
|
||||||
bool acquired = false;
|
bool acquired = false;
|
||||||
|
|
||||||
FdLock(Descriptor desc, LockType lockType, bool wait, std::string_view waitMsg);
|
FdLock(Descriptor desc, LockType lockType, bool wait, std::string_view waitMsg);
|
||||||
|
FdLock(const FdLock &) = delete;
|
||||||
|
FdLock & operator=(const FdLock &) = delete;
|
||||||
|
FdLock(FdLock &&) = delete;
|
||||||
|
FdLock & operator=(FdLock &&) = delete;
|
||||||
|
|
||||||
~FdLock()
|
~FdLock()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,8 @@ struct FdSink : BufferedSink
|
||||||
}
|
}
|
||||||
|
|
||||||
FdSink(FdSink &&) = default;
|
FdSink(FdSink &&) = default;
|
||||||
|
FdSink(const FdSink &) = delete;
|
||||||
|
FdSink & operator=(const FdSink &) = delete;
|
||||||
|
|
||||||
FdSink & operator=(FdSink && s)
|
FdSink & operator=(FdSink && s)
|
||||||
{
|
{
|
||||||
|
|
@ -200,8 +202,10 @@ struct FdSource : BufferedSource, RestartableSource
|
||||||
}
|
}
|
||||||
|
|
||||||
FdSource(FdSource &&) = default;
|
FdSource(FdSource &&) = default;
|
||||||
|
|
||||||
FdSource & operator=(FdSource && s) = default;
|
FdSource & operator=(FdSource && s) = default;
|
||||||
|
FdSource(const FdSource &) = delete;
|
||||||
|
FdSource & operator=(const FdSource & s) = delete;
|
||||||
|
~FdSource() = default;
|
||||||
|
|
||||||
bool good() override;
|
bool good() override;
|
||||||
void restart() override;
|
void restart() override;
|
||||||
|
|
@ -452,6 +456,11 @@ struct LambdaSink : Sink
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LambdaSink(LambdaSink &&) = delete;
|
||||||
|
LambdaSink(const LambdaSink &) = delete;
|
||||||
|
LambdaSink & operator=(LambdaSink &&) = delete;
|
||||||
|
LambdaSink & operator=(const LambdaSink &) = delete;
|
||||||
|
|
||||||
~LambdaSink()
|
~LambdaSink()
|
||||||
{
|
{
|
||||||
cleanupFun();
|
cleanupFun();
|
||||||
|
|
@ -628,6 +637,11 @@ struct FramedSource : Source
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FramedSource(FramedSource &&) = delete;
|
||||||
|
FramedSource(const FramedSource &) = delete;
|
||||||
|
FramedSource & operator=(FramedSource &&) = delete;
|
||||||
|
FramedSource & operator=(const FramedSource &) = delete;
|
||||||
|
|
||||||
~FramedSource()
|
~FramedSource()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
@ -685,6 +699,11 @@ struct FramedSink : nix::BufferedSink
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FramedSink(FramedSink &&) = delete;
|
||||||
|
FramedSink(const FramedSink &) = delete;
|
||||||
|
FramedSink & operator=(FramedSink &&) = delete;
|
||||||
|
FramedSink & operator=(const FramedSink &) = delete;
|
||||||
|
|
||||||
~FramedSink()
|
~FramedSink()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -69,13 +69,10 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
Lock(Lock && l)
|
Lock(Lock && l) = delete;
|
||||||
: s(l.s)
|
|
||||||
{
|
|
||||||
unreachable();
|
|
||||||
}
|
|
||||||
|
|
||||||
Lock(const Lock & l) = delete;
|
Lock(const Lock & l) = delete;
|
||||||
|
Lock & operator=(Lock && l) = delete;
|
||||||
|
Lock & operator=(const Lock & l) = delete;
|
||||||
|
|
||||||
~Lock() {}
|
~Lock() {}
|
||||||
|
|
||||||
|
|
@ -110,6 +107,8 @@ public:
|
||||||
|
|
||||||
struct WriteLock : Lock<WL>
|
struct WriteLock : Lock<WL>
|
||||||
{
|
{
|
||||||
|
using Lock<WL>::Lock;
|
||||||
|
|
||||||
T * operator->()
|
T * operator->()
|
||||||
{
|
{
|
||||||
return &WriteLock::s->data;
|
return &WriteLock::s->data;
|
||||||
|
|
@ -131,6 +130,8 @@ public:
|
||||||
|
|
||||||
struct ReadLock : Lock<RL>
|
struct ReadLock : Lock<RL>
|
||||||
{
|
{
|
||||||
|
using Lock<RL>::Lock;
|
||||||
|
|
||||||
const T * operator->()
|
const T * operator->()
|
||||||
{
|
{
|
||||||
return &ReadLock::s->data;
|
return &ReadLock::s->data;
|
||||||
|
|
|
||||||
|
|
@ -384,6 +384,11 @@ struct MaintainCount
|
||||||
counter += delta;
|
counter += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MaintainCount(MaintainCount &&) = delete;
|
||||||
|
MaintainCount(const MaintainCount &) = delete;
|
||||||
|
MaintainCount & operator=(MaintainCount &&) = delete;
|
||||||
|
MaintainCount & operator=(const MaintainCount &) = delete;
|
||||||
|
|
||||||
~MaintainCount()
|
~MaintainCount()
|
||||||
{
|
{
|
||||||
counter -= delta;
|
counter -= delta;
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,11 @@ public:
|
||||||
writer.openElement(name, attrs);
|
writer.openElement(name, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XMLOpenElement(XMLOpenElement &&) = delete;
|
||||||
|
XMLOpenElement(const XMLOpenElement &) = delete;
|
||||||
|
XMLOpenElement & operator=(XMLOpenElement &&) = delete;
|
||||||
|
XMLOpenElement & operator=(const XMLOpenElement &) = delete;
|
||||||
|
|
||||||
~XMLOpenElement()
|
~XMLOpenElement()
|
||||||
{
|
{
|
||||||
writer.closeElement();
|
writer.closeElement();
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MonitorFdHup(int fd);
|
MonitorFdHup(int fd);
|
||||||
|
MonitorFdHup(MonitorFdHup &&) = delete;
|
||||||
|
MonitorFdHup(const MonitorFdHup &) = delete;
|
||||||
|
MonitorFdHup & operator=(MonitorFdHup &&) = delete;
|
||||||
|
MonitorFdHup & operator=(const MonitorFdHup &) = delete;
|
||||||
|
|
||||||
~MonitorFdHup()
|
~MonitorFdHup()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,16 @@ struct InterruptCallbackImpl : InterruptCallback
|
||||||
{
|
{
|
||||||
InterruptCallbacks::Token token;
|
InterruptCallbacks::Token token;
|
||||||
|
|
||||||
|
InterruptCallbackImpl(InterruptCallbacks::Token token)
|
||||||
|
: token(token)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
InterruptCallbackImpl(InterruptCallbackImpl &&) = delete;
|
||||||
|
InterruptCallbackImpl(const InterruptCallbackImpl &) = delete;
|
||||||
|
InterruptCallbackImpl & operator=(InterruptCallbackImpl &&) = delete;
|
||||||
|
InterruptCallbackImpl & operator=(const InterruptCallbackImpl &) = delete;
|
||||||
|
|
||||||
~InterruptCallbackImpl() override
|
~InterruptCallbackImpl() override
|
||||||
{
|
{
|
||||||
auto interruptCallbacks(_interruptCallbacks.lock());
|
auto interruptCallbacks(_interruptCallbacks.lock());
|
||||||
|
|
@ -153,11 +163,7 @@ std::unique_ptr<InterruptCallback> createInterruptCallback(std::function<void()>
|
||||||
auto interruptCallbacks(_interruptCallbacks.lock());
|
auto interruptCallbacks(_interruptCallbacks.lock());
|
||||||
auto token = interruptCallbacks->nextToken++;
|
auto token = interruptCallbacks->nextToken++;
|
||||||
interruptCallbacks->callbacks.emplace(token, callback);
|
interruptCallbacks->callbacks.emplace(token, callback);
|
||||||
|
return std::make_unique<InterruptCallbackImpl>(token);
|
||||||
std::unique_ptr<InterruptCallbackImpl> res{new InterruptCallbackImpl{}};
|
|
||||||
res->token = token;
|
|
||||||
|
|
||||||
return std::unique_ptr<InterruptCallback>(res.release());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue