Recognize < and > as binary expressions in builder-type calls.
The current heuristic assumes that there can't be binary operators in
builder-type calls (excluding assigments). However, it also excluded
< and > in general, which is wrong. Now they are only excluded if they
are template parameters.
Before:
return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa()i
.aaaaaa() < aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();
After:
return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() <
aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175291 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index faef560..2ddd257 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -467,11 +467,13 @@
KeywordVirtualFound = true;
if (CurrentToken->is(tok::period) || CurrentToken->is(tok::arrow))
++PeriodsAndArrows;
- if (getPrecedence(*CurrentToken) > prec::Assignment &&
- CurrentToken->isNot(tok::less) && CurrentToken->isNot(tok::greater))
- CanBeBuilderTypeStmt = false;
+ AnnotatedToken *TheToken = CurrentToken;
if (!consumeToken())
return LT_Invalid;
+ if (getPrecedence(*TheToken) > prec::Assignment &&
+ TheToken->Type != TT_TemplateOpener &&
+ TheToken->Type != TT_TemplateCloser)
+ CanBeBuilderTypeStmt = false;
}
if (KeywordVirtualFound)
return LT_VirtualFunctionDecl;