diff --git a/doc/developer-notes.md b/doc/developer-notes.md --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -93,7 +93,7 @@ return didMore; } } -} +} // namespace foo ``` @@ -519,6 +519,21 @@ - *Rationale*: Avoids symbol conflicts +- Terminate namespaces with a comment (`// namespace mynamespace`). The comment + should be placed on the same line as the brace closing the namespace, e.g. + +```c++ +namespace mynamespace { + ... +} // namespace mynamespace + +namespace { + ... +} // namespace +``` + + - *Rationale*: Avoids confusion about the namespace context + Header Inclusions ----------------- diff --git a/src/.clang-format b/src/.clang-format --- a/src/.clang-format +++ b/src/.clang-format @@ -13,6 +13,6 @@ AllowShortBlocksOnASingleLine: false AllowShortIfStatementsOnASingleLine: true AllowShortFunctionsOnASingleLine: Inline -FixNamespaceComments: false +FixNamespaceComments: true ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, BOOST_REVERSE_FOREACH ] CommentPragmas: '@DISABLE FORMATING FOR THIS COMMENT@' diff --git a/src/addrdb.cpp b/src/addrdb.cpp --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -111,7 +111,7 @@ return DeserializeDB(chainParams, filein, data); } -} +} // namespace CBanDB::CBanDB(const CChainParams &chainParamsIn) : chainParams(chainParamsIn) { pathBanlist = GetDataDir() / "banlist.dat"; diff --git a/src/avalanche.h b/src/avalanche.h --- a/src/avalanche.h +++ b/src/avalanche.h @@ -48,7 +48,7 @@ * Special NodeId that represent no node. */ static const NodeId NO_NODE = -1; -} +} // namespace /** * Vote history. diff --git a/src/bench/bench.h b/src/bench/bench.h --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -129,7 +129,7 @@ int64_t m_width; int64_t m_height; }; -} +} // namespace benchmark // BENCHMARK(foo, num_iters_for_one_second) expands to: benchmark::BenchRunner // bench_11foo("foo", num_iterations); diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp --- a/src/bench/checkblock.cpp +++ b/src/bench/checkblock.cpp @@ -11,7 +11,7 @@ namespace block_bench { #include -} +} // namespace block_bench // These are the two major time-sinks which happen after we have fully received // a block off the wire, but before we can relay the block on to peers using diff --git a/src/crypto/sha256_avx2.cpp b/src/crypto/sha256_avx2.cpp --- a/src/crypto/sha256_avx2.cpp +++ b/src/crypto/sha256_avx2.cpp @@ -101,7 +101,7 @@ WriteLE32(out + 192 + offset, _mm256_extract_epi32(v, 1)); WriteLE32(out + 224 + offset, _mm256_extract_epi32(v, 0)); } -} +} // namespace void Transform_8way(uint8_t *out, const uint8_t *in) { // Transform 1 @@ -449,6 +449,6 @@ Write8(out, 24, Add(g, K(0x1f83d9abul))); Write8(out, 28, Add(h, K(0x5be0cd19ul))); } -} +} // namespace sha256d64_avx2 #endif diff --git a/src/crypto/sha256_shani.cpp b/src/crypto/sha256_shani.cpp --- a/src/crypto/sha256_shani.cpp +++ b/src/crypto/sha256_shani.cpp @@ -77,7 +77,7 @@ inline void __attribute__((always_inline)) Save(uint8_t *out, __m128i s) { _mm_storeu_si128((__m128i *)out, _mm_shuffle_epi8(s, MASK)); } -} +} // namespace namespace sha256_shani { void Transform(uint32_t *s, const uint8_t *chunk, size_t blocks) { @@ -141,7 +141,7 @@ _mm_storeu_si128((__m128i *)s, s0); _mm_storeu_si128((__m128i *)(s + 4), s1); } -} +} // namespace sha256_shani namespace sha256d64_shani { @@ -353,6 +353,6 @@ Save(out + 32, bs0); Save(out + 48, bs1); } -} +} // namespace sha256d64_shani #endif diff --git a/src/crypto/sha256_sse4.cpp b/src/crypto/sha256_sse4.cpp --- a/src/crypto/sha256_sse4.cpp +++ b/src/crypto/sha256_sse4.cpp @@ -952,7 +952,7 @@ : "cc", "memory", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11", "xmm12"); } -} +} // namespace sha256_sse4 /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/src/crypto/sha256_sse41.cpp b/src/crypto/sha256_sse41.cpp --- a/src/crypto/sha256_sse41.cpp +++ b/src/crypto/sha256_sse41.cpp @@ -91,7 +91,7 @@ WriteLE32(out + 64 + offset, _mm_extract_epi32(v, 1)); WriteLE32(out + 96 + offset, _mm_extract_epi32(v, 0)); } -} +} // namespace void Transform_4way(uint8_t *out, const uint8_t *in) { // Transform 1 @@ -439,6 +439,6 @@ Write4(out, 24, Add(g, K(0x1f83d9abul))); Write4(out, 28, Add(h, K(0x5be0cd19ul))); } -} +} // namespace sha256d64_sse41 #endif diff --git a/src/fs.h b/src/fs.h --- a/src/fs.h +++ b/src/fs.h @@ -18,6 +18,6 @@ namespace fsbridge { FILE *fopen(const fs::path &p, const char *mode); FILE *freopen(const fs::path &p, const char *mode, FILE *stream); -}; +}; // namespace fsbridge #endif // BITCOIN_FS_H diff --git a/src/fs.cpp b/src/fs.cpp --- a/src/fs.cpp +++ b/src/fs.cpp @@ -15,4 +15,4 @@ return ::freopen(p.string().c_str(), mode, stream); } -} // fsbridge +} // namespace fsbridge diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3699,7 +3699,7 @@ return mp->CompareDepthAndScore(*b, *a); } }; -} +} // namespace bool PeerLogicValidation::SendMessages(const Config &config, CNode *pto, std::atomic &interruptMsgProc) { diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -38,7 +38,7 @@ namespace interfaces { class Handler; class Node; -} +} // namespace interfaces QT_BEGIN_NAMESPACE class QAction; diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -20,7 +20,7 @@ namespace interfaces { class Handler; class Node; -} +} // namespace interfaces QT_BEGIN_NAMESPACE class QTimer; diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h --- a/src/qt/splashscreen.h +++ b/src/qt/splashscreen.h @@ -16,7 +16,7 @@ class Handler; class Node; class Wallet; -}; +}; // namespace interfaces /** Class for the splashscreen with information of the running client. * diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp --- a/src/qt/test/paymentservertests.cpp +++ b/src/qt/test/paymentservertests.cpp @@ -7,12 +7,12 @@ #include #include #include +#include #include #include