Skip to content

Commit 01dc38b

Browse files
committed
Merge bitcoin/bitcoin#30406: refactor: modernize-use-equals-default
3333bae tidy: modernize-use-equals-default (MarcoFalke) Pull request description: Prior to C++20, `modernize-use-equals-default` could have been problematic because it could turn a non-aggregate into an aggregate. The risk would be that aggregate initialization would be enabled where the author did not intend to enable it. With C++20, aggregate for those is forbidden either way. (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1008r1.pdf) So enabled it for code clarity, consistency, and possibly unlocking compiler optimizations. See https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html ACKs for top commit: stickies-v: ACK 3333bae Tree-SHA512: ab42ff01be7ca7e7d8b4c6a485e68426f59627d83dd827cf292304829562348dc17a52ee009f5f6f3c1c2081d7166ffac4baef23197ebeba8de7767c6ddfe255
2 parents c2c0b4f + 3333bae commit 01dc38b

Some content is hidden

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

53 files changed

+72
-76
lines changed

src/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ misc-unused-using-decls,
1010
misc-no-recursion,
1111
modernize-use-default-member-init,
1212
modernize-use-emplace,
13+
modernize-use-equals-default,
1314
modernize-use-noexcept,
1415
modernize-use-nullptr,
1516
performance-*,

src/arith_uint256.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class base_uint
240240
/** 256-bit unsigned big integer. */
241241
class arith_uint256 : public base_uint<256> {
242242
public:
243-
arith_uint256() {}
243+
arith_uint256() = default;
244244
arith_uint256(const base_uint<256>& b) : base_uint<256>(b) {}
245245
arith_uint256(uint64_t b) : base_uint<256>(b) {}
246246

src/blockencodings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class BlockTransactions {
5959
uint256 blockhash;
6060
std::vector<CTransactionRef> txn;
6161

62-
BlockTransactions() {}
62+
BlockTransactions() = default;
6363
explicit BlockTransactions(const BlockTransactionsRequest& req) :
6464
blockhash(req.blockhash), txn(req.indexes.size()) {}
6565

@@ -109,7 +109,7 @@ class CBlockHeaderAndShortTxIDs {
109109
/**
110110
* Dummy for deserialization
111111
*/
112-
CBlockHeaderAndShortTxIDs() {}
112+
CBlockHeaderAndShortTxIDs() = default;
113113

114114
/**
115115
* @param[in] nonce This should be randomly generated, and is used for the siphash secret key

src/chain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CBlockFileInfo
6666
READWRITE(VARINT(obj.nTimeLast));
6767
}
6868

69-
CBlockFileInfo() {}
69+
CBlockFileInfo() = default;
7070

7171
std::string ToString() const;
7272

src/coins.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class CCoinsViewCursor
154154
{
155155
public:
156156
CCoinsViewCursor(const uint256 &hashBlockIn): hashBlock(hashBlockIn) {}
157-
virtual ~CCoinsViewCursor() {}
157+
virtual ~CCoinsViewCursor() = default;
158158

159159
virtual bool GetKey(COutPoint &key) const = 0;
160160
virtual bool GetValue(Coin &coin) const = 0;
@@ -198,7 +198,7 @@ class CCoinsView
198198
virtual std::unique_ptr<CCoinsViewCursor> Cursor() const;
199199

200200
//! As we use CCoinsViews polymorphically, have a virtual destructor
201-
virtual ~CCoinsView() {}
201+
virtual ~CCoinsView() = default;
202202

203203
//! Estimate database size (0 if not implemented)
204204
virtual size_t EstimateSize() const { return 0; }

src/crypto/muhash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class MuHash3072
9797

9898
public:
9999
/* The empty set. */
100-
MuHash3072() noexcept {};
100+
MuHash3072() noexcept = default;
101101

102102
/* A singleton with variable sized data in it. */
103103
explicit MuHash3072(Span<const unsigned char> in) noexcept;

src/crypto/sha3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SHA3_256
3232
public:
3333
static constexpr size_t OUTPUT_SIZE = 32;
3434

35-
SHA3_256() {}
35+
SHA3_256() = default;
3636
SHA3_256& Write(Span<const unsigned char> data);
3737
SHA3_256& Finalize(Span<unsigned char> output);
3838
SHA3_256& Reset();

src/flatfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct FlatFilePos
1818

1919
SERIALIZE_METHODS(FlatFilePos, obj) { READWRITE(VARINT_MODE(obj.nFile, VarIntMode::NONNEGATIVE_SIGNED), VARINT(obj.nPos)); }
2020

21-
FlatFilePos() {}
21+
FlatFilePos() = default;
2222

2323
FlatFilePos(int nFileIn, unsigned int nPosIn) :
2424
nFile(nFileIn),

src/headerssync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct CompressedHeader {
100100

101101
class HeadersSyncState {
102102
public:
103-
~HeadersSyncState() {}
103+
~HeadersSyncState() = default;
104104

105105
enum class State {
106106
/** PRESYNC means the peer has not yet demonstrated their chain has

src/httpserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class HTTPClosure
156156
{
157157
public:
158158
virtual void operator()() = 0;
159-
virtual ~HTTPClosure() {}
159+
virtual ~HTTPClosure() = default;
160160
};
161161

162162
/** Event class. This can be used either as a cross-thread trigger or as a timer.

0 commit comments

Comments
 (0)