From bfa1edd8247b80e951a570ff2486fe5fa9898c41 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 14 Mar 2013 14:00:17 +0000 Subject: 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 --- lib/Format/TokenAnnotator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/Format') 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; -- cgit v1.2.3-18-g5258