X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftsdl-trace-class-visitor.cpp;h=d8a01864b6245463db9901346ea79bc079bc5657;hb=28f23191dcbf047429d51950a337a57d7a3f866a;hp=3c628fb412f813974dc541c8b53dfdbc6fd44837;hpb=28ab034a2c3582d07d3423d2d746731f87d3969f;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp index 3c628fb41..d8a01864b 100644 --- a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp @@ -23,6 +23,7 @@ #include #include #include +#include namespace lst = lttng::sessiond::trace; namespace tsdl = lttng::sessiond::tsdl; @@ -138,7 +139,7 @@ public: variant_tsdl_keyword_sanitizer(tsdl::details::type_overrider& type_overrides, type_lookup_function lookup_type) : - _type_overrides{ type_overrides }, _lookup_type(lookup_type) + _type_overrides(type_overrides), _lookup_type(std::move(lookup_type)) { } @@ -152,56 +153,48 @@ private: }; using unsafe_names = std::set; - virtual void visit(const lst::field& field) override final + void visit(const lst::field& field) final { _type_overrides.type(field.get_type()).accept(*this); } - virtual void visit(const lst::integer_type& type __attribute__((unused))) override final + void visit(const lst::integer_type& type __attribute__((unused))) final { } - virtual void visit(const lst::floating_point_type& type - __attribute__((unused))) override final + void visit(const lst::floating_point_type& type __attribute__((unused))) final { } - virtual void visit(const lst::signed_enumeration_type& type - __attribute__((unused))) override final + void visit(const lst::signed_enumeration_type& type __attribute__((unused))) final { } - virtual void visit(const lst::unsigned_enumeration_type& type - __attribute__((unused))) override final + void visit(const lst::unsigned_enumeration_type& type __attribute__((unused))) final { } - virtual void visit(const lst::static_length_array_type& type - __attribute__((unused))) override final + void visit(const lst::static_length_array_type& type __attribute__((unused))) final { } - virtual void visit(const lst::dynamic_length_array_type& type - __attribute__((unused))) override final + void visit(const lst::dynamic_length_array_type& type __attribute__((unused))) final { } - virtual void visit(const lst::static_length_blob_type& type - __attribute__((unused))) override final + void visit(const lst::static_length_blob_type& type __attribute__((unused))) final { } - virtual void visit(const lst::dynamic_length_blob_type& type - __attribute__((unused))) override final + void visit(const lst::dynamic_length_blob_type& type __attribute__((unused))) final { } - virtual void visit(const lst::null_terminated_string_type& type - __attribute__((unused))) override final + void visit(const lst::null_terminated_string_type& type __attribute__((unused))) final { } - virtual void visit(const lst::structure_type& type) override final + void visit(const lst::structure_type& type) final { /* Recurse into structure attributes. */ for (const auto& field : type.fields_) { @@ -343,27 +336,23 @@ private: _type_overrides.publish(type, std::move(sanitized_variant_type)); } - virtual void visit(const lst::variant_type< - lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) - override final + void visit(const lst::variant_type< + lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) final { visit_variant(type); } - virtual void visit(const lst::variant_type< - lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) - override final + void visit(const lst::variant_type< + lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) final { visit_variant(type); } - virtual void visit(const lst::static_length_string_type& type - __attribute__((unused))) override final + void visit(const lst::static_length_string_type& type __attribute__((unused))) final { } - virtual void visit(const lst::dynamic_length_string_type& type - __attribute__((unused))) override final + void visit(const lst::dynamic_length_string_type& type __attribute__((unused))) final { } @@ -379,13 +368,13 @@ public: const tsdl::details::type_overrider& type_overrides, const nonstd::optional& in_default_clock_class_name = nonstd::nullopt) : - _indentation_level{ indentation_level }, - _trace_abi{ abi }, - _bypass_identifier_escape{ false }, - _default_clock_class_name{ in_default_clock_class_name ? - in_default_clock_class_name->c_str() : - nullptr }, - _type_overrides{ type_overrides } + _indentation_level(indentation_level), + _trace_abi(abi), + + _default_clock_class_name(in_default_clock_class_name ? + in_default_clock_class_name->c_str() : + nullptr), + _type_overrides(type_overrides) { } @@ -396,7 +385,7 @@ public: } private: - virtual void visit(const lst::field& field) override final + void visit(const lst::field& field) final { /* * Hack: keep the name of the field being visited since @@ -425,7 +414,7 @@ private: _description += ";"; } - virtual void visit(const lst::integer_type& type) override final + void visit(const lst::integer_type& type) final { _description += "integer { "; @@ -506,7 +495,7 @@ private: _description += " }"; } - virtual void visit(const lst::floating_point_type& type) override final + void visit(const lst::floating_point_type& type) final { _description += fmt::format( "floating_point {{ align = {alignment}; mant_dig = {mantissa_digits}; exp_dig = {exponent_digits};", @@ -564,17 +553,17 @@ private: _description += "}"; } - virtual void visit(const lst::signed_enumeration_type& type) override final + void visit(const lst::signed_enumeration_type& type) final { visit_enumeration(type); } - virtual void visit(const lst::unsigned_enumeration_type& type) override final + void visit(const lst::unsigned_enumeration_type& type) final { visit_enumeration(type); } - virtual void visit(const lst::static_length_array_type& type) override final + void visit(const lst::static_length_array_type& type) final { if (type.alignment != 0) { LTTNG_ASSERT(_current_field_name.size() > 0); @@ -589,7 +578,7 @@ private: _type_suffixes.emplace(fmt::format("[{}]", type.length)); } - virtual void visit(const lst::dynamic_length_array_type& type) override final + void visit(const lst::dynamic_length_array_type& type) final { if (type.alignment != 0) { /* @@ -615,7 +604,7 @@ private: *(type.length_field_location.elements_.end() - 1)))); } - virtual void visit(const lst::static_length_blob_type& type) override final + void visit(const lst::static_length_blob_type& type) final { /* This type doesn't exist in CTF 1.x, express it as a static length array of * uint8_t. */ @@ -632,7 +621,7 @@ private: visit(*array); } - virtual void visit(const lst::dynamic_length_blob_type& type) override final + void visit(const lst::dynamic_length_blob_type& type) final { /* This type doesn't exist in CTF 1.x, express it as a dynamic length array of * uint8_t. */ @@ -649,7 +638,7 @@ private: visit(*array); } - virtual void visit(const lst::null_terminated_string_type& type) override final + void visit(const lst::null_terminated_string_type& type) final { /* Defaults to UTF-8. */ if (type.encoding_ == lst::null_terminated_string_type::encoding::ASCII) { @@ -659,7 +648,7 @@ private: } } - virtual void visit(const lst::structure_type& type) override final + void visit(const lst::structure_type& type) final { _indentation_level++; _description += "struct {"; @@ -724,16 +713,14 @@ private: _description += "}"; } - virtual void visit(const lst::variant_type< - lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) - override final + void visit(const lst::variant_type< + lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) final { visit_variant(type); } - virtual void visit(const lst::variant_type< - lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) - override final + void visit(const lst::variant_type< + lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) final { visit_variant(type); } @@ -749,7 +736,7 @@ private: lst::integer_type::base::DECIMAL); } - virtual void visit(const lst::static_length_string_type& type) override final + void visit(const lst::static_length_string_type& type) final { /* * TSDL expresses static-length strings as arrays of 8-bit integer with @@ -761,7 +748,7 @@ private: visit(*char_array); } - virtual void visit(const lst::dynamic_length_string_type& type) override final + void visit(const lst::dynamic_length_string_type& type) final { /* * TSDL expresses dynamic-length strings as arrays of 8-bit integer with @@ -792,26 +779,25 @@ private: /* Description in TSDL format. */ std::string _description; - bool _bypass_identifier_escape; + bool _bypass_identifier_escape{ false }; const char *_default_clock_class_name; const tsdl::details::type_overrider& _type_overrides; }; class tsdl_trace_environment_visitor : public lst::trace_class_environment_visitor { public: - tsdl_trace_environment_visitor() : _environment{ "env {\n" } - { - } + tsdl_trace_environment_visitor() = default; - virtual void visit(const lst::environment_field& field) override + void visit(const lst::environment_field& field) override { _environment += fmt::format(" {} = {};\n", field.name, field.value); } - virtual void visit(const lst::environment_field& field) override + void visit(const lst::environment_field& field) override { - _environment += fmt::format( - " {} = \"{}\";\n", field.name, escape_tsdl_env_string_value(field.value)); + _environment += fmt::format(" {} = \"{}\";\n", + field.name, + escape_tsdl_env_string_value(field.value)); } /* Only call once. */ @@ -822,14 +808,14 @@ public: } private: - std::string _environment; + std::string _environment{ "env {\n" }; }; } /* namespace */ tsdl::trace_class_visitor::trace_class_visitor( const lst::abi& trace_abi, tsdl::append_metadata_fragment_function append_metadata_fragment) : - _trace_abi{ trace_abi }, _append_metadata_fragment(append_metadata_fragment) + _trace_abi(trace_abi), _append_metadata_fragment(std::move(append_metadata_fragment)) { }