aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-14 12:18:19 +0000
committerDaniel Jasper <djasper@google.com>2013-01-14 12:18:19 +0000
commit4abbb535f0f050aea6373e26e769643c3c61a9b1 (patch)
tree04f8486aa5de248a67d1149716d9cfd65a0da4ce /lib/Format/Format.cpp
parenta4ae9f30ef7bccdaa3feef8036af07fbb91f107c (diff)
Improve understanding post increment and decrement.
Before: (a->f()) ++; a[42] ++; After: (a->f())++; a[42]++; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172400 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r--lib/Format/Format.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 548bdee2b2..57e9a76989 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -1060,7 +1060,10 @@ private:
/// \brief Determine whether ++/-- are pre- or post-increments/-decrements.
TokenType determineIncrementUsage(const AnnotatedToken &Tok) {
- if (Tok.Parent != NULL && Tok.Parent->is(tok::identifier))
+ if (Tok.Parent == NULL)
+ return TT_UnaryOperator;
+ if (Tok.Parent->is(tok::r_paren) || Tok.Parent->is(tok::r_square) ||
+ Tok.Parent->is(tok::identifier))
return TT_TrailingUnaryOperator;
return TT_UnaryOperator;