r282410 - clang-format: Only special-case top-level */& in multivar-declstmts.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 26 08:14:25 PDT 2016


Author: djasper
Date: Mon Sep 26 10:14:24 2016
New Revision: 282410

URL: http://llvm.org/viewvc/llvm-project?rev=282410&view=rev
Log:
clang-format: Only special-case top-level */& in multivar-declstmts.

Before (even with PointerAlignment: Left):
  vector<int *> a, b;

After:
  vector<int*> a, b;

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=282410&r1=282409&r2=282410&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Sep 26 10:14:24 2016
@@ -2015,7 +2015,7 @@ bool TokenAnnotator::spaceRequiredBetwee
                                      Left.Previous->is(tok::r_paren)) ||
             (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
              (Style.PointerAlignment != FormatStyle::PAS_Left ||
-              Line.IsMultiVariableDeclStmt)));
+              (Line.IsMultiVariableDeclStmt && Left.NestingLevel == 0))));
   if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) &&
       (!Left.is(TT_PointerOrReference) ||
        (Style.PointerAlignment != FormatStyle::PAS_Right &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=282410&r1=282409&r2=282410&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Sep 26 10:14:24 2016
@@ -4802,6 +4802,7 @@ TEST_F(FormatTest, DeclarationsOfMultipl
   verifyFormat("aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,\n"
                "          *b = bbbbbbbbbbbbbbbbbbb, *d = ddddddddddddddddddd;",
                Style);
+  verifyFormat("vector<int*> a, b;", Style);
 }
 
 TEST_F(FormatTest, ConditionalExpressionsInBrackets) {




More information about the cfe-commits mailing list