From 49c77b2e702b02a0fbac7b817ccb73e7c128f9d9 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 18 Oct 2013 16:47:55 +0000 Subject: [PATCH] clang-format: Don't force linebreak between return and multiline string. This looks ugly and leads to llvm.org/PR17590. Before (with AlwaysBreakBeforeMultilineStrings): return "aaaa" "bbbb"; After: return "aaaa" "bbbb"; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192984 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 4 ++-- unittests/Format/FormatTest.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index b0bd13b69a..0cf9e32ea8 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -133,8 +133,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { return true; if (Style.AlwaysBreakBeforeMultilineStrings && State.Column > State.Stack.back().Indent && // Breaking saves columns. - Previous.isNot(tok::lessless) && Previous.Type != TT_InlineASMColon && - NextIsMultilineString(State)) + !Previous.isOneOf(tok::kw_return, tok::lessless) && + Previous.Type != TT_InlineASMColon && NextIsMultilineString(State)) return true; if (!Style.BreakBeforeBinaryOperators) { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 15d05f5575..6bcf44c4e8 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5590,6 +5590,12 @@ TEST_F(FormatTest, BreakStringLiterals) { "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaaaaaaaa\");", getGoogleStyle())); + EXPECT_EQ("return \"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaa \"\n" + " \"aaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa\";", + format("return \"aaaaaaaaaaaaaaaaaaaaaa " + "aaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaa " + "aaaaaaaaaaaaaaaaaaaaaa\";", + getGoogleStyle())); EXPECT_EQ("llvm::outs() << \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \"\n" " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\";", format("llvm::outs() << " -- 2.40.0