aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-03-14 14:00:17 +0000
committerDaniel Jasper <djasper@google.com>2013-03-14 14:00:17 +0000
commitbfa1edd8247b80e951a570ff2486fe5fa9898c41 (patch)
treedc853dd2d64d313411f67f4f56f0f3ee8902c02b /lib
parent923ebef120a37122ce50722a85cbe42c0c2dab53 (diff)
Slightly improve formatting of longer pipe statements.
The stronger binding of a string ending in :/= does not really make sense if it is the only character. Before: llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << "=" << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; After: llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << "=" << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Format/TokenAnnotator.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index e878a9690c..8267a25d03 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -934,10 +934,11 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Right.is(tok::lessless)) {
if (Left.is(tok::string_literal)) {
- char LastChar =
- StringRef(Left.FormatTok.Tok.getLiteralData(),
- Left.FormatTok.TokenLength).drop_back(1).rtrim().back();
- if (LastChar == ':' || LastChar == '=')
+ StringRef Content = StringRef(Left.FormatTok.Tok.getLiteralData(),
+ Left.FormatTok.TokenLength);
+ Content = Content.drop_back(1).drop_front(1).trim();
+ if (Content.size() > 1 &&
+ (Content.back() == ':' || Content.back() == '='))
return 100;
}
return prec::Shift;