From 07ac853f86d69ffa61de3249e5d45e08accd5355 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 7 Jul 2015 16:09:39 +0000 Subject: [PATCH] clang-format: Break after "for (" less eagerly. Before: for ( auto aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb; ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) { After: for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb; ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) { git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241601 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 3 ++- unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index a3691570cd..7664e530fb 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1706,7 +1706,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Left.is(tok::l_paren) && InFunctionDecl && Style.AlignAfterOpenBracket) return 100; - if (Left.is(tok::l_paren) && Left.Previous && Left.Previous->is(tok::kw_if)) + if (Left.is(tok::l_paren) && Left.Previous && + Left.Previous->isOneOf(tok::kw_if, tok::kw_for)) return 1000; if (Left.is(tok::equal) && InFunctionDecl) return 110; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 5e9c3ebcb2..c9f63cef66 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -516,6 +516,10 @@ TEST_F(FormatTest, FormatsForLoop) { " aaaaaaaaaa);\n" " iter; ++iter) {\n" "}"); + verifyFormat("for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb;\n" + " ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) {"); FormatStyle NoBinPacking = getLLVMStyle(); NoBinPacking.BinPackParameters = false; -- 2.40.0