diff options
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 8 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 168b59e8ee4..9e4600b430d 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1030,7 +1030,13 @@ void UnwrappedLineParser::parseObjCUntilAtEnd() { addUnwrappedLine(); break; } - parseStructuralElement(); + if (FormatTok->is(tok::l_brace)) { + parseBlock(/*MustBeDeclaration=*/false); + // In ObjC interfaces, nothing should be following the "}". + addUnwrappedLine(); + } else { + parseStructuralElement(); + } } while (!eof()); } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 274d6e0064b..24ba93f1b98 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4791,6 +4791,10 @@ TEST_F(FormatTest, FormatObjCImplementation) { verifyFormat("@implementation Foo (HackStuff)\n" "+ (id)init {\n}\n" "@end"); + verifyFormat("@implementation ObjcClass\n" + "- (void)method;\n" + "{}\n" + "@end"); } TEST_F(FormatTest, FormatObjCProtocol) { |