[cfe-dev] Fwd: clang-format: Incorrect BreakBeforeBraces documentation

Matthew Fernandez via cfe-dev cfe-dev at lists.llvm.org
Sun Oct 1 16:54:23 PDT 2017


Hello cfe-commits,

I sent the following mail to cfe-dev, but didn't receive reply. I believe the attached patch to the Clang repo fixes 
this issue, if you're happy to accept it. Please let me know if you want it altered or if I've made a mistake.

Thanks,
Matt


-------- Forwarded Message --------
Subject: clang-format: Incorrect BreakBeforeBraces documentation
Date: Wed, 13 Sep 2017 18:11:57 -0700
From: Matthew Fernandez <matthew.fernandez at gmail.com>
To: cfe-dev at lists.llvm.org

Hello cfe-dev,

If this is not the right place for reporting issues with clang-format, please let me know where I should post this instead.

The docs for the BreakBeforeBraces option of clang-format style [0] give the following example of Allman bracing:

     try {
       foo();
     }
     catch () {
     }
     void foo() { bar(); }
     class foo {
     };
     if (foo()) {
     }
     else {
     }
     enum X : int { A, B };

This does not seem to be Allman style. In fact clang-format itself will reflow this example:

     $ clang-format -style="{BreakBeforeBraces: Allman}" allman.cpp
     try
     {
       foo();
     }
     catch ()
     {
     }
     void foo() { bar(); }
     class foo
     {
     };
     if (foo())
     {
     }
     else
     {
     }
     enum X : int
     {
       A,
       B
     };

Is this a mistake in the documentation?

Thanks,
Matt

   [0]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ClangFormatStyleOptions.patch
Type: text/x-patch
Size: 771 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171001/f79871d7/attachment.bin>


More information about the cfe-dev mailing list