From 279430585a45ba40b01519ca8ac41987b2b42660 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. llvm-svn: 194310 --- clang/lib/Format/ContinuationIndenter.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 1f6c8693d683..4e1417cf4dfa 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e37f0cd4eb90..d02fb3405c7d 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) {