summaryrefslogtreecommitdiffstats
path: root/lib/Format
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-06-29 13:30:41 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-06-29 13:30:41 +0000
commit1747f04c528f04f9daa2d77885cc3c27d2553674 (patch)
treead450c96f20b717b31cc77d6b382fca40e29a277 /lib/Format
parentba2af70d9cfaddc5b8c2fa6e2a55387025b8f3ee (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format')
-rw-r--r--lib/Format/TokenAnnotator.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 767096b60e..d78a37532f 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/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;