r181872 - Don't merge one-line functions in weird brace styles.

Daniel Jasper djasper at google.com
Wed May 15 01:30:06 PDT 2013


Author: djasper
Date: Wed May 15 03:30:06 2013
New Revision: 181872

URL: http://llvm.org/viewvc/llvm-project?rev=181872&view=rev
Log:
Don't merge one-line functions in weird brace styles.

Modified:
    cfe/trunk/lib/Format/Format.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=181872&r1=181871&r2=181872&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed May 15 03:30:06 2013
@@ -1341,7 +1341,8 @@ private:
     if (I + 1 == E || (I + 1)->Type == LT_Invalid)
       return;
 
-    if (I->Last->is(tok::l_brace)) {
+    if (I->Last->is(tok::l_brace) &&
+        Style.BreakBeforeBraces == FormatStyle::BS_Attach) {
       tryMergeSimpleBlock(I, E, Limit);
     } else if (I->First.is(tok::kw_if)) {
       tryMergeSimpleIf(I, E, Limit);

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=181872&r1=181871&r2=181872&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 15 03:30:06 2013
@@ -4117,6 +4117,10 @@ TEST_F(FormatTest, LinuxBraceBreaking) {
                "      b();\n"
                "    }\n"
                "  }\n"
+               "  void g()\n"
+               "  {\n"
+               "    return;\n"
+               "  }\n"
                "}\n"
                "}",
                BreakBeforeBrace);
@@ -4134,6 +4138,10 @@ TEST_F(FormatTest, StroustrupBraceBreaki
                "      b();\n"
                "    }\n"
                "  }\n"
+               "  void g()\n"
+               "  {\n"
+               "    return;\n"
+               "  }\n"
                "}\n"
                "}",
                BreakBeforeBrace);





More information about the cfe-commits mailing list