Formatter: Make parseObjCUntilAtEnd() actually work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172003 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 688937c..1d0cb30 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -212,6 +212,8 @@
       return parseObjCInterface();
     case tok::objc_protocol:
       return parseObjCProtocol();
+    case tok::objc_end:
+      return; // Handled by the caller.
     default:
       break;
     }
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index e06544a..15fe9aa 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1189,6 +1189,8 @@
                "@end");
 
   verifyFormat("@interface Foo\n"
+               "@end\n"
+               "@interface Bar\n"
                "@end");
 
   verifyFormat("@interface Foo : Bar\n"
@@ -1262,6 +1264,11 @@
 
   verifyFormat("@protocol Foo;\n"
                "@protocol Bar;\n");
+
+  verifyFormat("@protocol Foo\n"
+               "@end\n"
+               "@protocol Bar\n"
+               "@end");
 }
 
 TEST_F(FormatTest, ObjCAt) {