chore(clang-tidy): Add clang-tidy rules: prefer-member-initializer and optin.performance.Padding (#3716)

* Add clang-tidy prefer-member-initializer

* Fix clang-tdy config

* Fix incorrect change

* Fix sorting of .clang-tidy
This commit is contained in:
Aaron Gokaslan
2022-02-10 12:45:46 -05:00
committed by GitHub
parent dc9803cef2
commit d6c66d25bb
9 changed files with 47 additions and 21 deletions

View File

@@ -103,10 +103,7 @@ public:
class NonCopyable {
public:
NonCopyable(int a, int b) : value{new int(a*b)} { print_created(this, a, b); }
NonCopyable(NonCopyable &&o) noexcept {
value = std::move(o.value);
print_move_created(this);
}
NonCopyable(NonCopyable &&o) noexcept : value{std::move(o.value)} { print_move_created(this); }
NonCopyable(const NonCopyable &) = delete;
NonCopyable() = delete;
void operator=(const NonCopyable &) = delete;
@@ -128,11 +125,8 @@ private:
class Movable {
public:
Movable(int a, int b) : value{a+b} { print_created(this, a, b); }
Movable(const Movable &m) { value = m.value; print_copy_created(this); }
Movable(Movable &&m) noexcept {
value = m.value;
print_move_created(this);
}
Movable(const Movable &m) : value{m.value} { print_copy_created(this); }
Movable(Movable &&m) noexcept : value{m.value} { print_move_created(this); }
std::string get_value() const { return std::to_string(value); }
~Movable() { print_destroyed(this); }
private: