[clang-format] Fixup a case of text proto message attributes

Summary: This patch fixes a case where a proto message attribute is wrongly identified as an text proto extension.

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D43465

llvm-svn: 325509
This commit is contained in:
Krasimir Georgiev 2018-02-19 15:31:25 +00:00
parent b040fcc693
commit 9b2aa42f00
2 changed files with 16 additions and 0 deletions

View File

@ -375,6 +375,10 @@ private:
// (aaa) = aaa
// ];
//
// extensions 123 [
// (aaa) = aaa
// ];
//
// or text proto extensions (in options):
//
// option (Aaa.options) = {
@ -394,6 +398,8 @@ private:
Left->Type = TT_ArrayInitializerLSquare;
if (!Left->endsSequence(tok::l_square, tok::numeric_constant,
tok::equal) &&
!Left->endsSequence(tok::l_square, tok::numeric_constant,
tok::identifier) &&
!Left->endsSequence(tok::l_square, tok::colon, TT_SelectorName)) {
Left->Type = TT_ProtoExtensionLSquare;
BindingIncrease = 10;

View File

@ -168,6 +168,16 @@ TEST_F(FormatTestProto, MessageFieldAttributes) {
" aaaaaaaaaaaaaaaa: true\n"
" }\n"
"];");
verifyFormat("extensions 20 [(proto2.type) = 'Aaaa.bbbb'];");
verifyFormat("extensions 20\n"
" [(proto3.type) = 'Aaaa.bbbb', (aaa.Aaa) = 'aaa.bbb'];");
verifyFormat("extensions 123 [\n"
" (aaa) = aaaa,\n"
" (bbbbbbbbbbbbbbbbbbbbbbbbbb) = {\n"
" aaaaaaaaaaaaaaaaa: true,\n"
" aaaaaaaaaaaaaaaa: true\n"
" }\n"
"];");
}
TEST_F(FormatTestProto, DoesntWrapFileOptions) {