clang-format: Set BraceWrapping:AfterControlStatement:MultiLine #23216

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2110-srcFormat changing 1 files +1 −0
  1. MarcoFalke commented at 10:15 am on October 7, 2021: member

    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

  2. clang-format: Set BraceWrapping:AfterControlStatement:MultiLine facee3e229
  3. MarcoFalke added the label Docs on Oct 7, 2021
  4. practicalswift commented at 11:37 am on October 7, 2021: contributor
    Concept ACK
  5. katesalazar commented at 3:45 pm on October 7, 2021: contributor
    FWIW concept ACK
  6. MarcoFalke commented at 1:40 pm on October 8, 2021: member
    Sorry, this doesn’t function as expected, unless the column limit is set as well, as mentioned in the thread #21735
  7. MarcoFalke closed this on Oct 8, 2021

  8. MarcoFalke deleted the branch on Oct 8, 2021
  9. DrahtBot locked this on Oct 30, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me