]> granicus.if.org Git - clang/commitdiff
clang-format: Don't indent relative to unary operators (some more).
authorDaniel Jasper <djasper@google.com>
Mon, 29 Jun 2015 10:42:59 +0000 (10:42 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 29 Jun 2015 10:42:59 +0000 (10:42 +0000)
Before:
  long aaaaaaaa = !aaaa( // break
                      aaaaaa);
  long aaaaaaaa = !aa.aa( // break
      aaaaaa);

After:
  long aaaaaaaa = !aaaa( // break
      aaaaaa);
  long aaaaaaaa = !aa.aa( // break
      aaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240934 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp

index 2357abd7abdb4f9d1c9cee78cb856eb719c92629..2717c2731d2cd794230cf737610c92c5d566dd1e 100644 (file)
@@ -815,7 +815,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
     //       ParameterToInnerFunction));
     if (*I > prec::Unknown)
       NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column);
-    if (*I != prec::Conditional)
+    if (*I != prec::Conditional && !Current.is(TT_UnaryOperator))
       NewParenState.StartOfFunctionCall = State.Column;
 
     // Always indent conditional expressions. Never indent expression where
index 445b5a941ac9d7b3441e41df8030665c00490d1b..6b8bff167abd2dfe656ef8cf2299b431c0d5b924 100644 (file)
@@ -3921,10 +3921,12 @@ TEST_F(FormatTest, BreaksDesireably) {
                "                      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
                "                  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
 
-  // Indent consistently independent of call expression.
+  // Indent consistently independent of call expression and unary operator.
+  verifyFormat("aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n"
+               "    dddddddddddddddddddddddddddddd));");
+  verifyFormat("aaaaaaaaaaa(!bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n"
+               "    dddddddddddddddddddddddddddddd));");
   verifyFormat("aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(\n"
-               "    dddddddddddddddddddddddddddddd));\n"
-               "aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n"
                "    dddddddddddddddddddddddddddddd));");
 
   // This test case breaks on an incorrect memoization, i.e. an optimization not
@@ -5190,7 +5192,7 @@ TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
                "        aaaaa)) {\n"
                "}");
   verifyFormat("aaaaaaaaaa(!aaaaaaaaaa( // break\n"
-               "               aaaaa));");
+               "    aaaaa));");
   verifyFormat("*aaa = aaaaaaa( // break\n"
                "    bbbbbb);");
 }