From 3f2cde91d8b66d2d086fa08ee874535ba3b6a4ec Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 26 Sep 2016 15:14:24 +0000 Subject: [PATCH] clang-format: Only special-case top-level */& in multivar-declstmts. Before (even with PointerAlignment: Left): vector a, b; After: vector a, b; llvm-svn: 282410 --- clang/lib/Format/TokenAnnotator.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 75eb137805b0..72d869782cea 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2015,7 +2015,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, 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 && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 6cffb3b238ee..bac2a5b7a913 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4802,6 +4802,7 @@ TEST_F(FormatTest, DeclarationsOfMultipleVariables) { verifyFormat("aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,\n" " *b = bbbbbbbbbbbbbbbbbbb, *d = ddddddddddddddddddd;", Style); + verifyFormat("vector a, b;", Style); } TEST_F(FormatTest, ConditionalExpressionsInBrackets) {