diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 688937c1e6aa..1d0cb30af845 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -212,6 +212,8 @@ void UnwrappedLineParser::parseStructuralElement() { return parseObjCInterface(); case tok::objc_protocol: return parseObjCProtocol(); + case tok::objc_end: + return; // Handled by the caller. default: break; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e06544a95f20..15fe9aa9d737 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1189,6 +1189,8 @@ TEST_F(FormatTest, FormatObjCInterface) { "@end"); verifyFormat("@interface Foo\n" + "@end\n" + "@interface Bar\n" "@end"); verifyFormat("@interface Foo : Bar\n" @@ -1262,6 +1264,11 @@ TEST_F(FormatTest, FormatObjCProtocol) { verifyFormat("@protocol Foo;\n" "@protocol Bar;\n"); + + verifyFormat("@protocol Foo\n" + "@end\n" + "@protocol Bar\n" + "@end"); } TEST_F(FormatTest, ObjCAt) {