Skip to content

Commit a1862f0

Browse files
author
Tor Didriksen
committed
Bug #32433090 RUN CLANG-TIDY MODERNIZE-USE-EQUALS-DEFAULT OVER THE CODE BASE
Use run-clang-tidy.py -fix -checks='-*,modernize-use-equals-default' This check replaces default bodies of special member functions with = default; The explicitly defaulted function declarations enable more opportunities in optimization, because the compiler might treat explicitly defaulted functions as trivial. Performance changes, as measured by sysbench with default argumens, are in the noise area. A small improvement for PGO/LTO builds. With gcc10, mysqld is about 14 MB smaller with ' = default;' constructors and destructors. A few manual fixes were applied to the clang-tidy result: Fixes for -Werror=unused-parameter -cs::apply::Commit_order_queue::Iterator::Iterator(const Iterator &rhs) +cs::apply::Commit_order_queue::Iterator::Iterator(const Iterator &) -cs::apply::Commit_order_queue::Iterator::operator=(const Iterator &rhs) = default; +cs::apply::Commit_order_queue::Iterator::operator=(const Iterator &) = default; Revert some of the changes done by clang-tidy, such as error: use of deleted function SortingIterator::IteratorHolder::~IteratorHolder() router/src/harness/include/mysql/harness/stdx/expected.h:111:3: note: stdx::base::storage_t<T, E>::storage_t() [with T = const char*; E = std::error_code] is implicitly deleted because the default definition would be ill-formed: 111 | storage_t() = default; The reverted changes have been tagged with // NOLINT(modernize-use-equals-default) or // NOLINTNEXTLINE(modernize-use-equals-default) to prevent clang-tidy to try to fix them later. The DTOR Item::~Item() was rewritten manually. The body contained an ifdef, so clang-tidy would not rewrite it. Other CTORs/DTORs could also be rewritten, e.g. Rsegs() and ~Rsegs() in InnoDB. Change-Id: I0457e799464119d1f4042589f404dd4b172440e8
1 parent e2af261 commit a1862f0

File tree

657 files changed

+1260
-1306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

657 files changed

+1260
-1306
lines changed

client/base/abstract_program.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void Abstract_program::run(int argc, char **argv) {
9090
exit(result);
9191
}
9292

93-
Abstract_program::~Abstract_program() {}
93+
Abstract_program::~Abstract_program() = default;
9494

9595
void Abstract_program::init_name(char *name_from_cmd_line) {
9696
#ifdef _WIN32

client/base/i_connection_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Base {
3737
*/
3838
class I_connection_factory {
3939
public:
40-
virtual ~I_connection_factory() {}
40+
virtual ~I_connection_factory() = default;
4141

4242
/**
4343
Provides new connection to MySQL database server.

client/base/i_option.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ using namespace Mysql::Tools::Base::Options;
2828

2929
uint32 I_option::last_optid = 256;
3030

31-
I_option::~I_option() {}
31+
I_option::~I_option() = default;

client/base/i_option_changed_listener.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Options {
3939
*/
4040
class I_option_changed_listener {
4141
public:
42-
virtual ~I_option_changed_listener() {}
42+
virtual ~I_option_changed_listener() = default;
4343

4444
/**
4545
Called after specified option has name changed.

client/base/message_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum Message_type {
4848
class Message_data {
4949
public:
5050
Message_data(uint64 code, std::string message, Message_type message_type);
51-
virtual ~Message_data() {}
51+
virtual ~Message_data() = default;
5252
uint64 get_code() const;
5353
std::string get_message() const;
5454
Message_type get_message_type() const;

client/base/number_option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Number_option
5151
};
5252

5353
template <typename T_value>
54-
Number_option<T_value>::Number_option() {}
54+
Number_option<T_value>::Number_option() = default;
5555

5656
/**
5757
32-bit signed number option.

client/client_query_attributes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
class client_query_attributes {
3131
public:
32-
client_query_attributes() {}
32+
client_query_attributes() = default;
3333
~client_query_attributes() { clear(); }
3434
bool push_param(char *name, char *value);
3535
int set_params(MYSQL *mysql);

client/dump/abstract_data_object.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ std::string Abstract_data_object::get_schema() const { return m_schema; }
3636

3737
uint64 Abstract_data_object::get_id() const { return m_id; }
3838

39-
Abstract_data_object::~Abstract_data_object() {}
39+
Abstract_data_object::~Abstract_data_object() = default;

client/dump/abstract_dump_task.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using namespace Mysql::Tools::Dump;
3232
Abstract_dump_task::Abstract_dump_task(Abstract_data_object *related_object)
3333
: m_related_object(related_object) {}
3434

35-
Abstract_dump_task::~Abstract_dump_task() {}
35+
Abstract_dump_task::~Abstract_dump_task() = default;
3636

3737
I_data_object *Abstract_dump_task::get_related_db_object() const {
3838
return m_related_object;

client/dump/abstract_simple_dump_task.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void Abstract_simple_dump_task::set_completed() { m_is_completed = true; }
3030

3131
bool Abstract_simple_dump_task::is_completed() const { return m_is_completed; }
3232

33-
Abstract_simple_dump_task::~Abstract_simple_dump_task() {}
33+
Abstract_simple_dump_task::~Abstract_simple_dump_task() = default;
3434

3535
Abstract_simple_dump_task::Abstract_simple_dump_task()
3636
: m_is_completed(false) {}

client/dump/i_chain_element.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
using namespace Mysql::Tools::Dump;
2828

29-
I_chain_element::~I_chain_element() {}
29+
I_chain_element::~I_chain_element() = default;

client/dump/i_connection_provider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Dump {
3636

3737
class I_connection_provider {
3838
public:
39-
virtual ~I_connection_provider() {}
39+
virtual ~I_connection_provider() = default;
4040
virtual Mysql::Tools::Base::Mysql_query_runner *get_runner(
4141
std::function<bool(const Mysql::Tools::Base::Message_data &)>
4242
*message_handler) = 0;

client/dump/i_data_formatter_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Dump {
3636
*/
3737
class I_data_formatter_wrapper {
3838
public:
39-
virtual ~I_data_formatter_wrapper() {}
39+
virtual ~I_data_formatter_wrapper() = default;
4040
/**
4141
Add new Data Formatter to supply acquired data of objects to.
4242
*/

client/dump/i_data_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Dump {
3131

3232
class I_data_object {
3333
public:
34-
virtual ~I_data_object() {}
34+
virtual ~I_data_object() = default;
3535
};
3636

3737
} // namespace Dump

client/dump/i_dump_task.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
using namespace Mysql::Tools::Dump;
2828

29-
I_dump_task::~I_dump_task() {}
29+
I_dump_task::~I_dump_task() = default;

client/dump/i_object_reader_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Dump {
3636
*/
3737
class I_object_reader_wrapper {
3838
public:
39-
virtual ~I_object_reader_wrapper() {}
39+
virtual ~I_object_reader_wrapper() = default;
4040
/**
4141
Add new Object Reader to supply direct execution of dump tasks to.
4242
*/

client/dump/i_output_writer_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Dump {
3636
*/
3737
class I_output_writer_wrapper {
3838
public:
39-
virtual ~I_output_writer_wrapper() {}
39+
virtual ~I_output_writer_wrapper() = default;
4040
/**
4141
Add new Output Writer to supply formatted strings to.
4242
*/

client/dump/i_progress_reporter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
using namespace Mysql::Tools::Dump;
2828

29-
I_progress_reporter::~I_progress_reporter() {}
29+
I_progress_reporter::~I_progress_reporter() = default;

client/dump/pattern_matcher.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
using namespace Mysql::Tools::Dump::Detail;
2828

29-
Pattern_matcher::Pattern_matcher() {}
29+
Pattern_matcher::Pattern_matcher() = default;
3030

3131
bool Pattern_matcher::is_pattern_matched(const std::string &to_match,
3232
const std::string &pattern,

client/mysql_ssl_rsa_setup.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class RSA_priv {
226226
public:
227227
RSA_priv(uint32_t key_size = 2048) : m_key_size(key_size) {}
228228

229-
~RSA_priv() {}
229+
~RSA_priv() = default;
230230

231231
Sql_string_t operator()(const Sql_string_t &key_file) {
232232
stringstream command;
@@ -281,7 +281,7 @@ class X509v3_ext_writer {
281281

282282
m_certv3_ext_options << "basicConstraints=CA:FALSE" << std::endl;
283283
}
284-
~X509v3_ext_writer() {}
284+
~X509v3_ext_writer() = default;
285285

286286
bool operator()(const Sql_string_t &cav3_ext_file,
287287
const Sql_string_t &certv3_ext_file) {
@@ -314,7 +314,7 @@ class X509_cert {
314314
public:
315315
X509_cert(uint32_t validity = 10 * 365L) : m_validity(validity) {}
316316

317-
~X509_cert() {}
317+
~X509_cert() = default;
318318

319319
Sql_string_t operator()(const Sql_string_t &req_file,
320320
const Sql_string_t &cert_file, uint32_t serial,

client/mysqlbinlog.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ class Load_log_processor {
852852

853853
public:
854854
Load_log_processor() : file_names() {}
855-
~Load_log_processor() {}
855+
~Load_log_processor() = default;
856856

857857
void init_by_dir_name(const char *dir) {
858858
target_dir_name_len =

client/mysqltest/expected_errors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class Expected_errors {
3737
public:
3838
typedef std::vector<std::unique_ptr<Error>>::iterator iterator;
3939

40-
Expected_errors() {}
41-
~Expected_errors() {}
40+
Expected_errors() = default;
41+
~Expected_errors() = default;
4242

4343
iterator begin() { return m_errors.begin(); }
4444
iterator end() { return m_errors.end(); }

client/mysqltest/expected_warnings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class Expected_warnings {
3535
public:
3636
typedef std::vector<std::unique_ptr<Warning>>::iterator iterator;
3737

38-
Expected_warnings() {}
39-
~Expected_warnings() {}
38+
Expected_warnings() = default;
39+
~Expected_warnings() = default;
4040

4141
iterator begin() { return m_warnings.begin(); }
4242
iterator end() { return m_warnings.end(); }

client/mysqltest/secondary_engine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
class Secondary_engine {
3232
public:
33-
Secondary_engine() {}
34-
~Secondary_engine() {}
33+
Secondary_engine() = default;
34+
~Secondary_engine() = default;
3535

3636
/// Get the secondary engine execution count value.
3737
///

client/path.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <pwd.h>
3737
#endif
3838

39-
Path::Path() {}
39+
Path::Path() = default;
4040

4141
Path::Path(const std::string &s) { path(s); }
4242

components/audit_api_message_emit/audit_api_message_emit.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class IError_handler {
6868
/**
6969
Virtual destructor.
7070
*/
71-
virtual ~IError_handler() {}
71+
virtual ~IError_handler() = default;
7272
/**
7373
Error reporting method.
7474

components/keyrings/common/data/data.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ Data::Data(Data &&src) noexcept {
4747
}
4848

4949
/* Assignment operator */
50-
Data &Data::operator=(const Data &src) {
51-
data_ = src.data_;
52-
type_ = src.type_;
53-
valid_ = src.valid_;
54-
55-
return *this;
56-
}
50+
Data &Data::operator=(const Data &src) = default;
5751

5852
Data &Data::operator=(Data &&src) noexcept {
5953
std::swap(src.data_, data_);

components/keyrings/common/data/meta.cc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,7 @@ Metadata::Metadata(Metadata &&src) noexcept {
5151
}
5252

5353
/** Assignment operator */
54-
Metadata &Metadata::operator=(const Metadata &src) {
55-
key_id_ = src.key_id_;
56-
owner_id_ = src.owner_id_;
57-
hash_key_ = src.hash_key_;
58-
valid_ = src.valid_;
59-
60-
return *this;
61-
}
54+
Metadata &Metadata::operator=(const Metadata &src) = default;
6255

6356
Metadata &Metadata::operator=(Metadata &&src) noexcept {
6457
std::swap(src.key_id_, key_id_);

components/keyrings/common/data_file/writer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class File_writer final {
3434
bool backup_exists = false);
3535

3636
/* Destructor */
37-
~File_writer() {}
37+
~File_writer() = default;
3838

3939
/* Validity */
4040
bool valid() const { return valid_; }

components/keyrings/common/encryption/aes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Aes_operation_context final {
6363
public:
6464
Aes_operation_context(const std::string data_id, const std::string auth_id,
6565
const std::string mode, size_t block_size);
66-
~Aes_operation_context() {}
66+
~Aes_operation_context() = default;
6767
const std::string data_id() const { return data_id_; }
6868
const std::string auth_id() const { return auth_id_; }
6969
Keyring_aes_opmode opmode() const { return opmode_; }

components/keyrings/common/json_data/json_ds.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace json_data {
3232
/* Base class for data extensions */
3333
class Json_data_extension {
3434
public:
35-
Json_data_extension() {}
35+
Json_data_extension() = default;
3636
virtual std::string version() { return std::string{"1.0"}; }
37-
virtual ~Json_data_extension() {}
37+
virtual ~Json_data_extension() = default;
3838
};
3939

4040
} // namespace json_data

components/keyrings/common/json_data/json_reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Json_reader {
7777
Json_reader();
7878

7979
/** Destructor */
80-
virtual ~Json_reader() {}
80+
virtual ~Json_reader() = default;
8181

8282
std::string version() const;
8383

components/keyrings/common/json_data/json_writer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Json_writer {
4747
const std::string array_key = "elements");
4848

4949
/** Destructor */
50-
virtual ~Json_writer() {}
50+
virtual ~Json_writer() = default;
5151

5252
bool set_data(const std::string data);
5353

components/keyrings/common/memstore/cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Datacache final {
4949
Datacache &operator=(Datacache &&src) = delete;
5050

5151
/** Destructor */
52-
~Datacache() {}
52+
~Datacache() = default;
5353

5454
/**
5555
Retrieve an element from cache

components/keyrings/common/operations/operations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class Keyring_operations {
493493
load_cache();
494494
}
495495

496-
~Keyring_operations() {}
496+
~Keyring_operations() = default;
497497

498498
/**
499499
Insert API to populate cache

components/keyrings/keyring_file/backend/backend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Keyring_file_backend final {
3636
explicit Keyring_file_backend(const std::string keyring_file_name,
3737
bool read_only);
3838

39-
~Keyring_file_backend() {}
39+
~Keyring_file_backend() = default;
4040

4141
/**
4242
Fetch data

components/libminchassis/my_metadata.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2222

2323
#include "components/libminchassis/my_metadata.h"
2424

25-
my_metadata::my_metadata() {}
25+
my_metadata::my_metadata() = default;
2626

27-
my_metadata::my_metadata(my_metadata &other) : data(other.data) {}
27+
my_metadata::my_metadata(my_metadata &) = default;
2828

2929
my_metadata::const_iterator::const_iterator(
3030
my_unordered_string_to_string_map::const_iterator iter,

components/libminchassis/my_ref_counted.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ my_ref_counted::my_ref_counted(my_ref_counted &other)
3030
: m_count(other.m_count.load()) {}
3131

3232
/* virtual destructor */
33-
my_ref_counted::~my_ref_counted() {}
33+
my_ref_counted::~my_ref_counted() = default;
3434

3535
/**
3636
Increases a reference count.

components/libminchassis/mysql_service_implementation.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,9 @@ mysql_service_implementation::mysql_service_implementation(
4545
}
4646

4747
mysql_service_implementation::mysql_service_implementation(
48-
mysql_service_implementation &other)
49-
: my_ref_counted(other),
50-
my_metadata(other),
51-
m_interface(other.m_interface),
52-
m_service(other.m_service),
53-
m_full_name(other.m_full_name) {}
48+
mysql_service_implementation &)
49+
50+
= default;
5451

5552
/**
5653
Gets service name that is implemented by this service implementation.

0 commit comments

Comments
 (0)