From 1565eb3e381161924c96884c3bbc64bea6555535 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 23 Jan 2013 15:55:19 +0000 Subject: [PATCH] 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. llvm-svn: 173268 --- clang/lib/Format/Format.cpp | 7 ++----- clang/unittests/Format/FormatTest.cpp | 5 ++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 2952067c398d..9b6067c37b78 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -596,12 +596,9 @@ private: 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; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 708b7d8086a3..493f2ad7b2eb 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1040,9 +1040,8 @@ TEST_F(FormatTest, BreaksAfterAssignments) { " 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) {