Apply clang-tidy to remove empty constructors / destructors

This patch is the result of running
run-clang-tidy -fix -header-filter=.* -checks='-*,modernize-use-equals-default' .

Code style changes have been done on top. The result of this change
leads to the following improvements:

1. Binary size reduction.
* For a -DBUILD_CONFIG=mysql_release build, the binary size is reduced by
  ~400kb.
* A raw -DCMAKE_BUILD_TYPE=Release reduces the binary size by ~1.4kb.

2. Compiler can better understand the intent of the code, thus it leads
   to more optimization possibilities. Additionally it enabled detecting
   unused variables that had an empty default constructor but not marked
   so explicitly.

   Particular change required following this patch in sql/opt_range.cc

   result_keys, an unused template class Bitmap now correctly issues
   unused variable warnings.

   Setting Bitmap template class constructor to default allows the compiler
   to identify that there are no side-effects when instantiating the class.
   Previously the compiler could not issue the warning as it assumed Bitmap
   class (being a template) would not be performing a NO-OP for its default
   constructor. This prevented the "unused variable warning".
This commit is contained in:
Vicențiu Ciorbaru 2023-02-07 13:57:20 +02:00
commit 08c852026d
242 changed files with 1101 additions and 1341 deletions

View file

@ -33,7 +33,7 @@ class GRN_DAT_API Array {
}
template <UInt32 U>
explicit Array(T (&array)[U]) : ptr_(array), size_(U) {}
~Array() {}
~Array() = default;
const T &operator[](UInt32 i) const {
GRN_DAT_DEBUG_THROW_IF(i >= size_);

View file

@ -25,8 +25,8 @@ namespace dat {
class GRN_DAT_API Cursor {
public:
Cursor() {}
virtual ~Cursor() {}
Cursor() = default;
virtual ~Cursor() = default;
virtual void close() = 0;

View file

@ -175,12 +175,8 @@ class Exception : public std::exception {
file_(file),
line_(line),
what_((what != NULL) ? what : "") {}
Exception(const Exception &ex) throw()
: std::exception(ex),
file_(ex.file_),
line_(ex.line_),
what_(ex.what_) {}
virtual ~Exception() throw() {}
Exception(const Exception &ex) throw() = default;
virtual ~Exception() throw() = default;
virtual ErrorCode code() const throw() = 0;
virtual const char *file() const throw() {
@ -208,7 +204,7 @@ class Error : public Exception {
: Exception(file, line, what) {}
Error(const Error &ex) throw()
: Exception(ex) {}
virtual ~Error() throw() {}
virtual ~Error() throw() = default;
virtual ErrorCode code() const throw() {
return T;

View file

@ -33,7 +33,7 @@ IdCursor::IdCursor()
end_(INVALID_KEY_ID),
count_(0) {}
IdCursor::~IdCursor() {}
IdCursor::~IdCursor() = default;
void IdCursor::open(const Trie &trie,
const String &min_str,

View file

@ -99,7 +99,7 @@ class GRN_DAT_API Key {
// Disallows instantiation.
Key() : id_and_length_low_(INVALID_KEY_ID << 4), length_high_(0) {}
~Key() {}
~Key() = default;
// Disallows copy and assignment.
Key(const Key &);

View file

@ -35,7 +35,7 @@ PredictiveCursor::PredictiveCursor()
end_(0),
min_length_(0) {}
PredictiveCursor::~PredictiveCursor() {}
PredictiveCursor::~PredictiveCursor() = default;
void PredictiveCursor::open(const Trie &trie,
const String &str,

View file

@ -33,7 +33,7 @@ PrefixCursor::PrefixCursor()
cur_(0),
end_(0) {}
PrefixCursor::~PrefixCursor() {}
PrefixCursor::~PrefixCursor() = default;
void PrefixCursor::open(const Trie &trie,
const String &str,

View file

@ -35,9 +35,7 @@ class GRN_DAT_API String {
explicit String(const char (&str)[T])
: ptr_(reinterpret_cast<const UInt8 *>(str)),
length_(T - 1) {}
String(const String &rhs)
: ptr_(rhs.ptr_),
length_(rhs.length_) {}
String(const String &rhs) = default;
String &operator=(const String &rhs) {
set_ptr(rhs.ptr());

View file

@ -55,7 +55,7 @@ Trie::Trie()
entries_(),
key_buf_() {}
Trie::~Trie() {}
Trie::~Trie() = default;
void Trie::create(const char *file_name,
UInt64 file_size,