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.fernan...@gmail.com>
To: cfe-...@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
Index: docs/ClangFormatStyleOptions.rst
===================================================================
--- docs/ClangFormatStyleOptions.rst	(revision 314636)
+++ docs/ClangFormatStyleOptions.rst	(working copy)
@@ -891,19 +891,28 @@
 
     .. code-block:: c++
 
-      try {
+      try
+      {
         foo();
       }
-      catch () {
+      catch ()
+      {
       }
       void foo() { bar(); }
-      class foo {
+      class foo
+      {
       };
-      if (foo()) {
+      if (foo())
+      {
       }
-      else {
+      else
+      {
       }
-      enum X : int { A, B };
+      enum X : int
+      {
+        A,
+        B
+      };
 
   * ``BS_GNU`` (in configuration: ``GNU``)
     Always break before braces and add an extra level of indentation to
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to