From 9c5ac63785b5aac0c85b57637409869b27983bfe Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Mon, 19 Feb 2018 16:00:21 +0000 Subject: [PATCH] [clang-format] Fix text proto extension scope opening detection Summary: This fixes the detection of scope openers in text proto extensions; previously they were not detected correctly leading to instances like: ``` msg { [aa.bb ] { key: value } } ``` Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43469 llvm-svn: 325513 --- clang/lib/Format/FormatToken.h | 1 + clang/unittests/Format/FormatTestTextProto.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 6a55887..550bdcc 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -478,6 +478,7 @@ struct FormatToken { if (is(TT_TemplateString) && opensScope()) return true; return is(TT_ArrayInitializerLSquare) || + is(TT_ProtoExtensionLSquare) || (is(tok::l_brace) && (BlockKind == BK_Block || is(TT_DictLiteral) || (!Style.Cpp11BracedListStyle && NestingLevel == 0))) || diff --git a/clang/unittests/Format/FormatTestTextProto.cpp b/clang/unittests/Format/FormatTestTextProto.cpp index 97326cf..17cde61 100644 --- a/clang/unittests/Format/FormatTestTextProto.cpp +++ b/clang/unittests/Format/FormatTestTextProto.cpp @@ -389,6 +389,14 @@ TEST_F(FormatTestTextProto, FormatsExtensions) { " keyyyyyyyyyyyyyy: valuuuuuuuuuuuuuuuuuuuuuuuuue\n" " }\n" "}"); + verifyFormat( + "aaaaaaaaaaaaaaa {\n" + " bbbbbb {\n" + " [a.b/cy] {\n" + " eeeeeeeeeeeee: \"The lazy coo cat jumps over the lazy hot dog\"\n" + " }\n" + " }\n" + "}"); } TEST_F(FormatTestTextProto, NoSpaceAfterPercent) { -- 2.7.4