clang-format: Fix alignment of ObjC string literals.

This used to interfere with AlwaysBreakBeforeMultilineStrings.

This fixes llvm.org/PR17856.

llvm-svn: 194310
This commit is contained in:
Daniel Jasper 2013-11-09 03:08:25 +00:00
parent d1c58ed8a7
commit 279430585a
2 changed files with 8 additions and 1 deletions

View File

@ -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)) ||

View File

@ -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) {