diff options
author | Daniel Jasper <djasper@google.com> | 2014-04-14 11:08:45 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-04-14 11:08:45 +0000 |
commit | c0d606a584596039532a3770c5c65529bc18d47e (patch) | |
tree | f44278657f318d1ba341cf1b816f1ace4f8dcc34 /clang/lib/Format/TokenAnnotator.cpp | |
parent | f694ab1f18df8beaec81fcabf7edf4818f7ffbac (diff) | |
download | bcm5719-llvm-c0d606a584596039532a3770c5c65529bc18d47e.tar.gz bcm5719-llvm-c0d606a584596039532a3770c5c65529bc18d47e.zip |
clang-format: Don't allow hanging indentation for operators on new lines
Before:
if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap
== cccccccccccccc) ...
After:
if (aaaaaaaa
&& bbbbbbbbbbbbbbb // need to wrap
== cccccccccccccc) ...
The same rule has already be implemented for BreakBeforeBinaryOperators
set to false in r205527.
llvm-svn: 206159
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 016deecd9ed..b81bf91c78b 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -735,6 +735,8 @@ private: Current.Type = determineIncrementUsage(Current); } else if (Current.is(tok::exclaim)) { Current.Type = TT_UnaryOperator; + } else if (Current.is(tok::question)) { + Current.Type = TT_ConditionalExpr; } else if (Current.isBinaryOperator() && (!Current.Previous || Current.Previous->isNot(tok::l_square))) { @@ -858,6 +860,7 @@ private: tok::comma, tok::semi, tok::kw_return, tok::colon, tok::equal, tok::kw_delete, tok::kw_sizeof) || PrevToken->Type == TT_BinaryOperator || + PrevToken->Type == TT_ConditionalExpr || PrevToken->Type == TT_UnaryOperator || PrevToken->Type == TT_CastRParen) return TT_UnaryOperator; @@ -1494,7 +1497,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Tok.getPrecedence() == prec::Assignment) return false; if ((Tok.Type == TT_BinaryOperator && !Tok.Previous->is(tok::l_paren)) || - Tok.Previous->Type == TT_BinaryOperator) + Tok.Previous->Type == TT_BinaryOperator || + Tok.Previous->Type == TT_ConditionalExpr) return true; if (Tok.Previous->Type == TT_TemplateCloser && Tok.is(tok::l_paren)) return false; |