]> granicus.if.org Git - clang/commitdiff
Correctly format wrapped function call parameters in templated functions.
authorDaniel Jasper <djasper@google.com>
Wed, 9 Jan 2013 09:50:48 +0000 (09:50 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 9 Jan 2013 09:50:48 +0000 (09:50 +0000)
This fixes llvm.org/PR14846.

Before:
template <typename T>
void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
        int aaaaaaaaaaaaaaaaa);

After:
template <typename T>
void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
    int aaaaaaaaaaaaaaaaa);

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

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

index e5e59f4550a87746526c5b6049e729a74cfe1b0c..fbcb228fbe1a4fc1888ef1fe2a12fe45e5fb9198 100644 (file)
@@ -315,7 +315,7 @@ private:
                               WhitespaceStartColumn);
       }
 
-      State.LastSpace[ParenLevel] = State.Indent[ParenLevel];
+      State.LastSpace[ParenLevel] = State.Column;
       if (Current.is(tok::colon) && CurrentLineType != LT_ObjCMethodDecl &&
           State.NextToken->Type != TT_ConditionalExpr)
         State.Indent[ParenLevel] += 2;
index fb21ea7c6fb06bd6cb435f35cf8e5de0a8d7281d..56d4e17468b5a59ed8741437eb2cd245b6f20b24 100644 (file)
@@ -869,6 +869,9 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
       "aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa,\n"
       "                    aaaaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaa,\n"
       "                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+  verifyFormat("template <typename T>\n"
+               "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+               "    int aaaaaaaaaaaaaaaaa);");
 
 }