diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-06-29 13:30:41 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-06-29 13:30:41 +0000 |
commit | feeba61006e25b5bb2b7ad8a00d1fc087ca0c7d0 (patch) | |
tree | 1d6eee54fd0c68f5b14e58f031cb43ffaa47f495 /clang/lib | |
parent | fe09f506b689b17693d2f3568301dc2e94d93bf3 (diff) | |
download | bcm5719-llvm-feeba61006e25b5bb2b7ad8a00d1fc087ca0c7d0.tar.gz bcm5719-llvm-feeba61006e25b5bb2b7ad8a00d1fc087ca0c7d0.zip |
[clang-format] Fix parsing of msg{field}-style proto options
Summary:
This patch makes the `{` in `msg_field{field: OK}` in a proto option scope be
treated as an assignment operator. Previosly the added test case was formatted
as:
```
option (MyProto.options) = {
field_a: OK
field_b{field_c: OK} field_d: OKOKOK field_e: OK
}
```
Reviewers: djasper
Reviewed By: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D34749
llvm-svn: 306672
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 767096b60ef..d78a37532fe 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1570,8 +1570,10 @@ private: const FormatToken *NextNonComment = Current->getNextNonComment(); if (Current->is(TT_ConditionalExpr)) return prec::Conditional; - if (NextNonComment && NextNonComment->is(tok::colon) && - NextNonComment->is(TT_DictLiteral)) + if (NextNonComment && Current->is(TT_SelectorName) && + (NextNonComment->is(TT_DictLiteral) || + (Style.Language == FormatStyle::LK_Proto && + NextNonComment->is(tok::less)))) return prec::Assignment; if (Current->is(TT_JsComputedPropertyName)) return prec::Assignment; |