]> granicus.if.org Git - clang/commitdiff
refactor protocol resolution out of ActOnStartCategoryInterface
authorChris Lattner <sabre@nondot.org>
Sat, 26 Jul 2008 04:07:02 +0000 (04:07 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 26 Jul 2008 04:07:02 +0000 (04:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54093 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Action.h
lib/Parse/ParseObjc.cpp
lib/Sema/Sema.h
lib/Sema/SemaDeclObjC.cpp

index 7ffbbfaf9c1e5ca9263f30eea4a443752213195f..d2a653d23953526c2acb47483c5dc17ad56e2696 100644 (file)
@@ -648,22 +648,21 @@ public:
   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
index 1bfc2a949bed51b9139d1c376ed1e1d92dbe5558..cabb5bf69a53c42784faed4d4a9c9f8ada262e53 100644 (file)
@@ -131,7 +131,6 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration(
     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 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration(
       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);
 
index 777200651056f03c75d71500cf3d3662c7692bd0..9584dcc468712f748895faa4c99b82947f2d90f1 100644 (file)
@@ -624,13 +624,14 @@ public:
                     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,
index 5bafa236fb001c869d42cad9404bde3b445b5a67..570437d071e43c5bef1a2d0d619ca4e614e1cd6d 100644 (file)
@@ -402,7 +402,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
                             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 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
   }
 
   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;
 }