]> granicus.if.org Git - clang/commitdiff
Improve indentation after breaking at nested name specifiers.
authorDaniel Jasper <djasper@google.com>
Mon, 28 Jan 2013 07:43:15 +0000 (07:43 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 28 Jan 2013 07:43:15 +0000 (07:43 +0000)
These always represent a continuation and we should increase the ident.

Before:
aaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa::
          aaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa::
              aaaaaaaaaaaaaaaaaaaa);

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

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

index bae1bbb86d943b5a8e6f3b2612261a3a3409ad01..99b2d545c2a92014ecb03f82b284d6946b1ed226 100644 (file)
@@ -550,9 +550,10 @@ private:
                  State.Stack[ParenLevel].FirstLessLess != 0) {
         State.Column = State.Stack[ParenLevel].FirstLessLess;
       } else if (ParenLevel != 0 &&
-                 (Previous.is(tok::equal) || Current.is(tok::arrow) ||
-                  Current.is(tok::period) || Previous.is(tok::question) ||
-                  Previous.Type == TT_ConditionalExpr)) {
+                 (Previous.is(tok::equal) || Previous.is(tok::coloncolon) ||
+                  Previous.is(tok::question) ||
+                  Previous.Type == TT_ConditionalExpr ||
+                  Current.is(tok::period) || Current.is(tok::arrow))) {
         // Indent and extra 4 spaces after if we know the current expression is
         // continued.  Don't do that on the top level, as we already indent 4
         // there.
index d877dc29e55df4279a0bc51a45d9494b6a79dc0f..e47c7a5196cc303aed72fbf8ed52804cddb9e4d0 100644 (file)
@@ -1252,7 +1252,7 @@ TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) {
   // "bbbbb..." here instead of what we are doing now.
   verifyFormat(
       "aaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb::\n"
-      "                cccccccccccccccccccccccccccccccccccccccccccccccccc());");
+      "                    cccccccccccccccccccccccccccccccccccccccccccccc());");
 
   // Breaking at nested name specifiers is generally not desirable.
   verifyFormat(