From 1116c3ab670d03dbe96c01041b918f1436544b35 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Tue, 20 Dec 2022 22:40:15 +0100 Subject: [PATCH] Applied modernize-pass-by-value clang-tidy fixes --- src/class_diagram/model/class_element.cc | 10 ++++++---- src/class_diagram/model/class_element.h | 4 ++-- src/class_diagram/model/template_parameter.cc | 6 ++++-- src/class_diagram/model/template_parameter.h | 2 +- src/common/model/diagram_filter.cc | 14 ++++++++------ src/common/model/diagram_filter.h | 3 ++- src/common/model/element.cc | 5 +++-- src/common/model/element.h | 2 +- src/common/model/relationship.cc | 13 +++++++------ src/common/model/relationship.h | 6 +++--- src/common/model/source_location.h | 5 +++-- src/config/option.h | 11 ++++++----- 12 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/class_diagram/model/class_element.cc b/src/class_diagram/model/class_element.cc index 16fbd416..34170f5b 100644 --- a/src/class_diagram/model/class_element.cc +++ b/src/class_diagram/model/class_element.cc @@ -18,13 +18,15 @@ #include "class_element.h" +#include + namespace clanguml::class_diagram::model { -class_element::class_element(common::model::access_t access, - const std::string &name, const std::string &type) +class_element::class_element( + common::model::access_t access, std::string name, std::string type) : access_{access} - , name_{name} - , type_{type} + , name_{std::move(name)} + , type_{std::move(type)} { } diff --git a/src/class_diagram/model/class_element.h b/src/class_diagram/model/class_element.h index 10f646fe..4b50e8ef 100644 --- a/src/class_diagram/model/class_element.h +++ b/src/class_diagram/model/class_element.h @@ -29,8 +29,8 @@ namespace clanguml::class_diagram::model { class class_element : public common::model::decorated_element, public common::model::source_location { public: - class_element(common::model::access_t scope, const std::string &name, - const std::string &type); + class_element( + common::model::access_t scope, std::string name, std::string type); common::model::access_t access() const; std::string name() const; diff --git a/src/class_diagram/model/template_parameter.cc b/src/class_diagram/model/template_parameter.cc index 7644bf42..e3f1a218 100644 --- a/src/class_diagram/model/template_parameter.cc +++ b/src/class_diagram/model/template_parameter.cc @@ -20,11 +20,13 @@ #include "common/model/enums.h" #include +#include + namespace clanguml::class_diagram::model { template_parameter::template_parameter(const std::string &type, - const std::string &name, const std::string &default_value, bool is_variadic) - : default_value_{default_value} + const std::string &name, std::string default_value, bool is_variadic) + : default_value_{std::move(default_value)} , is_variadic_{is_variadic} { set_name(name); diff --git a/src/class_diagram/model/template_parameter.h b/src/class_diagram/model/template_parameter.h index a050608e..aa8c44b2 100644 --- a/src/class_diagram/model/template_parameter.h +++ b/src/class_diagram/model/template_parameter.h @@ -34,7 +34,7 @@ namespace clanguml::class_diagram::model { class template_parameter { public: template_parameter(const std::string &type = "", - const std::string &name = "", const std::string &default_value = "", + const std::string &name = "", std::string default_value = "", bool is_variadic = false); template_parameter(const template_parameter &right) = default; diff --git a/src/common/model/diagram_filter.cc b/src/common/model/diagram_filter.cc index 39d72c67..fc0e273e 100644 --- a/src/common/model/diagram_filter.cc +++ b/src/common/model/diagram_filter.cc @@ -18,6 +18,8 @@ #include "diagram_filter.h" +#include + #include "class_diagram/model/class.h" #include "common/model/package.h" #include "include_diagram/model/diagram.h" @@ -155,7 +157,7 @@ tvl::value_t anyof_filter::match( namespace_filter::namespace_filter( filter_t type, std::vector namespaces) : filter_visitor{type} - , namespaces_{namespaces} + , namespaces_{std::move(namespaces)} { } @@ -202,7 +204,7 @@ tvl::value_t namespace_filter::match( element_filter::element_filter(filter_t type, std::vector elements) : filter_visitor{type} - , elements_{elements} + , elements_{std::move(elements)} { } @@ -218,7 +220,7 @@ tvl::value_t element_filter::match( subclass_filter::subclass_filter(filter_t type, std::vector roots) : filter_visitor{type} - , roots_{roots} + , roots_{std::move(roots)} { } @@ -268,7 +270,7 @@ tvl::value_t subclass_filter::match(const diagram &d, const element &e) const relationship_filter::relationship_filter( filter_t type, std::vector relationships) : filter_visitor{type} - , relationships_{relationships} + , relationships_{std::move(relationships)} { } @@ -281,7 +283,7 @@ tvl::value_t relationship_filter::match( access_filter::access_filter(filter_t type, std::vector access) : filter_visitor{type} - , access_{access} + , access_{std::move(access)} { } @@ -294,7 +296,7 @@ tvl::value_t access_filter::match( context_filter::context_filter(filter_t type, std::vector context) : filter_visitor{type} - , context_{context} + , context_{std::move(context)} { } diff --git a/src/common/model/diagram_filter.h b/src/common/model/diagram_filter.h index bc7b539d..8ff0213b 100644 --- a/src/common/model/diagram_filter.h +++ b/src/common/model/diagram_filter.h @@ -30,6 +30,7 @@ #include "tvl.h" #include +#include namespace clanguml::common::model { @@ -140,7 +141,7 @@ struct edge_traversal_filter : public filter_visitor { edge_traversal_filter(filter_t type, relationship_t relationship, std::vector roots, bool forward = false) : filter_visitor{type} - , roots_{roots} + , roots_{std::move(roots)} , relationship_{relationship} , forward_{forward} { diff --git a/src/common/model/element.cc b/src/common/model/element.cc index bd080129..6ad54bde 100644 --- a/src/common/model/element.cc +++ b/src/common/model/element.cc @@ -21,11 +21,12 @@ #include "util/util.h" #include +#include namespace clanguml::common::model { -element::element(const namespace_ &using_namespace) - : using_namespace_{using_namespace} +element::element(namespace_ using_namespace) + : using_namespace_{std::move(using_namespace)} { } diff --git a/src/common/model/element.h b/src/common/model/element.h index f426eb68..cf79507e 100644 --- a/src/common/model/element.h +++ b/src/common/model/element.h @@ -34,7 +34,7 @@ namespace clanguml::common::model { class element : public diagram_element { public: - element(const namespace_ &using_namespace); + element(namespace_ using_namespace); virtual ~element() = default; diff --git a/src/common/model/relationship.cc b/src/common/model/relationship.cc index 3494ecd7..2bcf0657 100644 --- a/src/common/model/relationship.cc +++ b/src/common/model/relationship.cc @@ -18,17 +18,18 @@ #include "relationship.h" +#include + namespace clanguml::common::model { relationship::relationship(relationship_t type, int64_t destination, - access_t access, const std::string &label, - const std::string &multiplicity_source, - const std::string &multiplicity_destination) + access_t access, std::string label, std::string multiplicity_source, + std::string multiplicity_destination) : type_{type} , destination_{destination} - , multiplicity_source_{multiplicity_source} - , multiplicity_destination_{multiplicity_destination} - , label_{label} + , multiplicity_source_{std::move(multiplicity_source)} + , multiplicity_destination_{std::move(multiplicity_destination)} + , label_{std::move(label)} , access_{access} { } diff --git a/src/common/model/relationship.h b/src/common/model/relationship.h index ca25bf06..f1f388c1 100644 --- a/src/common/model/relationship.h +++ b/src/common/model/relationship.h @@ -29,9 +29,9 @@ class relationship : public common::model::decorated_element, public common::model::stylable_element { public: relationship(relationship_t type, int64_t destination, - access_t access = access_t::kPublic, const std::string &label = "", - const std::string &multiplicity_source = "", - const std::string &multiplicity_destination = ""); + access_t access = access_t::kPublic, std::string label = "", + std::string multiplicity_source = "", + std::string multiplicity_destination = ""); virtual ~relationship() = default; diff --git a/src/common/model/source_location.h b/src/common/model/source_location.h index 2d11b3c6..89525c66 100644 --- a/src/common/model/source_location.h +++ b/src/common/model/source_location.h @@ -18,6 +18,7 @@ #pragma once #include +#include namespace clanguml::common::model { @@ -25,8 +26,8 @@ class source_location { public: source_location() = default; - source_location(const std::string &f, unsigned int l) - : file_{f} + source_location(std::string f, unsigned int l) + : file_{std::move(f)} , line_{l} { } diff --git a/src/config/option.h b/src/config/option.h index 34b75ce6..5927c29d 100644 --- a/src/config/option.h +++ b/src/config/option.h @@ -18,6 +18,7 @@ #pragma once #include +#include namespace clanguml { namespace config { @@ -27,17 +28,17 @@ template void append_value(T &l, const T &r) { l = r; } enum class option_inherit_mode { kOverride, kAppend }; template struct option { - option(const std::string &name_, + option(std::string name_, option_inherit_mode im = option_inherit_mode::kOverride) - : name{name_} + : name{std::move(name_)} , value{} , inheritance_mode{im} { } - option(const std::string &name_, const T &initial_value, + option(std::string name_, T initial_value, option_inherit_mode im = option_inherit_mode::kOverride) - : name{name_} - , value{initial_value} + : name{std::move(name_)} + , value{std::move(initial_value)} , has_value{true} , inheritance_mode{im} {