clang-format: Incorrect BreakBeforeBraces documentation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

clang-format: Incorrect BreakBeforeBraces documentation

David Chisnall via cfe-dev
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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Fwd: clang-format: Incorrect BreakBeforeBraces documentation

David Chisnall via cfe-dev
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 <[hidden email]>
To: [hidden email]

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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

ClangFormatStyleOptions.patch (810 bytes) Download Attachment