Summary: This fixes a glitch where ``operator: value`` in a text proto would mess up the underlying formatting since it gets parsed as a kw_operator instead of an identifier.
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D43830
llvm-svn: 326227
Tok->Type = TT_BinaryOperator;
break;
case tok::kw_operator:
+ if (Style.Language == FormatStyle::LK_TextProto ||
+ Style.Language == FormatStyle::LK_Proto)
+ break;
while (CurrentToken &&
!CurrentToken->isOneOf(tok::l_paren, tok::semi, tok::r_paren)) {
if (CurrentToken->isOneOf(tok::star, tok::amp))
"};");
}
+TEST_F(FormatTestProto, AcceptsOperatorAsKeyInOptions) {
+ verifyFormat("option (MyProto.options) = {\n"
+ " bbbbbbbbb: <\n"
+ " ccccccccccccccccccccccc: <\n"
+ " operator: 1\n"
+ " operator: 2\n"
+ " operator { key: value }\n"
+ " >\n"
+ " >\n"
+ "};");
+}
+
} // end namespace tooling
} // end namespace clang
Style.Cpp11BracedListStyle = true;
verifyFormat("keys: [1]", Style);
}
+
+TEST_F(FormatTestTextProto, AcceptsOperatorAsKey) {
+ verifyFormat("aaaaaaaaaaa: <\n"
+ " bbbbbbbbb: <\n"
+ " ccccccccccccccccccccccc: <\n"
+ " operator: 1\n"
+ " operator: 2\n"
+ " operator { key: value }\n"
+ " >\n"
+ " >\n"
+ ">");
+}
} // end namespace tooling
} // end namespace clang