ksuther created this revision.
ksuther added reviewers: cfe-commits, djasper.
Herald added a subscriber: klimek.

The BraceWrapping of the Linux style is incorrect. This appeared in r248802 
when the custom BraceWrapping options were added.

This is what r248801 looked like:

clang-format -style="{BasedOnStyle: google,  BreakBeforeBraces: Linux}" 
~/Desktop/format.m 
void main()
{
  if (blah) {
    stuff();
  } else {
    more();
  }
}

This is what r248802 (and trunk) looks like:

clang-format -style="{BasedOnStyle: google,  BreakBeforeBraces: Linux}" 
~/Desktop/format.m 
void main()
{
  if (blah) {
    stuff();
  }
  else {
    more();
  }
}

The behavior before r248802 is correct based on the documentation:

BS_Linux (in configuration: Linux) Like Attach, but break before braces on 
function, namespace and class definitions.

I changed BraceWrapping.BeforeElse to false for Linux and added and else 
statement to the Linux brace test.

http://reviews.llvm.org/D15485

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9003,6 +9003,8 @@
                "    if (true) {\n"
                "      a();\n"
                "      b();\n"
+               "    } else {\n"
+               "      c();\n"
                "    }\n"
                "  }\n"
                "  void g() { return; }\n"
Index: lib/Format/Format.cpp
===================================================================
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -396,7 +396,7 @@
     Expanded.BraceWrapping.AfterClass = true;
     Expanded.BraceWrapping.AfterFunction = true;
     Expanded.BraceWrapping.AfterNamespace = true;
-    Expanded.BraceWrapping.BeforeElse = true;
+    Expanded.BraceWrapping.BeforeElse = false;
     break;
   case FormatStyle::BS_Mozilla:
     Expanded.BraceWrapping.AfterClass = true;


Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9003,6 +9003,8 @@
                "    if (true) {\n"
                "      a();\n"
                "      b();\n"
+               "    } else {\n"
+               "      c();\n"
                "    }\n"
                "  }\n"
                "  void g() { return; }\n"
Index: lib/Format/Format.cpp
===================================================================
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -396,7 +396,7 @@
     Expanded.BraceWrapping.AfterClass = true;
     Expanded.BraceWrapping.AfterFunction = true;
     Expanded.BraceWrapping.AfterNamespace = true;
-    Expanded.BraceWrapping.BeforeElse = true;
+    Expanded.BraceWrapping.BeforeElse = false;
     break;
   case FormatStyle::BS_Mozilla:
     Expanded.BraceWrapping.AfterClass = true;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to