summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-01-14 09:53:07 +0000
committerDaniel Jasper <djasper@google.com>2014-01-14 09:53:07 +0000
commitd07c2ee99eb547f82dcf72fb95899be8297712bb (patch)
tree0dbc6c5ffee98da795ffe9008242149aaa90d0a7 /clang/lib
parent23c0ab53b29335347cf53a835fb322c710da9162 (diff)
downloadbcm5719-llvm-d07c2ee99eb547f82dcf72fb95899be8297712bb.tar.gz
bcm5719-llvm-d07c2ee99eb547f82dcf72fb95899be8297712bb.zip
clang-format: Fix bug introduced in r198871.
We cannot simply change the start column to accomodate for the @ in an ObjC string literal as that will make clang-format happily violate the column limit. Use a different workaround instead. However, a better long-term solution might be to join the @ and the rest of the literal into a single token. llvm-svn: 199198
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/BreakableToken.cpp9
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp1
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index 8ca97d37a27..03693c62bb4 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -172,9 +172,16 @@ BreakableStringLiteral::getSplit(unsigned LineIndex, unsigned TailOffset,
void BreakableStringLiteral::insertBreak(unsigned LineIndex,
unsigned TailOffset, Split Split,
WhitespaceManager &Whitespaces) {
+ unsigned LeadingSpaces = StartColumn;
+ // The '@' of an ObjC string literal (@"Test") does not become part of the
+ // string token.
+ // FIXME: It might be a cleaner solution to merge the tokens as a
+ // precomputation step.
+ if (Prefix.startswith("@"))
+ --LeadingSpaces;
Whitespaces.replaceWhitespaceInToken(
Tok, Prefix.size() + TailOffset + Split.first, Split.second, Postfix,
- Prefix, InPPDirective, 1, IndentLevel, StartColumn);
+ Prefix, InPPDirective, 1, IndentLevel, LeadingSpaces);
}
static StringRef getLineCommentPrefix(StringRef Comment) {
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index aaedceb31e8..30c066fedee 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -811,7 +811,6 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
Current.Previous->is(tok::at)) {
IsNSStringLiteral = true;
Prefix = "@\"";
- --StartColumn;
}
if ((Text.endswith(Postfix = "\"") &&
(IsNSStringLiteral || Text.startswith(Prefix = "\"") ||
OpenPOWER on IntegriCloud