summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp8
-rw-r--r--clang/unittests/Format/FormatTestProto.cpp6
2 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 97fd98ecb94..e705c98c67b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -811,9 +811,8 @@ void UnwrappedLineParser::parseStructuralElement() {
// parseEnum falls through and does not yet add an unwrapped line as an
// enum definition can start a structural element.
parseEnum();
- // This does not apply for Java and JavaScript.
- if (Style.Language == FormatStyle::LK_Java ||
- Style.Language == FormatStyle::LK_JavaScript) {
+ // This only applies for C++.
+ if (Style.Language != FormatStyle::LK_Cpp) {
addUnwrappedLine();
return;
}
@@ -1554,6 +1553,9 @@ void UnwrappedLineParser::parseEnum() {
// Java enums are different.
parseJavaEnumBody();
return;
+ } else if (Style.Language == FormatStyle::LK_Proto) {
+ parseBlock(/*MustBeDeclaration=*/true);
+ return;
}
// Parse enum body.
diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp
index 74f7005b219..0dadd3b6731 100644
--- a/clang/unittests/Format/FormatTestProto.cpp
+++ b/clang/unittests/Format/FormatTestProto.cpp
@@ -73,6 +73,12 @@ TEST_F(FormatTestProto, FormatsEnums) {
" TYPE_A = 1;\n"
" TYPE_B = 2;\n"
"};");
+ verifyFormat("enum Type {\n"
+ " UNKNOWN = 0 [(some_options) = {\n"
+ " a: aa,\n"
+ " b: bb\n"
+ " }];\n"
+ "};");
}
TEST_F(FormatTestProto, UnderstandsReturns) {
OpenPOWER on IntegriCloud