[cfe-commits] r172308 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp

Daniel Jasper djasper at google.com
Fri Jan 11 23:36:22 PST 2013


Author: djasper
Date: Sat Jan 12 01:36:22 2013
New Revision: 172308

URL: http://llvm.org/viewvc/llvm-project?rev=172308&view=rev
Log:
Fix incorrect comparison operator causing loooong formatting times.

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=172308&r1=172307&r2=172308&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Sat Jan 12 01:36:22 2013
@@ -282,7 +282,9 @@
         return FirstLessLess < Other.FirstLessLess;
       if (BreakBeforeClosingBrace != Other.BreakBeforeClosingBrace)
         return BreakBeforeClosingBrace;
-      return BreakAfterComma;
+      if (BreakAfterComma != Other.BreakAfterComma)
+        return BreakAfterComma;
+      return false;
     }
   };
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172308&r1=172307&r2=172308&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sat Jan 12 01:36:22 2013
@@ -681,6 +681,24 @@
                      "    : some_var_(var),  // 4 space indent\n"
                      "      some_other_var_(var + 1) {  // lined up\n"
                      "}");
+
+  // This test takes VERY long when memoization is broken.
+  verifyGoogleFormat(
+      "Constructor()\n"
+      "    : aaaa(a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,"
+      " a, a, a,\n"
+      "           a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,"
+      " a, a, a,\n"
+      "           a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,"
+      " a, a, a,\n"
+      "           a, a, a, a, a, a, a, a, a, a, a)\n"
+      "      aaaa(a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,"
+      " a, a, a,\n"
+      "           a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,"
+      " a, a, a,\n"
+      "           a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,"
+      " a, a, a,\n"
+      "           a, a, a, a, a, a, a, a, a, a, a) {}\n");
 }
 
 TEST_F(FormatTest, BreaksAsHighAsPossible) {





More information about the cfe-commits mailing list