Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp =================================================================== --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -2018,6 +2018,10 @@ 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(); Index: cfe/trunk/unittests/Format/FormatTestProto.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTestProto.cpp +++ cfe/trunk/unittests/Format/FormatTestProto.cpp @@ -107,6 +107,12 @@ "};"); } +TEST_F(FormatTestProto, EnumAsFieldName) { + verifyFormat("message SomeMessage {\n" + " required int32 enum = 1;\n" + "}"); +} + TEST_F(FormatTestProto, UnderstandsReturns) { verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);"); }