summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-15 20:33:06 +0000
committerDaniel Jasper <djasper@google.com>2013-02-15 20:33:06 +0000
commiteb50c676bac72a27bc47ece11a0880c2ab4503b5 (patch)
tree87102c19398ec018cd7eacb424215f2437852a57 /clang/lib
parentb7eec015d05c0494b20ed0d9faf86562a460f1f4 (diff)
downloadbcm5719-llvm-eb50c676bac72a27bc47ece11a0880c2ab4503b5.tar.gz
bcm5719-llvm-eb50c676bac72a27bc47ece11a0880c2ab4503b5.zip
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(); llvm-svn: 175291
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index faef560c898..2ddd2572dde 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -467,11 +467,13 @@ public:
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;
OpenPOWER on IntegriCloud