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

Daniel Jasper djasper at google.com
Wed Jan 23 07:55:20 PST 2013


Author: djasper
Date: Wed Jan 23 09:55:19 2013
New Revision: 173268

URL: http://llvm.org/viewvc/llvm-project?rev=173268&view=rev
Log:
Don't try to do a hanging ident after assignments.

Before:
bool aaaa = aaaaaaaaaaa(
                aaaaaaaaaaaaaaaaa);

After:
bool aaaa = aaaaaaaaaaa(
    aaaaaaaaaaaaaaaaa);

The other indentation was a nice attempt but doesn't work in many cases.
Not sure what the right long term solution is as the "After: " is still
not nice. We either need to figure out what to do in the cases where it
"doesn't work" or come up with a third solution, e.g. falling back to:

bool aaaa =
    aaaaaaaaaaa(
        aaaaaaaaaaaaaaaaa);

which should always work and nicely highlight the structure.

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=173268&r1=173267&r2=173268&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Jan 23 09:55:19 2013
@@ -596,12 +596,9 @@
           Current.isNot(tok::comment))
         State.Stack[ParenLevel].HasMultiParameterLine = true;
 
-
-      // Top-level spaces that are not part of assignments are exempt as that
-      // mostly leads to better results.
+      // Top-level spaces are exempt as that mostly leads to better results.
       State.Column += Spaces;
-      if (Spaces > 0 &&
-          (ParenLevel != 0 || getPrecedence(Previous) == prec::Assignment))
+      if (Spaces > 0 && ParenLevel != 0)
         State.Stack[ParenLevel].LastSpace = State.Column;
     }
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=173268&r1=173267&r2=173268&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 23 09:55:19 2013
@@ -1040,9 +1040,8 @@
       "    TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(),\n"
       "                        SI->getPointerAddressSpaceee());\n");
   verifyFormat(
-      "CharSourceRange LineRange =\n"
-      "    CharSourceRange::getTokenRange(Line.Tokens.front().Tok.getLoc(),\n"
-      "                                   Line.Tokens.back().Tok.getLoc());");
+      "CharSourceRange LineRange = CharSourceRange::getTokenRange(\n"
+      "    Line.Tokens.front().Tok.getLo(), Line.Tokens.back().Tok.getLoc());");
 }
 
 TEST_F(FormatTest, AlignsAfterAssignments) {





More information about the cfe-commits mailing list