From a7856d021a1f318f9319c0a3028f0d76e38b6ca1 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Sat, 9 Nov 2013 03:08:25 +0000 Subject: [PATCH] clang-format: Fix alignment of ObjC string literals. This used to interfere with AlwaysBreakBeforeMultilineStrings. This fixes llvm.org/PR17856. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194310 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 2 +- unittests/Format/FormatTest.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 1f6c8693d6..4e1417cf4d 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -135,7 +135,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { return true; if (Style.AlwaysBreakBeforeMultilineStrings && State.Column > State.Stack.back().Indent && // Breaking saves columns. - !Previous.isOneOf(tok::kw_return, tok::lessless) && + !Previous.isOneOf(tok::kw_return, tok::lessless, tok::at) && Previous.Type != TT_InlineASMColon && NextIsMultilineString(State)) return true; if (((Previous.Type == TT_DictLiteral && Previous.is(tok::l_brace)) || diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index e37f0cd4eb..d02fb3405c 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3636,6 +3636,13 @@ TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) { "b\\\n" "c\";", Break)); + + // Exempt ObjC strings for now. + EXPECT_EQ("NSString *const kString = @\"aaaa\"\n" + " \"bbbb\";", + format("NSString *const kString = @\"aaaa\"\n" + "\"bbbb\";", + Break)); } TEST_F(FormatTest, AlignsPipes) { -- 2.40.0