diff options
author | Daniel Jasper <djasper@google.com> | 2013-11-09 03:08:25 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-11-09 03:08:25 +0000 |
commit | 279430585a45ba40b01519ca8ac41987b2b42660 (patch) | |
tree | 6552bf35761d879d70d8ef4edb53df72e4115310 | |
parent | d1c58ed8a7d51ee476b0b1638fa3a8bb8b0b445a (diff) | |
download | bcm5719-llvm-279430585a45ba40b01519ca8ac41987b2b42660.tar.gz bcm5719-llvm-279430585a45ba40b01519ca8ac41987b2b42660.zip |
clang-format: Fix alignment of ObjC string literals.
This used to interfere with AlwaysBreakBeforeMultilineStrings.
This fixes llvm.org/PR17856.
llvm-svn: 194310
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 1f6c8693d68..4e1417cf4df 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 e37f0cd4eb9..d02fb3405c7 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) { |