commit a9a40931315ceb670ee897f576fd0fdc50ffc887
Author: Grant Paul <git@grantpaul.com>
Date:   Mon Mar 30 23:30:42 2015 -0700

    Allow trailing comma in Objective-C protocol lists.
    
    This is useful when conditionally conforming to protocols. For
    example, consider:
    
        @inteface MyView : UIView <
          UITableViewDelegate,
        #ifdef IN_APP_EXTENSION
          UIGestureRecognizerDelegate,
        #endif
        #ifdef OPTIONAL_FEATURE
          UITextFieldDelegate,
        #endif
        >
    
        @end
    
    Without this patch, there's no clean way to write that because the
    protocol list is not allowed to have a trailing comma. With this
    patch, the trailing comma is simply ignored as it is, for example,
    in inside Objective-C array and dictionary literals.

diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index a597a16..636a017 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -1159,7 +1159,7 @@ ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &Protocols,
 
   SmallVector<IdentifierLocPair, 8> ProtocolIdents;
 
-  while (1) {
+  while (Tok.isNot(tok::greater)) {
     if (Tok.is(tok::code_completion)) {
       Actions.CodeCompleteObjCProtocolReferences(ProtocolIdents.data(), 
                                                  ProtocolIdents.size());
diff --git a/test/Parser/objc-interfaces.m b/test/Parser/objc-interfaces.m
index 0ae17f1..7436148 100644
--- a/test/Parser/objc-interfaces.m
+++ b/test/Parser/objc-interfaces.m
@@ -6,3 +6,12 @@
 - (int*) foo2  __attribute__((deprecated)) : (int) x1 __attribute__((deprecated)); // expected-error {{expected ';' after method prototype}} expected-error {{method type specifier must start with '-' or '+'}}
 @end
 
+@protocol P
+@end
+
+@protocol Q
+@end
+
+@interface TrailingComma <P,Q,>
+@end
+
