Currently there is no visual break between the condition of a control statement and the body. For example:
0if (IsThisTrue() ||
1 IsThatTrue()) {
2 DoThis;
3 DoThat;
4}
Fix this by allowing the brace to be on a new line.
Currently clang-format won’t re-format existing code, presumably due to the line-limit setting. However, the new line can be manually inserted and clang-format will no longer remove it with this new setting. So this can be tested by “injecting” a newline after a multi line control statement and calling clang-format-diff, as explained in the dev notes.
Example location to test:
0diff --git a/src/net_processing.cpp b/src/net_processing.cpp
1index 66b99aa2bb..f7dee82335 100644
2--- a/src/net_processing.cpp
3+++ b/src/net_processing.cpp
4@@ -4313,7 +4313,8 @@ void PeerManagerImpl::CheckForStaleTipAndEvictPeers()
5 void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer, std::chrono::microseconds now)
6 {
7 if (m_connman.ShouldRunInactivityChecks(node_to) && peer.m_ping_nonce_sent &&
8- now > peer.m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL}) {
9+ now > peer.m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL} )
10+{
11 LogPrint(BCLog::NET, "ping timeout: %fs peer=%d\n", 0.000001 * count_microseconds(now - peer.m_ping_start.load()), peer.m_id);
12 node_to.fDisconnect = true;
13 return;
See also: https://clang.llvm.org/docs/ClangFormatStyleOptions.html Fixes #21735