[cfe-commits] r54094 - in /cfe/trunk: include/clang/Parse/Action.h include/clang/Parse/Parser.h lib/Parse/MinimalAction.cpp lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp

Chris Lattner sabre at nondot.org
Fri Jul 25 21:13:19 PDT 2008


Author: lattner
Date: Fri Jul 25 23:13:19 2008
New Revision: 54094

URL: http://llvm.org/viewvc/llvm-project?rev=54094&view=rev
Log:
Pull protocol resolution of out ActOnStartClassInterface, this is also the 
last client of the old ParseObjCProtocolReferences, so it also removes it.

Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/MinimalAction.cpp
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=54094&r1=54093&r2=54094&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Fri Jul 25 23:13:19 2008
@@ -621,16 +621,15 @@
   // ActOnStartClassInterface - this action is called immediately after parsing
   // the prologue for a class interface (before parsing the instance 
   // variables). Instance variables are processed by ActOnFields().
-  virtual DeclTy *ActOnStartClassInterface(
-    SourceLocation AtInterafceLoc,
-    IdentifierInfo *ClassName, 
-    SourceLocation ClassLoc,
-    IdentifierInfo *SuperName, 
-    SourceLocation SuperLoc,
-    const IdentifierLocPair *ProtocolNames, 
-    unsigned NumProtocols,
-    SourceLocation EndProtoLoc,
-    AttributeList *AttrList) {
+  virtual DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
+                                           IdentifierInfo *ClassName, 
+                                           SourceLocation ClassLoc,
+                                           IdentifierInfo *SuperName, 
+                                           SourceLocation SuperLoc,
+                                           DeclTy * const *ProtoRefs, 
+                                           unsigned NumProtoRefs,
+                                           SourceLocation EndProtoLoc,
+                                           AttributeList *AttrList) {
     return 0;
   }
   
@@ -847,11 +846,14 @@
                                                unsigned NumElts);
   
   virtual DeclTy *ActOnStartClassInterface(SourceLocation interLoc,
-                    IdentifierInfo *ClassName, SourceLocation ClassLoc,
-                    IdentifierInfo *SuperName, SourceLocation SuperLoc,
-                    const IdentifierLocPair *ProtocolNames,
-                                           unsigned NumProtocols,
-                    SourceLocation EndProtoLoc, AttributeList *AttrList);
+                                           IdentifierInfo *ClassName,
+                                           SourceLocation ClassLoc,
+                                           IdentifierInfo *SuperName,
+                                           SourceLocation SuperLoc,
+                                           DeclTy * const *ProtoRefs, 
+                                           unsigned NumProtoRefs,
+                                           SourceLocation EndProtoLoc,
+                                           AttributeList *AttrList);
 };
 
 }  // end namespace clang

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=54094&r1=54093&r2=54094&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Jul 25 23:13:19 2008
@@ -326,8 +326,6 @@
                                           AttributeList *prefixAttrs = 0);
   void ParseObjCClassInstanceVariables(DeclTy *interfaceDecl, 
                                        SourceLocation atLoc);
-  bool ParseObjCProtocolReferences(llvm::SmallVectorImpl<IdentifierLocPair> &,
-                                   SourceLocation &endProtoLoc);
   bool ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclTy*> &P,
                                    bool WarnOnDeclarations, 
                                    SourceLocation &EndProtoLoc);

Modified: cfe/trunk/lib/Parse/MinimalAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/MinimalAction.cpp?rev=54094&r1=54093&r2=54094&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/MinimalAction.cpp (original)
+++ cfe/trunk/lib/Parse/MinimalAction.cpp Fri Jul 25 23:13:19 2008
@@ -89,11 +89,14 @@
 
 Action::DeclTy *
 MinimalAction::ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
-                    IdentifierInfo *ClassName, SourceLocation ClassLoc,
-                    IdentifierInfo *SuperName, SourceLocation SuperLoc,
-                    const IdentifierLocPair *ProtocolNames,
-                    unsigned NumProtocols,
-                    SourceLocation EndProtoLoc, AttributeList *AttrList) {
+                                        IdentifierInfo *ClassName,
+                                        SourceLocation ClassLoc,
+                                        IdentifierInfo *SuperName,
+                                        SourceLocation SuperLoc,
+                                        DeclTy * const *ProtoRefs,
+                                        unsigned NumProtocols,
+                                        SourceLocation EndProtoLoc,
+                                        AttributeList *AttrList) {
   TypeNameInfo *TI =
     new TypeNameInfo(1, ClassName->getFETokenInfo<TypeNameInfo>());
 

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=54094&r1=54093&r2=54094&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Jul 25 23:13:19 2008
@@ -186,16 +186,17 @@
     superClassLoc = ConsumeToken();
   }
   // Next, we need to check for any protocol references.
-  llvm::SmallVector<IdentifierLocPair, 8> ProtocolRefs;
-  SourceLocation endProtoLoc;
-  if (Tok.is(tok::less)) {
-    if (ParseObjCProtocolReferences(ProtocolRefs, endProtoLoc))
-      return 0;
-  }
-  DeclTy *ClsType = Actions.ActOnStartClassInterface(
-                      atLoc, nameId, nameLoc, 
-                      superClassId, superClassLoc, &ProtocolRefs[0], 
-                      ProtocolRefs.size(), endProtoLoc, attrList);
+  llvm::SmallVector<Action::DeclTy*, 8> ProtocolRefs;
+  SourceLocation EndProtoLoc;
+  if (Tok.is(tok::less) &&
+      ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc))
+    return 0;
+  
+  DeclTy *ClsType = 
+    Actions.ActOnStartClassInterface(atLoc, nameId, nameLoc, 
+                                     superClassId, superClassLoc,
+                                     &ProtocolRefs[0], ProtocolRefs.size(),
+                                     EndProtoLoc, attrList);
             
   if (Tok.is(tok::l_brace))
     ParseObjCClassInstanceVariables(ClsType, atLoc);
@@ -717,40 +718,6 @@
 ///     '<' identifier-list '>'
 ///
 bool Parser::
-ParseObjCProtocolReferences(llvm::SmallVectorImpl<IdentifierLocPair> &Protocols,
-                            SourceLocation &endLoc) {
-  assert(Tok.is(tok::less) && "expected <");
-  
-  ConsumeToken(); // the "<"
-  
-  while (1) {
-    if (Tok.isNot(tok::identifier)) {
-      Diag(Tok, diag::err_expected_ident);
-      SkipUntil(tok::greater);
-      return true;
-    }
-    Protocols.push_back(std::make_pair(Tok.getIdentifierInfo(),
-                                          Tok.getLocation()));
-    ConsumeToken();
-    
-    if (Tok.isNot(tok::comma))
-      break;
-    ConsumeToken();
-  }
-  
-  // Consume the '>'.
-  if (Tok.is(tok::greater)) {
-    endLoc = ConsumeAnyToken();
-    return false;
-  }
-  Diag(Tok, diag::err_expected_greater);
-  return true;
-}
-
-///   objc-protocol-refs:
-///     '<' identifier-list '>'
-///
-bool Parser::
 ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclTy*> &Protocols,
                             bool WarnOnDeclarations, SourceLocation &EndLoc) {
   assert(Tok.is(tok::less) && "expected <");

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=54094&r1=54093&r2=54094&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Jul 25 23:13:19 2008
@@ -605,13 +605,15 @@
   
 
   // Objective-C declarations.
-  virtual DeclTy *ActOnStartClassInterface(
-                    SourceLocation AtInterafceLoc,
-                    IdentifierInfo *ClassName, SourceLocation ClassLoc,
-                    IdentifierInfo *SuperName, SourceLocation SuperLoc,
-                    const IdentifierLocPair *ProtocolNames,
-                    unsigned NumProtocols,
-                    SourceLocation EndProtoLoc, AttributeList *AttrList);
+  virtual DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
+                                           IdentifierInfo *ClassName,
+                                           SourceLocation ClassLoc,
+                                           IdentifierInfo *SuperName,
+                                           SourceLocation SuperLoc,
+                                           DeclTy * const *ProtoRefs,
+                                           unsigned NumProtoRefs,
+                                           SourceLocation EndProtoLoc,
+                                           AttributeList *AttrList);
   
   virtual DeclTy *ActOnCompatiblityAlias(
                     SourceLocation AtCompatibilityAliasLoc,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=54094&r1=54093&r2=54094&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jul 25 23:13:19 2008
@@ -75,8 +75,7 @@
 ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
                          IdentifierInfo *ClassName, SourceLocation ClassLoc,
                          IdentifierInfo *SuperName, SourceLocation SuperLoc,
-                         const IdentifierLocPair *ProtocolNames,
-                         unsigned NumProtocols,
+                         DeclTy * const *ProtoRefs, unsigned NumProtoRefs,
                          SourceLocation EndProtoLoc, AttributeList *AttrList) {
   assert(ClassName && "Missing class identifier");
   
@@ -134,22 +133,8 @@
   }
   
   /// Check then save referenced protocols
-  if (NumProtocols) {
-    llvm::SmallVector<ObjCProtocolDecl*, 8> RefProtos;
-    for (unsigned int i = 0; i != NumProtocols; i++) {
-      ObjCProtocolDecl* RefPDecl = ObjCProtocols[ProtocolNames[i].first];
-      if (!RefPDecl)
-        Diag(ProtocolNames[i].second, diag::err_undeclared_protocol,
-             ProtocolNames[i].first->getName());
-      else {
-        if (RefPDecl->isForwardDecl())
-          Diag(ProtocolNames[i].second, diag::warn_undef_protocolref,
-               ProtocolNames[i].first->getName());
-        RefProtos.push_back(RefPDecl);
-      }
-    }
-    if (!RefProtos.empty())
-      IDecl->addReferencedProtocols(&RefProtos[0], RefProtos.size());
+  if (NumProtoRefs) {
+    IDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs);
     IDecl->setLocEnd(EndProtoLoc);
   }
   return IDecl;





More information about the cfe-commits mailing list