r189658 - clang-format: Fix incorrect indentation.
Daniel Jasper
djasper at google.com
Fri Aug 30 01:29:25 PDT 2013
Author: djasper
Date: Fri Aug 30 03:29:25 2013
New Revision: 189658
URL: http://llvm.org/viewvc/llvm-project?rev=189658&view=rev
Log:
clang-format: Fix incorrect indentation.
Before:
aaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(
dddddddddddddddddddddddddddddd));
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
dddddddddddddddddddddddddddddd));
After:
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(
dddddddddddddddddddddddddddddd));
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
dddddddddddddddddddddddddddddd));
This was overlooked when interducing the new builder-type call
detection in r189337. Also, some minor reorganization of a test.
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=189658&r1=189657&r2=189658&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Aug 30 03:29:25 2013
@@ -410,13 +410,12 @@ unsigned ContinuationIndenter::addTokenT
// OuterFunction(InnerFunctionCall(
// ParameterToInnerFunction),
// SecondParameterToOuterFunction);
- bool HasMultipleParameters = !Current.FakeLParens.empty();
bool HasTrailingCall = false;
if (Previous.MatchingParen) {
const FormatToken *Next = Previous.MatchingParen->getNextNonComment();
HasTrailingCall = Next && Next->isMemberAccess();
}
- if (HasMultipleParameters ||
+ if (startsBinaryExpression(Current) ||
(HasTrailingCall &&
State.Stack[State.Stack.size() - 2].CallContinuation == 0))
State.Stack.back().LastSpace = State.Column;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=189658&r1=189657&r2=189658&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Aug 30 03:29:25 2013
@@ -2212,14 +2212,11 @@ TEST_F(FormatTest, PutEmptyBlocksIntoOne
// Line break tests.
//===----------------------------------------------------------------------===//
-TEST_F(FormatTest, FormatsAwesomeMethodCall) {
+TEST_F(FormatTest, PreventConfusingIndents) {
verifyFormat(
"SomeLongMethodName(SomeReallyLongMethod(CallOtherReallyLongMethod(\n"
" parameter, parameter, parameter)),\n"
" SecondLongCall(parameter));");
-}
-
-TEST_F(FormatTest, PreventConfusingIndents) {
verifyFormat(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaa(\n"
@@ -2724,6 +2721,12 @@ TEST_F(FormatTest, BreaksDesireably) {
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+ // Indent consistently indenpendent of call expression.
+ verifyFormat("aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(\n"
+ " dddddddddddddddddddddddddddddd));\n"
+ "aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n"
+ " dddddddddddddddddddddddddddddd));");
+
// This test case breaks on an incorrect memoization, i.e. an optimization not
// taking into account the StopAt value.
verifyFormat(
@@ -5259,7 +5262,7 @@ TEST_F(FormatTest, BreakStringLiterals)
getLLVMStyleWithColumns(20)));
EXPECT_EQ(
"f(\"one two\".split(\n"
- " variable));",
+ " variable));",
format("f(\"one two\".split(variable));", getLLVMStyleWithColumns(20)));
EXPECT_EQ("f(\"one two three four five six \"\n"
" \"seven\".split(\n"
More information about the cfe-commits
mailing list