]> granicus.if.org Git - clang/commitdiff
clang-format: Fix bad wrapping after "*" introduced in r232044.
authorDaniel Jasper <djasper@google.com>
Wed, 18 Mar 2015 14:20:13 +0000 (14:20 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 18 Mar 2015 14:20:13 +0000 (14:20 +0000)
Before:
  void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa*
                                              const aaaaaaaaaaaa) {}

After:
  void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {}

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

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

index 911d52d7be50856005d7fcae4ff33791cff4dfc1..eea9d67e6939ee95e8fd7840dfdce4c2475d4710 100644 (file)
@@ -1996,9 +1996,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
   if (Left.isOneOf(TT_JavaAnnotation, TT_LeadingJavaAnnotation))
     return !Right.is(tok::l_paren);
   if (Left.is(TT_PointerOrReference))
-    return (!Line.IsMultiVariableDeclStmt &&
-            Style.PointerAlignment != FormatStyle::PAS_Right) ||
-           Right.is(TT_FunctionDeclarationName);
+    return Right.is(TT_FunctionDeclarationName);
   if (Right.is(TT_PointerOrReference))
     return Line.IsMultiVariableDeclStmt ||
            (Style.PointerAlignment == FormatStyle::PAS_Right &&
index 0b5babaf19a5210a9fbcde585dbe88e456415389..228e952bd1e0da1a74c2cfe63f8c8742f8ba3219 100644 (file)
@@ -3774,6 +3774,12 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
       "typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa\n"
       "aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
       "    bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}");
+
+  FormatStyle Style = getLLVMStyle();
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+               "    aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {}",
+               Style);
 }
 
 TEST_F(FormatTest, TrailingReturnType) {