From feeba61006e25b5bb2b7ad8a00d1fc087ca0c7d0 Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Thu, 29 Jun 2017 13:30:41 +0000 Subject: [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 --- clang/unittests/Format/FormatTestProto.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'clang/unittests/Format/FormatTestProto.cpp') diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index 0b052bd4c64..2e3b9311d12 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/unittests/Format/FormatTestProto.cpp @@ -201,6 +201,12 @@ TEST_F(FormatTestProto, FormatsOptions) { " field_c: \"OK\"\n" " msg_field{field_d: 123}\n" "};"); + verifyFormat("option (MyProto.options) = {\n" + " field_a: OK\n" + " field_b{field_c: OK}\n" + " field_d: OKOKOK\n" + " field_e: OK\n" + "}"); // Support syntax with <> instead of {}. verifyFormat("option (MyProto.options) = {\n" @@ -208,6 +214,13 @@ TEST_F(FormatTestProto, FormatsOptions) { " msg_field: \n" "};"); + verifyFormat("option (MyProto.options) = {\n" + " field_a: OK\n" + " field_b\n" + " field_d: OKOKOK\n" + " field_e: OK\n" + "}"); + verifyFormat("option (MyProto.options) = {\n" " msg_field: <>\n" " field_c: \"OK\",\n" -- cgit v1.2.3