From 36c93037980c06a388dd229e2e7bfd9b801a0adf Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:57:52 +0100 Subject: [PATCH 01/17] Enable clang-tidy rule to identify rule of 5 violations. --- .clang-tidy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.clang-tidy b/.clang-tidy index 24ae6bf1a..6f595801f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -25,6 +25,8 @@ Checks: ' -clang-diagnostic-range-loop-analysis, -clang-analyzer-core.StackAddressEscape, + cppcoreguidelines-special-member-functions, + misc-*, -misc-macro-parentheses, -misc-non-private-member-variables-in-classes, From 326223c74f147fcae1618ee9c545a3a1f44b8289 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:52:49 +0100 Subject: [PATCH 02/17] Fix rule of 5 violations in C++ unit tests. --- hilti/runtime/src/tests/exception.cc | 5 +++++ hilti/runtime/src/tests/hilti.cc | 5 +++++ hilti/runtime/src/tests/intrusive-ptr.cc | 10 ++++++++++ hilti/runtime/src/tests/library.cc | 5 +++++ hilti/runtime/src/tests/logging.cc | 5 +++++ hilti/runtime/src/tests/main.cc | 5 +++++ hilti/runtime/src/tests/util.cc | 4 ++++ hilti/toolchain/tests/main.cc | 6 ++++++ spicy/runtime/src/tests/global-state.cc | 5 +++++ spicy/runtime/src/tests/main.cc | 6 ++++++ spicy/runtime/src/tests/parser.cc | 11 +++++++++++ spicy/toolchain/tests/main.cc | 6 ++++++ 12 files changed, 73 insertions(+) diff --git a/hilti/runtime/src/tests/exception.cc b/hilti/runtime/src/tests/exception.cc index 91fcbcfce..e83cf6470 100644 --- a/hilti/runtime/src/tests/exception.cc +++ b/hilti/runtime/src/tests/exception.cc @@ -30,6 +30,11 @@ class TestLocation { debug::setLocation(nullptr); } + TestLocation(const TestLocation&) = delete; + TestLocation(TestLocation&&) = delete; + TestLocation& operator=(const TestLocation&) = delete; + TestLocation& operator=(TestLocation&&) = delete; + private: std::string _location; Context* _prev = nullptr; diff --git a/hilti/runtime/src/tests/hilti.cc b/hilti/runtime/src/tests/hilti.cc index d8dc2af04..a26582b03 100644 --- a/hilti/runtime/src/tests/hilti.cc +++ b/hilti/runtime/src/tests/hilti.cc @@ -23,6 +23,11 @@ class TestCout { ~TestCout() { configuration::detail::__configuration = std::move(_prev); } + TestCout(const TestCout&) = delete; + TestCout(TestCout&&) = delete; + TestCout& operator=(const TestCout&) = delete; + TestCout& operator=(TestCout&&) = delete; + auto str() const { return _cout.str(); } private: diff --git a/hilti/runtime/src/tests/intrusive-ptr.cc b/hilti/runtime/src/tests/intrusive-ptr.cc index 2bb8b83e4..f04ae26d1 100644 --- a/hilti/runtime/src/tests/intrusive-ptr.cc +++ b/hilti/runtime/src/tests/intrusive-ptr.cc @@ -25,6 +25,11 @@ class Managed : public intrusive_ptr::ManagedObject { Managed() { ++instances; } ~Managed() { --instances; } static inline int instances = 0; + + Managed(const Managed&) = delete; + Managed(Managed&&) = default; + Managed& operator=(const Managed&) = delete; + Managed& operator=(Managed&&) = default; }; using ManagedPtr = IntrusivePtr; @@ -50,6 +55,11 @@ struct TestObject : intrusive_ptr::ManagedObject { TestObject() { ++instances; } TestObject(int _i) : i(_i) { ++instances; } + TestObject(const TestObject&) = delete; + TestObject(TestObject&&) = default; + TestObject& operator=(const TestObject&) = delete; + TestObject& operator=(TestObject&&) = default; + ~TestObject() { --instances; } int i = 0; diff --git a/hilti/runtime/src/tests/library.cc b/hilti/runtime/src/tests/library.cc index f2f5d8f71..c4b6f4a6c 100644 --- a/hilti/runtime/src/tests/library.cc +++ b/hilti/runtime/src/tests/library.cc @@ -55,6 +55,11 @@ class Env { } } + Env(const Env&) = delete; + Env(Env&&) = default; + Env& operator=(const Env&) = delete; + Env& operator=(Env&&) = default; + private: std::pair> _prev; }; diff --git a/hilti/runtime/src/tests/logging.cc b/hilti/runtime/src/tests/logging.cc index 05f009f68..433728dcb 100644 --- a/hilti/runtime/src/tests/logging.cc +++ b/hilti/runtime/src/tests/logging.cc @@ -27,6 +27,11 @@ class TestLogger { std::swap(_prev, detail::globalState()->debug_logger); } + TestLogger(const TestLogger&) = delete; + TestLogger(TestLogger&&) = default; + TestLogger& operator=(const TestLogger&) = delete; + TestLogger& operator=(TestLogger&&) = default; + ~TestLogger() { detail::globalState()->debug_logger = std::move(_prev); } auto lines() const { return _file.lines(); } diff --git a/hilti/runtime/src/tests/main.cc b/hilti/runtime/src/tests/main.cc index 85f1c0ed2..0f37409ed 100644 --- a/hilti/runtime/src/tests/main.cc +++ b/hilti/runtime/src/tests/main.cc @@ -7,6 +7,11 @@ struct RuntimeWrapper { ~RuntimeWrapper() { hilti::rt::done(); } + RuntimeWrapper() = default; + RuntimeWrapper(const RuntimeWrapper&) = delete; + RuntimeWrapper(RuntimeWrapper&&) = default; + RuntimeWrapper& operator=(const RuntimeWrapper&) = delete; + RuntimeWrapper& operator=(RuntimeWrapper&&) = default; }; int main(int argc, char** argv) { diff --git a/hilti/runtime/src/tests/util.cc b/hilti/runtime/src/tests/util.cc index 4187f0598..e682b2952 100644 --- a/hilti/runtime/src/tests/util.cc +++ b/hilti/runtime/src/tests/util.cc @@ -134,6 +134,10 @@ TEST_CASE("createTemporaryFile") { struct Cleanup { Cleanup(hilti::rt::filesystem::path& tmp) : _tmp(tmp) {} + Cleanup(const Cleanup&) = delete; + Cleanup(Cleanup&&) = default; + Cleanup& operator=(const Cleanup&) = delete; + Cleanup& operator=(Cleanup&&) = delete; ~Cleanup() { std::error_code ec; if ( hilti::rt::filesystem::exists(_tmp, ec) ) diff --git a/hilti/toolchain/tests/main.cc b/hilti/toolchain/tests/main.cc index 8ee68d326..acc232ef5 100644 --- a/hilti/toolchain/tests/main.cc +++ b/hilti/toolchain/tests/main.cc @@ -7,6 +7,12 @@ struct RuntimeWrapper { ~RuntimeWrapper() { hilti::rt::done(); } + + RuntimeWrapper() = default; + RuntimeWrapper(const RuntimeWrapper&) = delete; + RuntimeWrapper(RuntimeWrapper&&) = delete; + RuntimeWrapper& operator=(const RuntimeWrapper&) = delete; + RuntimeWrapper& operator=(RuntimeWrapper&&) = delete; }; int main(int argc, char** argv) { diff --git a/spicy/runtime/src/tests/global-state.cc b/spicy/runtime/src/tests/global-state.cc index c9429af05..7ab66fc83 100644 --- a/spicy/runtime/src/tests/global-state.cc +++ b/spicy/runtime/src/tests/global-state.cc @@ -19,6 +19,11 @@ class TestState { detail::__global_state = _prev; } + TestState(const TestState&) = delete; + TestState(TestState&&) = default; + TestState& operator=(const TestState&) = delete; + TestState& operator=(TestState&&) = default; + private: detail::GlobalState* _prev{nullptr}; }; diff --git a/spicy/runtime/src/tests/main.cc b/spicy/runtime/src/tests/main.cc index 0a629a3fa..16ff46a73 100644 --- a/spicy/runtime/src/tests/main.cc +++ b/spicy/runtime/src/tests/main.cc @@ -12,6 +12,12 @@ struct RuntimeWrapper { spicy::rt::done(); hilti::rt::done(); } + + RuntimeWrapper() = default; + RuntimeWrapper(const RuntimeWrapper&) = delete; + RuntimeWrapper(RuntimeWrapper&&) = delete; + RuntimeWrapper& operator=(const RuntimeWrapper&) = delete; + RuntimeWrapper& operator=(RuntimeWrapper&&) = delete; }; int main(int argc, char** argv) { diff --git a/spicy/runtime/src/tests/parser.cc b/spicy/runtime/src/tests/parser.cc index b464449c3..1a47a6052 100644 --- a/spicy/runtime/src/tests/parser.cc +++ b/spicy/runtime/src/tests/parser.cc @@ -119,6 +119,17 @@ struct UnitWithSinkSupport : std::enable_shared_from_this { // Not implemented. return *this; } + + // NOLINTNEXTLINE(bugprone-unhandled-self-assignment, cert-oop54-cpp) + UnitWithSinkSupport& operator=(UnitWithSinkSupport&&) noexcept { + // Not implemented. + return *this; + } + + UnitWithSinkSupport() = default; + UnitWithSinkSupport(const UnitWithSinkSupport&) = default; + UnitWithSinkSupport(UnitWithSinkSupport&&) = default; + ~UnitWithSinkSupport() = default; }; Parser UnitWithSinkSupport::__parser{}; diff --git a/spicy/toolchain/tests/main.cc b/spicy/toolchain/tests/main.cc index a108f3c24..7a60e0467 100644 --- a/spicy/toolchain/tests/main.cc +++ b/spicy/toolchain/tests/main.cc @@ -12,6 +12,12 @@ struct RuntimeWrapper { spicy::rt::done(); hilti::rt::done(); } + + RuntimeWrapper() = default; + RuntimeWrapper(const RuntimeWrapper&) = delete; + RuntimeWrapper(RuntimeWrapper&&) = delete; + RuntimeWrapper& operator=(const RuntimeWrapper&) = delete; + RuntimeWrapper& operator=(RuntimeWrapper&&) = delete; }; int main(int argc, char** argv) { From d21610403611c14da72af9aab1ea4173fdde1e07 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:53:17 +0100 Subject: [PATCH 03/17] Fix rule of 5 violations in compiler infrastructure. --- hilti/runtime/include/test/utils.h | 15 +++++++++++++++ hilti/toolchain/include/ast/operator.h | 2 ++ hilti/toolchain/include/base/visitor.h | 5 +++++ hilti/toolchain/include/compiler/context.h | 5 +++++ .../include/compiler/detail/cxx/elements.h | 2 ++ hilti/toolchain/include/compiler/optimizer.h | 6 +++++- hilti/toolchain/include/compiler/unit.h | 7 +++++++ hilti/toolchain/src/compiler/codegen/codegen.cc | 5 +++++ hilti/toolchain/src/compiler/jit.cc | 6 ++++++ hilti/toolchain/src/compiler/optimizer.cc | 6 ++++++ 10 files changed, 58 insertions(+), 1 deletion(-) diff --git a/hilti/runtime/include/test/utils.h b/hilti/runtime/include/test/utils.h index ed73c276c..e8db740d7 100644 --- a/hilti/runtime/include/test/utils.h +++ b/hilti/runtime/include/test/utils.h @@ -55,6 +55,11 @@ class TemporaryFile { hilti::rt::filesystem::remove_all(_path, ec); // Swallow any error from removal. } + TemporaryFile(const TemporaryFile&) = delete; + TemporaryFile(TemporaryFile&&) = default; + TemporaryFile& operator=(const TemporaryFile&) = delete; + TemporaryFile& operator=(TemporaryFile&&) = default; + private: hilti::rt::filesystem::path _path; }; @@ -65,6 +70,11 @@ class CaptureIO { CaptureIO(std::ostream& stream) : _old(stream.rdbuf(_buffer.rdbuf())), _stream(&stream) {} ~CaptureIO() { _stream->rdbuf(_old); } + CaptureIO(const CaptureIO&) = delete; + CaptureIO(CaptureIO&&) = default; + CaptureIO& operator=(const CaptureIO&) = delete; + CaptureIO& operator=(CaptureIO&&) = default; + auto str() const { return _buffer.str(); } private: @@ -83,6 +93,11 @@ class TestContext { ~TestContext() { context::detail::current() = _prev; } + TestContext(const TestContext&) = delete; + TestContext(TestContext&&) = default; + TestContext& operator=(const TestContext&) = delete; + TestContext& operator=(TestContext&&) = default; + private: Context* _prev = nullptr; }; diff --git a/hilti/toolchain/include/ast/operator.h b/hilti/toolchain/include/ast/operator.h index a00133840..f51acc40f 100644 --- a/hilti/toolchain/include/ast/operator.h +++ b/hilti/toolchain/include/ast/operator.h @@ -192,6 +192,8 @@ struct Operand { Operand(Operand&&) = default; Operand(const Operand&) = default; + ~Operand() = default; + Operand& operator=(Operand&&) = default; Operand& operator=(const Operand&) = default; diff --git a/hilti/toolchain/include/base/visitor.h b/hilti/toolchain/include/base/visitor.h index 119c8aedd..00351165f 100644 --- a/hilti/toolchain/include/base/visitor.h +++ b/hilti/toolchain/include/base/visitor.h @@ -260,6 +260,11 @@ class Visitor { Visitor() = default; virtual ~Visitor() = default; + Visitor(const Visitor&) = default; + Visitor(Visitor&&) noexcept = default; + Visitor& operator=(const Visitor&) = default; + Visitor& operator=(Visitor&&) noexcept = default; + virtual void preDispatch(const Erased& /* n */, int /* level */){}; /** Execute matching dispatch methods for a single node. */ diff --git a/hilti/toolchain/include/compiler/context.h b/hilti/toolchain/include/compiler/context.h index 600927326..982cae303 100644 --- a/hilti/toolchain/include/compiler/context.h +++ b/hilti/toolchain/include/compiler/context.h @@ -145,6 +145,11 @@ class Context { /** Destructor. */ ~Context(); + Context(const Context&) = default; + Context(Context&&) = default; + Context& operator=(const Context&) = default; + Context& operator=(Context&&) = default; + /** Returns the context's compiler options. */ const Options& options() const { return _options; } diff --git a/hilti/toolchain/include/compiler/detail/cxx/elements.h b/hilti/toolchain/include/compiler/detail/cxx/elements.h index d653fac2c..342fd226f 100644 --- a/hilti/toolchain/include/compiler/detail/cxx/elements.h +++ b/hilti/toolchain/include/compiler/detail/cxx/elements.h @@ -120,6 +120,8 @@ struct Local { Local(const Local&) = default; Local& operator=(Local&&) = default; Local& operator=(const Local&) = default; + ~Local() = default; + Local(cxx::ID _id = {}, cxx::Type _type = {}, std::vector _args = {}, std::optional _init = {}, Linkage _linkage = {}) : id(std::move(_id)), diff --git a/hilti/toolchain/include/compiler/optimizer.h b/hilti/toolchain/include/compiler/optimizer.h index 501ec60f9..5a777ee0f 100644 --- a/hilti/toolchain/include/compiler/optimizer.h +++ b/hilti/toolchain/include/compiler/optimizer.h @@ -14,7 +14,11 @@ namespace hilti { struct Optimizer { public: Optimizer(const std::vector>& units) : _units(units) {} - ~Optimizer() {} + Optimizer(const Optimizer&) = default; + Optimizer(Optimizer&&) = default; + Optimizer& operator=(const Optimizer&) = delete; + Optimizer& operator=(Optimizer&&) = delete; + ~Optimizer() = default; void run(); diff --git a/hilti/toolchain/include/compiler/unit.h b/hilti/toolchain/include/compiler/unit.h index 3ae02530a..3c4208c7e 100644 --- a/hilti/toolchain/include/compiler/unit.h +++ b/hilti/toolchain/include/compiler/unit.h @@ -48,6 +48,13 @@ using MetaData = detail::cxx::linker::MetaData; */ class Unit { public: + Unit() = default; + Unit(const Unit&) = default; + Unit(Unit&&) = default; + + Unit& operator=(const Unit&) = default; + Unit& operator=(Unit&&) = default; + /** Destructor. */ ~Unit(); diff --git a/hilti/toolchain/src/compiler/codegen/codegen.cc b/hilti/toolchain/src/compiler/codegen/codegen.cc index 07d9f0488..14a7d94ba 100644 --- a/hilti/toolchain/src/compiler/codegen/codegen.cc +++ b/hilti/toolchain/src/compiler/codegen/codegen.cc @@ -34,6 +34,11 @@ struct GlobalsVisitor : hilti::visitor::PreOrder { GlobalsVisitor(const GlobalsVisitor&) = delete; GlobalsVisitor(GlobalsVisitor&&) noexcept = delete; + GlobalsVisitor& operator=(const GlobalsVisitor&) = delete; + GlobalsVisitor& operator=(GlobalsVisitor&&) noexcept = delete; + + ~GlobalsVisitor() override = default; + CodeGen* cg; bool include_implementation; diff --git a/hilti/toolchain/src/compiler/jit.cc b/hilti/toolchain/src/compiler/jit.cc index 089948020..474ee2aaf 100644 --- a/hilti/toolchain/src/compiler/jit.cc +++ b/hilti/toolchain/src/compiler/jit.cc @@ -98,6 +98,12 @@ class FileGuard { } } + FileGuard() = default; + FileGuard(const FileGuard&) = delete; + FileGuard(FileGuard&&) = delete; + FileGuard& operator=(const FileGuard&) = delete; + FileGuard& operator=(FileGuard&&) = delete; + private: std::vector _paths; }; diff --git a/hilti/toolchain/src/compiler/optimizer.cc b/hilti/toolchain/src/compiler/optimizer.cc index dd90c01ac..0652d9982 100644 --- a/hilti/toolchain/src/compiler/optimizer.cc +++ b/hilti/toolchain/src/compiler/optimizer.cc @@ -91,6 +91,12 @@ class OptimizerVisitor { virtual void collect(Node&) {} virtual bool prune_uses(Node&) { return false; } virtual bool prune_decls(Node&) { return false; } + + OptimizerVisitor() = default; + OptimizerVisitor(const OptimizerVisitor&) = default; + OptimizerVisitor(OptimizerVisitor&&) = default; + OptimizerVisitor& operator=(const OptimizerVisitor&) = default; + OptimizerVisitor& operator=(OptimizerVisitor&&) = default; }; struct FunctionVisitor : OptimizerVisitor, visitor::PreOrder { From 0af525230627b8c08f75741e55978f3d19d9c298 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:50:04 +0100 Subject: [PATCH 04/17] Fix rule of 5 violations for runtime exceptions. --- hilti/runtime/include/exception.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hilti/runtime/include/exception.h b/hilti/runtime/include/exception.h index 7d3e5ec96..2b37fbfa1 100644 --- a/hilti/runtime/include/exception.h +++ b/hilti/runtime/include/exception.h @@ -99,6 +99,12 @@ inline std::ostream& operator<<(std::ostream& stream, const Exception& e) { retu name(std::string_view desc) : base(Internal(), #name, desc) {} \ name(std::string_view desc, std::string_view location) : base(Internal(), #name, desc, location) {} \ virtual ~name(); /* required to create vtable, see hilti::rt::Exception */ \ + \ + name(const name&) = default; \ + name(name&&) = default; \ + name& operator=(const name&) = default; \ + name& operator=(name&&) = default; \ + \ protected: \ using base::base; \ }; // namespace hilti::rt From ac72d53e0a2543641e206fb1a629a1e96064e1fc Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:53:28 +0100 Subject: [PATCH 05/17] Fix rule of 5 violations in `FiberContext`. --- hilti/runtime/include/fiber.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hilti/runtime/include/fiber.h b/hilti/runtime/include/fiber.h index 78fbd8cf5..5cf6fa709 100644 --- a/hilti/runtime/include/fiber.h +++ b/hilti/runtime/include/fiber.h @@ -48,6 +48,12 @@ struct FiberContext { FiberContext(); ~FiberContext(); + FiberContext(const FiberContext&) = delete; + FiberContext(FiberContext&&) = default; + + FiberContext& operator=(const FiberContext&) = delete; + FiberContext& operator=(FiberContext&&) = default; + /** (Pseudo-)fiber representing the main function. */ std::unique_ptr main; From a672b15292c5e6d4fdd4cdbe6e7a9b28702d4fbb Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:53:34 +0100 Subject: [PATCH 06/17] Fix rule of 5 violations in `StackBuffer`. --- hilti/runtime/include/fiber.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hilti/runtime/include/fiber.h b/hilti/runtime/include/fiber.h index 5cf6fa709..ee8a12dea 100644 --- a/hilti/runtime/include/fiber.h +++ b/hilti/runtime/include/fiber.h @@ -81,6 +81,11 @@ struct StackBuffer { */ StackBuffer(const ::Fiber* fiber) : _fiber(fiber) {} + StackBuffer(const StackBuffer&) = delete; + StackBuffer(StackBuffer&&) = default; + StackBuffer& operator=(const StackBuffer&) = delete; + StackBuffer& operator=(StackBuffer&&) = default; + /** Destructor. */ ~StackBuffer(); From c1466049e0cd3457552ffc97a16cd7dd56f02bb4 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:53:40 +0100 Subject: [PATCH 07/17] Fix rule of 5 violations for fiber callbacks. --- hilti/runtime/include/fiber.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hilti/runtime/include/fiber.h b/hilti/runtime/include/fiber.h index ee8a12dea..e71bcd719 100644 --- a/hilti/runtime/include/fiber.h +++ b/hilti/runtime/include/fiber.h @@ -145,12 +145,14 @@ class Callback { return hilti::rt::any_cast(f)(h); }) {} - Callback(const Callback&) = default; + Callback(const Callback&) = delete; Callback(Callback&&) = default; - Callback& operator=(const Callback&) = default; + Callback& operator=(const Callback&) = delete; Callback& operator=(Callback&&) = default; + ~Callback() = default; + hilti::rt::any operator()(resumable::Handle* h) const { return _invoke(_f, h); } private: From 0c56e17a7e65b0f783d96d570c2084b4ffab88f1 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:55:03 +0100 Subject: [PATCH 08/17] Fix rule of 5 violations for runtime ranges. --- hilti/runtime/include/iterator.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hilti/runtime/include/iterator.h b/hilti/runtime/include/iterator.h index 0dd7f6d3a..eba1e6a0b 100644 --- a/hilti/runtime/include/iterator.h +++ b/hilti/runtime/include/iterator.h @@ -18,6 +18,9 @@ class Range { Range(const Range&) = delete; Range(Range&&) = delete; + + ~Range() = default; + Range& operator=(const Range&) = delete; Range& operator=(Range&&) = delete; From 3ba907bd9b5d0fb9b64e66dac4daa6cf542daab8 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:55:58 +0100 Subject: [PATCH 09/17] Fix rule of 5 violations for `Bytes`. --- hilti/runtime/include/types/bytes.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hilti/runtime/include/types/bytes.h b/hilti/runtime/include/types/bytes.h index 82da179e9..dfc8dac74 100644 --- a/hilti/runtime/include/types/bytes.h +++ b/hilti/runtime/include/types/bytes.h @@ -188,6 +188,8 @@ class Bytes : protected std::string { Bytes(const Bytes& xs) : Base(xs) {} Bytes(Bytes&& xs) noexcept : Base(std::move(xs)) {} + ~Bytes() = default; + /** Replaces the contents of this `Bytes` with another `Bytes`. * * This function invalidates all iterators. From e8eefea7f2fbcaea7e0739b6760724c40591411f Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:56:03 +0100 Subject: [PATCH 10/17] Fix rule of 5 violations for `StrongReference`. --- hilti/runtime/include/types/reference.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hilti/runtime/include/types/reference.h b/hilti/runtime/include/types/reference.h index a70bcd165..9781925cb 100644 --- a/hilti/runtime/include/types/reference.h +++ b/hilti/runtime/include/types/reference.h @@ -392,6 +392,8 @@ class StrongReference : public std::shared_ptr { /** Move constructor. */ StrongReference(StrongReference&& other) noexcept : Base(std::move(other)) {} + ~StrongReference() = default; + /** * Returns true if the reference does not refer any value. */ From 8b82028307510bc9a9c19bfab10a45fb6cc65e98 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:56:08 +0100 Subject: [PATCH 11/17] Fix rule of 5 violations for `Chain`. --- hilti/runtime/include/types/stream.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hilti/runtime/include/types/stream.h b/hilti/runtime/include/types/stream.h index b7b062a1c..f99e27bb9 100644 --- a/hilti/runtime/include/types/stream.h +++ b/hilti/runtime/include/types/stream.h @@ -225,7 +225,8 @@ class Chain : public intrusive_ptr::ManagedObject { using UnsafeConstIterator = stream::detail::UnsafeConstIterator; using Size = stream::Size; - Chain() {} + Chain() = default; + ~Chain() = default; /** Moves a chunk and all its successors into a new chain. */ Chain(std::unique_ptr head) : _head(std::move(head)), _tail(_head->last()) { _head->setChain(this); } From 46d5edb3df37300277c63513912663f91ef96491 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:56:13 +0100 Subject: [PATCH 12/17] Fix rule of 5 violations for `Stream`'s `SafeConstIterator`. --- hilti/runtime/include/types/stream.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hilti/runtime/include/types/stream.h b/hilti/runtime/include/types/stream.h index f99e27bb9..cf0d16fc8 100644 --- a/hilti/runtime/include/types/stream.h +++ b/hilti/runtime/include/types/stream.h @@ -366,6 +366,8 @@ class SafeConstIterator { /** Constructor. */ SafeConstIterator() = default; + ~SafeConstIterator() = default; + SafeConstIterator(const SafeConstIterator&) = default; SafeConstIterator(SafeConstIterator&&) = default; From be53405ae64a5bfd76b34f1071c12bc7cd94e38f Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:56:18 +0100 Subject: [PATCH 13/17] Fix rule of 5 violations for stream `View`. --- hilti/runtime/include/types/stream.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hilti/runtime/include/types/stream.h b/hilti/runtime/include/types/stream.h index cf0d16fc8..40b546519 100644 --- a/hilti/runtime/include/types/stream.h +++ b/hilti/runtime/include/types/stream.h @@ -1020,6 +1020,8 @@ class View final { /** Constructor. */ View() = default; + ~View() = default; + View(const View&) = default; View(View&&) = default; From 6f1a76d32ab825b058b167caca6d78c03e917797 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:56:26 +0100 Subject: [PATCH 14/17] Fix rule of 5 violations for runtime regexp's `Pimpl`. --- hilti/runtime/src/types/regexp.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hilti/runtime/src/types/regexp.cc b/hilti/runtime/src/types/regexp.cc index 818bd2802..655dad91c 100644 --- a/hilti/runtime/src/types/regexp.cc +++ b/hilti/runtime/src/types/regexp.cc @@ -56,6 +56,10 @@ class regexp::MatchState::Pimpl { Pimpl(const Pimpl& other) : _acc(other._acc), _first(other._first), _re(other._re) { jrx_match_state_copy(&other._ms, &_ms); } + + Pimpl(Pimpl&&) = default; + Pimpl& operator=(const Pimpl&) = default; + Pimpl& operator=(Pimpl&&) = default; }; regexp::MatchState::MatchState(const RegExp& re) { From c059317e91115d4b8269401a8a0bc092f6dc56b2 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:56:33 +0100 Subject: [PATCH 15/17] Fix rule of 5 violations for runtime filters. --- spicy/runtime/include/filter.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spicy/runtime/include/filter.h b/spicy/runtime/include/filter.h index 6c866b6b9..0e09ddf56 100644 --- a/spicy/runtime/include/filter.h +++ b/spicy/runtime/include/filter.h @@ -32,6 +32,11 @@ struct OneFilter { hilti::rt::Resumable _resumable) : parse(std::move(_parse)), input(std::move(_input)), resumable(std::move(_resumable)) {} + ~OneFilter() = default; + + OneFilter& operator=(const OneFilter&) = delete; + OneFilter& operator=(OneFilter&&) = default; + Parse1Function parse; hilti::rt::ValueReference input; hilti::rt::Resumable resumable; From 37dc95e788b2764e40379b79321e1ce7ef0a5d7f Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:56:38 +0100 Subject: [PATCH 16/17] Fix rule of 5 violations for `ParseError`. --- spicy/runtime/include/parser.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spicy/runtime/include/parser.h b/spicy/runtime/include/parser.h index b66cd8fb6..b7242d09f 100644 --- a/spicy/runtime/include/parser.h +++ b/spicy/runtime/include/parser.h @@ -322,6 +322,11 @@ class ParseError : public hilti::rt::RecoverableFailure { ParseError(const hilti::rt::result::Error& e) : RecoverableFailure(e.description()) {} ~ParseError() override; /* required to create vtable, see hilti::rt::Exception */ + + ParseError(const ParseError&) = default; + ParseError(ParseError&&) = default; + ParseError& operator=(const ParseError&) = default; + ParseError& operator=(ParseError&&) = default; }; /** From 6762dde73639f7dc072f4c51fffe8305a03b8faa Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Fri, 15 Dec 2023 09:56:42 +0100 Subject: [PATCH 17/17] Fix rule of 5 violations for `Backtrack`. --- spicy/runtime/include/parser.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spicy/runtime/include/parser.h b/spicy/runtime/include/parser.h index b7242d09f..9e9f6baf4 100644 --- a/spicy/runtime/include/parser.h +++ b/spicy/runtime/include/parser.h @@ -338,12 +338,22 @@ class Backtrack : public ParseError { public: Backtrack() : ParseError("backtracking outside of &try scope") {} ~Backtrack() override; + + Backtrack(const Backtrack&) = default; + Backtrack(Backtrack&&) = default; + Backtrack& operator=(const Backtrack&) = default; + Backtrack& operator=(Backtrack&&) = default; }; class MissingData : public ParseError { public: MissingData(std::string_view location = "") : ParseError("missing data", location) {} ~MissingData() override; /* required to create vtable, see hilti::rt::Exception */ + + MissingData(const MissingData&) = default; + MissingData(MissingData&&) = default; + MissingData& operator=(const MissingData&) = default; + MissingData& operator=(MissingData&&) = default; }; /**