summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-05-17 08:13:23 +0000
committerDaniel Jasper <djasper@google.com>2015-05-17 08:13:23 +0000
commit0928553eecaa835b9983c8afbc8ee3948327a06c (patch)
tree12a21b58be381591c6c6e53f3841547562e3d5f1 /clang/lib/Format/ContinuationIndenter.cpp
parenta8200603d4eeb50a2b771bb0b32edcb4c2c01d04 (diff)
downloadbcm5719-llvm-0928553eecaa835b9983c8afbc8ee3948327a06c.tar.gz
bcm5719-llvm-0928553eecaa835b9983c8afbc8ee3948327a06c.zip
clang-format: Properly align ObjC string literals.
Before: NSString s = @"a" "b" "c"; NSString s = @"a" @"b" @"c"; After: NSString s = @"a" "b" "c"; NSString s = @"a" @"b" @"c"; This fixes llvm.org/PR23536. llvm-svn: 237538
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 720b6140b2f..3baebed5679 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -546,10 +546,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
if (Current.is(tok::identifier) && Current.Next &&
Current.Next->is(TT_DictLiteral))
return State.Stack.back().Indent;
- if ((NextNonComment->isStringLiteral() ||
- NextNonComment->is(TT_ObjCStringLiteral)) &&
- State.StartOfStringLiteral != 0)
+ if (NextNonComment->isStringLiteral() && State.StartOfStringLiteral != 0)
return State.StartOfStringLiteral;
+ if (NextNonComment->is(TT_ObjCStringLiteral) &&
+ State.StartOfStringLiteral != 0)
+ return State.StartOfStringLiteral - 1;
if (NextNonComment->is(tok::lessless) &&
State.Stack.back().FirstLessLess != 0)
return State.Stack.back().FirstLessLess;
@@ -702,13 +703,13 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
moveStatePastScopeCloser(State);
moveStatePastFakeRParens(State);
- if ((Current.isStringLiteral() || Current.is(TT_ObjCStringLiteral)) &&
- State.StartOfStringLiteral == 0) {
+ if (Current.isStringLiteral() && State.StartOfStringLiteral == 0)
State.StartOfStringLiteral = State.Column;
- } else if (!Current.isOneOf(tok::comment, tok::identifier, tok::hash) &&
- !Current.isStringLiteral()) {
+ if (Current.is(TT_ObjCStringLiteral) && State.StartOfStringLiteral == 0)
+ State.StartOfStringLiteral = State.Column + 1;
+ else if (!Current.isOneOf(tok::comment, tok::identifier, tok::hash) &&
+ !Current.isStringLiteral())
State.StartOfStringLiteral = 0;
- }
State.Column += Current.ColumnWidth;
State.NextToken = State.NextToken->Next;
OpenPOWER on IntegriCloud