Summary: Similar to TypeScript, "enum" is not a reserved word.
Reviewers: krasimir, MyDeveloperDay
Reviewed By: MyDeveloperDay
Subscribers: MyDeveloperDay, cfe-commits
Tags: #clang, #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59629
Patch by: dchai (Donald Chai)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356833
91177308-0d34-0410-b5e6-
96231b3b80d8
FormatTok->isOneOf(tok::colon, tok::question))
return false;
+ // In protobuf, "enum" can be used as a field name.
+ if (Style.Language == FormatStyle::LK_Proto && FormatTok->is(tok::equal))
+ return false;
+
// Eat up enum class ...
if (FormatTok->Tok.is(tok::kw_class) || FormatTok->Tok.is(tok::kw_struct))
nextToken();
"};");
}
+TEST_F(FormatTestProto, EnumAsFieldName) {
+ verifyFormat("message SomeMessage {\n"
+ " required int32 enum = 1;\n"
+ "}");
+}
+
TEST_F(FormatTestProto, UnderstandsReturns) {
verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
}