summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-30 08:29:25 +0000
committerDaniel Jasper <djasper@google.com>2013-08-30 08:29:25 +0000
commitf79b0b15623a9138d629dac7f7928fa9630d83bc (patch)
tree403a798ce617909e28c146e534ef4d67e97ea008
parent2cf664fb86e0abbf8d9000e9a71f31e0fa1203d4 (diff)
downloadbcm5719-llvm-f79b0b15623a9138d629dac7f7928fa9630d83bc.tar.gz
bcm5719-llvm-f79b0b15623a9138d629dac7f7928fa9630d83bc.zip
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. llvm-svn: 189658
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp13
2 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 2737b8d5269..878580e8920 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -410,13 +410,12 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline,
// 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;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index dc2dc01e203..9c8efd882c4 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2212,14 +2212,11 @@ TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) {
// 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"
OpenPOWER on IntegriCloud