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

Chris Lattner sabre at nondot.org
Fri Jul 25 21:07:02 PDT 2008


Author: lattner
Date: Fri Jul 25 23:07:02 2008
New Revision: 54093

URL: http://llvm.org/viewvc/llvm-project?rev=54093&view=rev
Log:
refactor protocol resolution out of ActOnStartCategoryInterface

Modified:
    cfe/trunk/include/clang/Parse/Action.h
    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=54093&r1=54092&r2=54093&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Fri Jul 25 23:07:02 2008
@@ -648,22 +648,21 @@
   virtual DeclTy *ActOnStartProtocolInterface(SourceLocation AtProtoLoc,
                                               IdentifierInfo *ProtocolName, 
                                               SourceLocation ProtocolLoc,
-                                              DeclTy * const *ProtoRefNames,
+                                              DeclTy * const *ProtoRefs,
                                               unsigned NumProtoRefs,
                                               SourceLocation EndProtoLoc) {
     return 0;
   }
   // ActOnStartCategoryInterface - this action is called immdiately after
   // parsing the prologue for a category interface.
-  virtual DeclTy *ActOnStartCategoryInterface(
-    SourceLocation AtInterfaceLoc,
-    IdentifierInfo *ClassName, 
-    SourceLocation ClassLoc,
-    IdentifierInfo *CategoryName, 
-    SourceLocation CategoryLoc,
-    const IdentifierLocPair *ProtoRefNames, 
-    unsigned NumProtoRefs,
-    SourceLocation EndProtoLoc) {
+  virtual DeclTy *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
+                                              IdentifierInfo *ClassName, 
+                                              SourceLocation ClassLoc,
+                                              IdentifierInfo *CategoryName, 
+                                              SourceLocation CategoryLoc,
+                                              DeclTy * const *ProtoRefs,
+                                              unsigned NumProtoRefs,
+                                              SourceLocation EndProtoLoc) {
     return 0;
   }
   // ActOnStartClassImplementation - this action is called immdiately after

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Jul 25 23:07:02 2008
@@ -131,7 +131,6 @@
     SourceLocation lparenLoc = ConsumeParen();
     SourceLocation categoryLoc, rparenLoc;
     IdentifierInfo *categoryId = 0;
-    llvm::SmallVector<IdentifierLocPair, 8> ProtocolRefs;
     
     // For ObjC2, the category name is optional (not an error).
     if (Tok.is(tok::identifier)) {
@@ -147,19 +146,21 @@
       return 0;
     }
     rparenLoc = ConsumeParen();
-    SourceLocation endProtoLoc;
+    
     // Next, we need to check for any protocol references.
-    if (Tok.is(tok::less)) {
-      if (ParseObjCProtocolReferences(ProtocolRefs, endProtoLoc))
-        return 0;
-    }
+    SourceLocation EndProtoLoc;
+    llvm::SmallVector<DeclTy *, 8> ProtocolRefs;
+    if (Tok.is(tok::less) &&
+        ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc))
+      return 0;
+    
     if (attrList) // categories don't support attributes.
       Diag(Tok, diag::err_objc_no_attributes_on_category);
     
     DeclTy *CategoryType = Actions.ActOnStartCategoryInterface(atLoc, 
                                      nameId, nameLoc, categoryId, categoryLoc,
                                      &ProtocolRefs[0], ProtocolRefs.size(),
-                                     endProtoLoc);
+                                     EndProtoLoc);
     
     ParseObjCInterfaceDeclList(CategoryType, tok::objc_not_keyword);
 

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Jul 25 23:07:02 2008
@@ -624,13 +624,14 @@
                     DeclTy * const *ProtoRefNames, unsigned NumProtoRefs,
                     SourceLocation EndProtoLoc);
   
-  virtual DeclTy *ActOnStartCategoryInterface(
-                    SourceLocation AtInterfaceLoc,
-                    IdentifierInfo *ClassName, SourceLocation ClassLoc,
-                    IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
-                    const IdentifierLocPair *ProtoRefNames,
-                    unsigned NumProtoRefs,
-                    SourceLocation EndProtoLoc);
+  virtual DeclTy *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
+                                              IdentifierInfo *ClassName,
+                                              SourceLocation ClassLoc,
+                                              IdentifierInfo *CategoryName,
+                                              SourceLocation CategoryLoc,
+                                              DeclTy * const *ProtoRefs,
+                                              unsigned NumProtoRefs,
+                                              SourceLocation EndProtoLoc);
   
   virtual DeclTy *ActOnStartClassImplementation(
                     SourceLocation AtClassImplLoc,

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jul 25 23:07:02 2008
@@ -402,7 +402,7 @@
                             IdentifierInfo *ClassName, SourceLocation ClassLoc,
                             IdentifierInfo *CategoryName,
                             SourceLocation CategoryLoc,
-                            const IdentifierLocPair *ProtoRefNames,
+                            DeclTy * const *ProtoRefs,
                             unsigned NumProtoRefs,
                             SourceLocation EndProtoLoc) {
   ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
@@ -430,24 +430,9 @@
   }
 
   if (NumProtoRefs) {
-    llvm::SmallVector<ObjCProtocolDecl*, 32> RefProtocols;
-    /// Check and then save the referenced protocols.
-    for (unsigned int i = 0; i != NumProtoRefs; i++) {
-      ObjCProtocolDecl* RefPDecl = ObjCProtocols[ProtoRefNames[i].first];
-      if (!RefPDecl)
-        Diag(ProtoRefNames[i].second, diag::err_undeclared_protocol,
-             ProtoRefNames[i].first->getName());
-      else {
-        if (RefPDecl->isForwardDecl())
-          Diag(ProtoRefNames[i].second, diag::warn_undef_protocolref,
-               ProtoRefNames[i].first->getName());
-        RefProtocols.push_back(RefPDecl);
-      }
-    }
-    if (!RefProtocols.empty())
-      CDecl->addReferencedProtocols(&RefProtocols[0], RefProtocols.size());
+    CDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs);
+    CDecl->setLocEnd(EndProtoLoc);
   }
-  CDecl->setLocEnd(EndProtoLoc);
   return CDecl;
 }
 





More information about the cfe-commits mailing list