aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-03-01 16:48:32 +0000
committerDaniel Jasper <djasper@google.com>2013-03-01 16:48:32 +0000
commit248497199bc56e86d1c089beb9529f3b3d77abb1 (patch)
tree35f0149d2f7f52b1d7dec0cb24f55b2ae675ee98 /lib/Format/TokenAnnotator.cpp
parent812c045e591495b940f5a9102b146bb43b970e1f (diff)
Normal indent for last element of builder-type call.
In builder type call, we indent to the laster function calls. However, for the last element of such a call, we don't need to do so, as that normally just wastes space and does not increase readability. Before: aaaaaa->aaaaaa->aaaaaa( // break aaaaaa); aaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaa ->aaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: aaaaaa->aaaaaa->aaaaaa( // break aaaaaa); aaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176352 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/TokenAnnotator.cpp')
-rw-r--r--lib/Format/TokenAnnotator.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index b9e35126ec..125619ccf6 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -464,6 +464,7 @@ private:
public:
LineType parseLine() {
int PeriodsAndArrows = 0;
+ AnnotatedToken *LastPeriodOrArrow = NULL;
bool CanBeBuilderTypeStmt = true;
if (CurrentToken->is(tok::hash)) {
parsePreprocessorDirective();
@@ -472,8 +473,10 @@ public:
while (CurrentToken != NULL) {
if (CurrentToken->is(tok::kw_virtual))
KeywordVirtualFound = true;
- if (CurrentToken->is(tok::period) || CurrentToken->is(tok::arrow))
+ if (CurrentToken->is(tok::period) || CurrentToken->is(tok::arrow)) {
++PeriodsAndArrows;
+ LastPeriodOrArrow = CurrentToken;
+ }
AnnotatedToken *TheToken = CurrentToken;
if (!consumeToken())
return LT_Invalid;
@@ -485,8 +488,10 @@ public:
return LT_VirtualFunctionDecl;
// Assume a builder-type call if there are 2 or more "." and "->".
- if (PeriodsAndArrows >= 2 && CanBeBuilderTypeStmt)
+ if (PeriodsAndArrows >= 2 && CanBeBuilderTypeStmt) {
+ LastPeriodOrArrow->LastInChainOfCalls = true;
return LT_BuilderTypeCall;
+ }
if (Line.First.Type == TT_ObjCMethodSpecifier) {
if (Contexts.back().FirstObjCSelectorName != NULL)
@@ -934,7 +939,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Level != prec::Unknown)
return Level;
-
+
return 3;
}