clang-tidy: add a subset of cppcoreguidelines and other style checks
[lttng-tools.git] / src / bin / lttng-sessiond / field.hpp
index 2e3a67bf42f23f39a2b4242a1817096daff92778..dc418b661bd1344049141b9dd39d825244ed0615 100644 (file)
@@ -65,7 +65,12 @@ public:
 
        bool operator==(const type& other) const noexcept;
        bool operator!=(const type& other) const noexcept;
+
        virtual ~type();
+       type(const type&) = delete;
+       type(type&&) = delete;
+       type& operator=(type&&) = delete;
+       type& operator=(const type&) = delete;
 
        /* Obtain an independent copy of `type`. */
        virtual type::cuptr copy() const = 0;
@@ -75,7 +80,7 @@ public:
        const unsigned int alignment;
 
 protected:
-       type(unsigned int alignment);
+       explicit type(unsigned int alignment);
 
 private:
        virtual bool _is_equal(const type& rhs) const noexcept = 0;
@@ -138,9 +143,9 @@ public:
                        base base,
                        roles roles = {});
 
-       virtual type::cuptr copy() const override;
+       type::cuptr copy() const override;
 
-       virtual void accept(type_visitor& visitor) const override;
+       void accept(type_visitor& visitor) const override;
 
        const enum byte_order byte_order;
        const unsigned int size;
@@ -154,7 +159,7 @@ public:
        const roles roles_;
 
 protected:
-       virtual bool _is_equal(const type& other) const noexcept override;
+       bool _is_equal(const type& other) const noexcept override;
 };
 
 class floating_point_type : public type {
@@ -164,28 +169,35 @@ public:
                        unsigned int exponent_digits,
                        unsigned int mantissa_digits);
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const enum byte_order byte_order;
        const unsigned int exponent_digits;
        const unsigned int mantissa_digits;
 
 private:
-       virtual bool _is_equal(const type& other) const noexcept override final;
+       bool _is_equal(const type& other) const noexcept final;
 };
 
 class enumeration_type : public integer_type {
+public:
+       ~enumeration_type() override = default;
+       enumeration_type(const enumeration_type&) = delete;
+       enumeration_type(enumeration_type&&) = delete;
+       enumeration_type& operator=(enumeration_type&&) = delete;
+       enumeration_type& operator=(const enumeration_type&) = delete;
+
 protected:
        enumeration_type(unsigned int alignment,
-                       enum byte_order byte_order,
-                       unsigned int size,
-                       enum signedness signedness,
-                       enum base base,
-                       integer_type::roles roles = {});
+                        enum byte_order byte_order,
+                        unsigned int size,
+                        enum signedness signedness,
+                        enum base base,
+                        integer_type::roles roles = {});
 
-       virtual void accept(type_visitor& visitor) const = 0;
+       void accept(type_visitor& visitor) const override = 0;
 };
 
 namespace details {
@@ -214,20 +226,26 @@ class enumeration_mapping {
 public:
        using range_t = enumeration_mapping_range<MappingIntegerType>;
 
-       enumeration_mapping(const enumeration_mapping<MappingIntegerType>& other) = default;
-       enumeration_mapping(const enumeration_mapping<MappingIntegerType>&& other) :
-               name{std::move(other.name)}, range{other.range}
+       enumeration_mapping(std::string in_name, MappingIntegerType value) :
+               name{ std::move(in_name) }, range{ value, value }
        {
        }
 
-       enumeration_mapping(std::string in_name, MappingIntegerType value) : name{std::move(in_name)}, range{value, value}
+       enumeration_mapping(std::string in_name, range_t in_range) :
+               name{ std::move(in_name) }, range{ in_range }
        {
        }
 
-       enumeration_mapping(std::string in_name, range_t in_range) : name{std::move(in_name)}, range{in_range}
+       enumeration_mapping(const enumeration_mapping<MappingIntegerType>& other) = default;
+       enumeration_mapping(enumeration_mapping<MappingIntegerType>&& other) noexcept :
+               name{ std::move(other.name) }, range{ other.range }
        {
        }
 
+       enumeration_mapping& operator=(enumeration_mapping&&) = delete;
+       enumeration_mapping& operator=(const enumeration_mapping&) = delete;
+       ~enumeration_mapping() = default;
+
        const std::string name;
        /*
         * Only one range per mapping is supported for the moment as
@@ -273,18 +291,18 @@ public:
        {
        }
 
-       virtual type::cuptr copy() const override
+       type::cuptr copy() const override
        {
                return lttng::make_unique<typed_enumeration_type<MappingIntegerType>>(
                                alignment, byte_order, size, base_, mappings_, roles_);
        }
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const std::shared_ptr<const mappings> mappings_;
 
 private:
-       virtual bool _is_equal(const type& base_other) const noexcept override final
+       bool _is_equal(const type& base_other) const noexcept final
        {
                const auto& other = static_cast<const typed_enumeration_type<MappingIntegerType>&>(
                                base_other);
@@ -304,7 +322,7 @@ public:
        const type::cuptr element_type;
 
 protected:
-       virtual bool _is_equal(const type& base_other) const noexcept override;
+       bool _is_equal(const type& base_other) const noexcept override;
 };
 
 class static_length_array_type : public array_type {
@@ -313,14 +331,14 @@ public:
                        type::cuptr element_type,
                        uint64_t in_length);
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const uint64_t length;
 
 private:
-       virtual bool _is_equal(const type& base_other) const noexcept override final;
+       bool _is_equal(const type& base_other) const noexcept final;
 };
 
 class dynamic_length_array_type : public array_type {
@@ -329,14 +347,14 @@ public:
                        type::cuptr element_type,
                        field_location length_field_location);
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const field_location length_field_location;
 
 private:
-       virtual bool _is_equal(const type& base_other) const noexcept override final;
+       bool _is_equal(const type& base_other) const noexcept final;
 };
 
 class static_length_blob_type : public type {
@@ -350,29 +368,29 @@ public:
 
        static_length_blob_type(unsigned int alignment, uint64_t in_length_bytes, roles roles = {});
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const uint64_t length_bytes;
        const roles roles_;
 
 private:
-       virtual bool _is_equal(const type& base_other) const noexcept override final;
+       bool _is_equal(const type& base_other) const noexcept final;
 };
 
 class dynamic_length_blob_type : public type {
 public:
        dynamic_length_blob_type(unsigned int alignment, field_location length_field_location);
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const field_location length_field_location;
 
 private:
-       virtual bool _is_equal(const type& base_other) const noexcept override final;
+       bool _is_equal(const type& base_other) const noexcept final;
 };
 
 class string_type : public type {
@@ -392,7 +410,7 @@ public:
        const encoding encoding_;
 
 protected:
-       virtual bool _is_equal(const type& base_other) const noexcept override;
+       bool _is_equal(const type& base_other) const noexcept override;
 };
 
 class static_length_string_type : public string_type {
@@ -400,14 +418,14 @@ public:
        static_length_string_type(
                        unsigned int alignment, enum encoding in_encoding, uint64_t length);
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const uint64_t length;
 
 private:
-       virtual bool _is_equal(const type& base_other) const noexcept override final;
+       bool _is_equal(const type& base_other) const noexcept final;
 };
 
 class dynamic_length_string_type : public string_type {
@@ -416,23 +434,23 @@ public:
                        enum encoding in_encoding,
                        field_location length_field_location);
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const field_location length_field_location;
 
 private:
-       virtual bool _is_equal(const type& base_other) const noexcept override final;
+       bool _is_equal(const type& base_other) const noexcept final;
 };
 
 class null_terminated_string_type : public string_type {
 public:
        null_terminated_string_type(unsigned int alignment, enum encoding in_encoding);
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 };
 
 class structure_type : public type {
@@ -441,14 +459,14 @@ public:
 
        structure_type(unsigned int alignment, fields in_fields);
 
-       virtual type::cuptr copy() const override final;
+       type::cuptr copy() const final;
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const fields fields_;
 
 private:
-       virtual bool _is_equal(const type& base_other) const noexcept override final;
+       bool _is_equal(const type& base_other) const noexcept final;
 };
 
 template <typename MappingIntegerType>
@@ -474,7 +492,7 @@ public:
        {
        }
 
-       virtual type::cuptr copy() const override final
+       type::cuptr copy() const final
        {
                choices copy_of_choices;
 
@@ -488,7 +506,7 @@ public:
                        alignment, selector_field_location, std::move(copy_of_choices));
        }
 
-       virtual void accept(type_visitor& visitor) const override final;
+       void accept(type_visitor& visitor) const final;
 
        const field_location selector_field_location;
        const choices choices_;
@@ -500,8 +518,6 @@ private:
                        return false;
                }
 
-               return true;
-
                return std::equal(a.cbegin(), a.cend(), b.cbegin(),
                                [](const choice& choice_a, const choice& choice_b) {
                                        return choice_a.first == choice_b.first &&
@@ -509,7 +525,7 @@ private:
                                });
        }
 
-       virtual bool _is_equal(const type& base_other) const noexcept override final
+       bool _is_equal(const type& base_other) const noexcept final
        {
                const auto& other = static_cast<decltype(*this)&>(base_other);
 
@@ -521,6 +537,11 @@ private:
 class field_visitor {
 public:
        virtual ~field_visitor() = default;
+       field_visitor(field_visitor&&) = delete;
+       field_visitor(const field_visitor&) = delete;
+       field_visitor& operator=(const field_visitor&) = delete;
+       field_visitor& operator=(field_visitor&&) = delete;
+
        virtual void visit(const field& field) = 0;
 
 protected:
@@ -530,6 +551,11 @@ protected:
 class type_visitor {
 public:
        virtual ~type_visitor() = default;
+       type_visitor(type_visitor&&) = delete;
+       type_visitor(const type_visitor&) = delete;
+       type_visitor& operator=(const type_visitor&) = delete;
+       type_visitor& operator=(type_visitor&&) = delete;
+
        virtual void visit(const integer_type& type) = 0;
        virtual void visit(const floating_point_type& type) = 0;
        virtual void visit(const signed_enumeration_type& type) = 0;
@@ -562,9 +588,9 @@ protected:
 namespace fmt {
 template <>
 struct formatter<lttng::sessiond::trace::field_location> : formatter<std::string> {
-       template <typename FormatCtx>
-       typename FormatCtx::iterator format(
-                       const lttng::sessiond::trace::field_location& location, FormatCtx& ctx)
+       template <typename FormatContextType>
+       typename FormatContextType::iterator format(
+                       const lttng::sessiond::trace::field_location& location, FormatContextType& ctx)
        {
                std::string location_str{"["};
 
@@ -614,10 +640,10 @@ template <typename MappingIntegerType>
 template <>
 struct formatter<typename lttng::sessiond::trace::signed_enumeration_type::mapping::range_t>
        : formatter<std::string> {
-       template <typename FormatCtx>
-       typename FormatCtx::iterator
+       template <typename FormatContextType>
+       typename FormatContextType::iterator
        format(typename lttng::sessiond::trace::signed_enumeration_type::mapping::range_t range,
-                       FormatCtx& ctx)
+                       FormatContextType& ctx)
        {
                return format_to(ctx.out(),
                                details::format_mapping_range<
@@ -630,10 +656,10 @@ struct formatter<typename lttng::sessiond::trace::signed_enumeration_type::mappi
 template <>
 struct formatter<typename lttng::sessiond::trace::unsigned_enumeration_type::mapping::range_t>
        : formatter<std::string> {
-       template <typename FormatCtx>
-       typename FormatCtx::iterator
+       template <typename FormatContextType>
+       typename FormatContextType::iterator
        format(typename lttng::sessiond::trace::unsigned_enumeration_type::mapping::range_t range,
-                       FormatCtx& ctx)
+                       FormatContextType& ctx)
        {
                return format_to(ctx.out(),
                                details::format_mapping_range<
This page took 0.035198 seconds and 4 git commands to generate.