[cfe-commits] r42311 - in /cfe/trunk: AST/Decl.cpp Parse/MinimalAction.cpp Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaDecl.cpp clang.xcodeproj/project.pbxproj include/clang/AST/ASTContext.h include/clang/AST/Decl.h include/clang/Basic/DiagnosticKinds.def include/clang/Parse/Action.h test/Sema/class-def-test-1.m test/Sema/class-impl-1.m

Fariborz Jahanian fjahanian at apple.com
Tue Sep 25 11:38:09 PDT 2007


Author: fjahanian
Date: Tue Sep 25 13:38:09 2007
New Revision: 42311

URL: http://llvm.org/viewvc/llvm-project?rev=42311&view=rev
Log:
This patch introduces a new class to keep track of class implementation info. It also adds more 
semantic checks for class and protocol declarations. Test cases are good indications of kind of 
checking being done in this patch.


Added:
    cfe/trunk/test/Sema/class-def-test-1.m
    cfe/trunk/test/Sema/class-impl-1.m
Modified:
    cfe/trunk/AST/Decl.cpp
    cfe/trunk/Parse/MinimalAction.cpp
    cfe/trunk/Parse/ParseObjc.cpp
    cfe/trunk/Sema/Sema.h
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/include/clang/Parse/Action.h

Modified: cfe/trunk/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=42311&r1=42310&r2=42311&view=diff

==============================================================================
--- cfe/trunk/AST/Decl.cpp (original)
+++ cfe/trunk/AST/Decl.cpp Tue Sep 25 13:38:09 2007
@@ -32,6 +32,7 @@
 static unsigned nForwardProtocolDecls = 0;
 static unsigned nCategoryDecls = 0;
 static unsigned nIvarDecls = 0;
+static unsigned nObjcImplementationDecls = 0;
 
 static bool StatSwitch = false;
 
@@ -132,6 +133,10 @@
 	  nCategoryDecls, (int)sizeof(ObjcCategoryDecl),
 	  int(nCategoryDecls*sizeof(ObjcCategoryDecl)));
 
+  fprintf(stderr, "    %d class implementation decls, %d each (%d bytes)\n", 
+	  nObjcImplementationDecls, (int)sizeof(ObjcImplementationDecl),
+	  int(nObjcImplementationDecls*sizeof(ObjcImplementationDecl)));
+
   fprintf(stderr, "Total bytes = %d\n", 
 	  int(nFuncs*sizeof(FunctionDecl)+nBlockVars*sizeof(BlockVarDecl)+
 	      nFileVars*sizeof(FileVarDecl)+nParmVars*sizeof(ParmVarDecl)+
@@ -193,6 +198,9 @@
     case ObjcIvar:
       nIvarDecls++;
       break;
+    case ObjcImplementation: 
+      nObjcImplementationDecls++;
+      break;
   }
 }
 

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

==============================================================================
--- cfe/trunk/Parse/MinimalAction.cpp (original)
+++ cfe/trunk/Parse/MinimalAction.cpp Tue Sep 25 13:38:09 2007
@@ -68,7 +68,7 @@
 }
 
 Action::DeclTy *
-MinimalAction::ObjcStartClassInterface(SourceLocation AtInterafceLoc,
+MinimalAction::ObjcStartClassInterface(Scope* S, SourceLocation AtInterafceLoc,
                     IdentifierInfo *ClassName, SourceLocation ClassLoc,
                     IdentifierInfo *SuperName, SourceLocation SuperLoc,
                     IdentifierInfo **ProtocolNames, unsigned NumProtocols,
@@ -81,7 +81,8 @@
 }
 
 Action::DeclTy *
-MinimalAction::ObjcStartProtoInterface(SourceLocation AtProtoInterfaceLoc,
+MinimalAction::ObjcStartProtoInterface(Scope* S,
+		 SourceLocation AtProtoInterfaceLoc,
                  IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
                  IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) {
   

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

==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Tue Sep 25 13:38:09 2007
@@ -189,7 +189,8 @@
     if (ParseObjCProtocolReferences(ProtocolRefs))
       return 0;
   }
-  DeclTy *ClsType = Actions.ObjcStartClassInterface(atLoc, nameId, nameLoc, 
+  DeclTy *ClsType = Actions.ObjcStartClassInterface(CurScope,
+		      atLoc, nameId, nameLoc, 
                       superClassId, superClassLoc, &ProtocolRefs[0], 
                       ProtocolRefs.size(), attrList);
             
@@ -749,7 +750,7 @@
       return 0;
   }
   
-  DeclTy *ProtoType = Actions.ObjcStartProtoInterface(AtLoc, 
+  DeclTy *ProtoType = Actions.ObjcStartProtoInterface(CurScope, AtLoc, 
                                 protocolName, nameLoc,
                                 &ProtocolRefs[0],
                                 ProtocolRefs.size());
@@ -786,6 +787,7 @@
     return 0;
   }
   // We have a class or category name - consume it.
+  IdentifierInfo *nameId = Tok.getIdentifierInfo();
   SourceLocation nameLoc = ConsumeToken(); // consume class or category name
   
   if (Tok.getKind() == tok::l_paren) { 
@@ -810,6 +812,8 @@
     return 0;
   }
   // We have a class implementation
+  SourceLocation superClassLoc;
+  IdentifierInfo *superClassId = 0;
   if (Tok.getKind() == tok::colon) {
     // We have a super class
     ConsumeToken();
@@ -817,10 +821,16 @@
       Diag(Tok, diag::err_expected_ident); // missing super class name.
       return 0;
     }
-    ConsumeToken(); // Consume super class name
+    superClassId = Tok.getIdentifierInfo();
+    superClassLoc = ConsumeToken(); // Consume super class name
   }
+  DeclTy *ImplClsType = Actions.ObjcStartClassImplementation(CurScope,
+				  atLoc, 
+                                  nameId, nameLoc,
+                                  superClassId, superClassLoc);
+  
   if (Tok.getKind() == tok::l_brace)
-    ParseObjCClassInstanceVariables(0/*FIXME*/); // we have ivars
+    ParseObjCClassInstanceVariables(ImplClsType/*FIXME*/); // we have ivars
   
   return 0;
 }

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

==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Tue Sep 25 13:38:09 2007
@@ -352,13 +352,15 @@
                                                SourceLocation RParenLoc);
   
   // Objective-C declarations.
-  virtual DeclTy *ObjcStartClassInterface(SourceLocation AtInterafceLoc,
+  virtual DeclTy *ObjcStartClassInterface(Scope* S,
+		    SourceLocation AtInterafceLoc,
                     IdentifierInfo *ClassName, SourceLocation ClassLoc,
                     IdentifierInfo *SuperName, SourceLocation SuperLoc,
                     IdentifierInfo **ProtocolNames, unsigned NumProtocols,
                     AttributeList *AttrList);
                     
-  virtual DeclTy *ObjcStartProtoInterface(SourceLocation AtProtoInterfaceLoc,
+  virtual DeclTy *ObjcStartProtoInterface(Scope* S,
+		    SourceLocation AtProtoInterfaceLoc,
                     IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
                     IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs);
   
@@ -367,6 +369,12 @@
                     IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
                     IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs);
   
+  virtual DeclTy *ObjcStartClassImplementation(Scope* S,
+		    SourceLocation AtClassImplLoc,
+                    IdentifierInfo *ClassName, SourceLocation ClassLoc,
+                    IdentifierInfo *SuperClassname, 
+                    SourceLocation SuperClassLoc);
+  
   virtual DeclTy *ObjcClassDeclaration(Scope *S, SourceLocation AtClassLoc,
                                        IdentifierInfo **IdentList,
                                        unsigned NumElts);

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42311&r1=42310&r2=42311&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Tue Sep 25 13:38:09 2007
@@ -862,13 +862,24 @@
   return NewTD;
 }
 
-Sema::DeclTy *Sema::ObjcStartClassInterface(SourceLocation AtInterfaceLoc,
+Sema::DeclTy *Sema::ObjcStartClassInterface(Scope* S,
+                    SourceLocation AtInterfaceLoc,
                     IdentifierInfo *ClassName, SourceLocation ClassLoc,
                     IdentifierInfo *SuperName, SourceLocation SuperLoc,
                     IdentifierInfo **ProtocolNames, unsigned NumProtocols,
                     AttributeList *AttrList) {
   assert(ClassName && "Missing class identifier");
-   
+  
+  // Check for another declaration kind with the same name.
+  ScopedDecl *PrevDecl = LookupScopedDecl(ClassName, Decl::IDNS_Ordinary,
+                                          ClassLoc, S);
+  if (PrevDecl && !isa<ObjcInterfaceDecl>(PrevDecl)
+      && !isa<ObjcProtocolDecl>(PrevDecl)) {
+    Diag(ClassLoc, diag::err_redefinition_different_kind,
+         ClassName->getName());
+    Diag(PrevDecl->getLocation(), diag::err_previous_definition);
+  }
+  
   ObjcInterfaceDecl* IDecl = Context.getObjCInterfaceDecl(ClassName);
   
   if (IDecl) {
@@ -889,15 +900,26 @@
   }
   
   if (SuperName) {
-    ObjcInterfaceDecl* SuperClassEntry = 
-                         Context.getObjCInterfaceDecl(SuperName);
+    ObjcInterfaceDecl* SuperClassEntry = 0;
+    // Check if a different kind of symbol declared in this scope.
+    PrevDecl = LookupScopedDecl(SuperName, Decl::IDNS_Ordinary,
+                                SuperLoc, S);
+    if (PrevDecl && !isa<ObjcInterfaceDecl>(PrevDecl)
+        && !isa<ObjcProtocolDecl>(PrevDecl)) {
+      Diag(SuperLoc, diag::err_redefinition_different_kind,
+           SuperName->getName());
+      Diag(PrevDecl->getLocation(), diag::err_previous_definition);
+    }
+    else {
+      // Check that super class is previously defined
+      SuperClassEntry = Context.getObjCInterfaceDecl(SuperName);
                               
-    if (!SuperClassEntry || SuperClassEntry->getIsForwardDecl()) {
-      Diag(AtInterfaceLoc, diag::err_undef_superclass, SuperName->getName(),
-           ClassName->getName());  
+      if (!SuperClassEntry || SuperClassEntry->getIsForwardDecl()) {
+        Diag(AtInterfaceLoc, diag::err_undef_superclass, SuperName->getName(),
+             ClassName->getName()); 
+      }
     }
-    else
-      IDecl->setSuperClass(SuperClassEntry);
+    IDecl->setSuperClass(SuperClassEntry);
   }
   
   /// Check then save referenced protocols
@@ -916,7 +938,8 @@
   return IDecl;
 }
 
-Sema::DeclTy *Sema::ObjcStartProtoInterface(SourceLocation AtProtoInterfaceLoc,
+Sema::DeclTy *Sema::ObjcStartProtoInterface(Scope* S,
+		SourceLocation AtProtoInterfaceLoc,
                 IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
                 IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) {
   assert(ProtocolName && "Missing protocol identifier");
@@ -1032,6 +1055,72 @@
   return CDecl;
 }
 
+Sema::DeclTy *Sema::ObjcStartClassImplementation(Scope *S,
+                      SourceLocation AtClassImplLoc,
+                      IdentifierInfo *ClassName, SourceLocation ClassLoc,
+                      IdentifierInfo *SuperClassname, 
+                      SourceLocation SuperClassLoc) {
+  ObjcInterfaceDecl* IDecl = 0;
+  // Check for another declaration kind with the same name.
+  ScopedDecl *PrevDecl = LookupScopedDecl(ClassName, Decl::IDNS_Ordinary,
+                                          ClassLoc, S);
+  if (PrevDecl && !isa<ObjcInterfaceDecl>(PrevDecl)) {
+    Diag(ClassLoc, diag::err_redefinition_different_kind,
+         ClassName->getName());
+    Diag(PrevDecl->getLocation(), diag::err_previous_definition);
+  }
+  else {
+    // Is there an interface declaration of this class; if not, warn!
+    IDecl = Context.getObjCInterfaceDecl(ClassName);
+    if (!IDecl)
+      Diag(ClassLoc, diag::warn_undef_interface, ClassName->getName());
+  }
+  
+  // Check that super class name is valid class name
+  ObjcInterfaceDecl* SDecl = 0;
+  if (SuperClassname) {
+    // Check if a different kind of symbol declared in this scope.
+    PrevDecl = LookupScopedDecl(SuperClassname, Decl::IDNS_Ordinary,
+                                SuperClassLoc, S);
+    if (PrevDecl && !isa<ObjcInterfaceDecl>(PrevDecl)
+        && !isa<ObjcProtocolDecl>(PrevDecl)) {
+      Diag(SuperClassLoc, diag::err_redefinition_different_kind,
+           SuperClassname->getName());
+      Diag(PrevDecl->getLocation(), diag::err_previous_definition);
+    }
+    else {
+      SDecl = Context.getObjCInterfaceDecl(SuperClassname);
+      if (!SDecl)
+        Diag(SuperClassLoc, diag::err_undef_superclass, 
+             SuperClassname->getName(), ClassName->getName());
+      else if (IDecl && IDecl->getSuperClass() != SDecl) {
+        // This implementation and its interface do not have the same
+        // super class.
+        Diag(SuperClassLoc, diag::err_conflicting_super_class, 
+             SuperClassname->getName());
+        Diag(SDecl->getLocation(), diag::err_previous_definition);
+      }
+    }
+  }
+  
+  ObjcImplementationDecl* IMPDecl = 
+    new ObjcImplementationDecl(AtClassImplLoc, ClassName, SDecl);
+  
+  // Check that there is no duplicate implementation of this class.
+  bool err = false;
+  for (unsigned i = 0; i != Context.sizeObjcImplementationClass(); i++) {
+    if (Context.getObjcImplementationClass(i)->getIdentifier() == ClassName) {
+      Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName());
+      err = true;
+      break;
+    }
+  }
+  if (!err)     
+    Context.setObjcImplementationClass(IMPDecl);
+      
+  return IMPDecl;
+}
+
 /// ObjcClassDeclaration - 
 /// Scope will always be top level file scope. 
 Action::DeclTy *
@@ -1204,7 +1293,8 @@
   
   if (isa<RecordDecl>(static_cast<Decl *>(TagDecl)))
     NewFD = new FieldDecl(Loc, II, T);
-  else if (isa<ObjcInterfaceDecl>(static_cast<Decl *>(TagDecl)))
+  else if (isa<ObjcInterfaceDecl>(static_cast<Decl *>(TagDecl))
+	   || isa<ObjcImplementationDecl>(static_cast<Decl *>(TagDecl)))
     NewFD = new ObjcIvarDecl(Loc, II, T);
   else
     assert(0 && "Sema::ActOnField(): Unknown TagDecl");

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=42311&r1=42310&r2=42311&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Tue Sep 25 13:38:09 2007
@@ -725,6 +725,7 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
 			projectDirPath = "";

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=42311&r1=42310&r2=42311&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Sep 25 13:38:09 2007
@@ -39,6 +39,7 @@
   llvm::DenseMap<const RecordDecl*, const RecordLayout*> RecordLayoutInfo;
   llvm::DenseMap<const IdentifierInfo*, ObjcInterfaceDecl*> ClassNameInfo;
   llvm::DenseMap<const IdentifierInfo*, ObjcProtocolDecl*> ProtocolNameInfo;
+  llvm::SmallVector<ObjcImplementationDecl*, 8> ImplementationClassInfo;
   RecordDecl *CFConstantStringTypeDecl;
 public:
   
@@ -172,6 +173,16 @@
                             ObjcProtocolDecl* ProtocolDecl)
   { ProtocolNameInfo[ProtocolName] = ProtocolDecl; }
   
+  ObjcImplementationDecl* getObjcImplementationClass(unsigned ix) {
+    return ImplementationClassInfo[ix];
+  }
+  void setObjcImplementationClass(ObjcImplementationDecl* ImplDecl) {
+    ImplementationClassInfo.push_back(ImplDecl);
+  }
+  unsigned sizeObjcImplementationClass() const {
+    return ImplementationClassInfo.size();
+  }
+  
   //===--------------------------------------------------------------------===//
   //                            Type Operators
   //===--------------------------------------------------------------------===//

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=42311&r1=42310&r2=42311&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Sep 25 13:38:09 2007
@@ -29,7 +29,6 @@
 class ObjcProtocolDecl;
 class ObjcCategoryDecl;
 
-
 /// Decl - This represents one declaration (or definition), e.g. a variable, 
 /// typedef, function, struct, etc.  
 ///
@@ -41,6 +40,7 @@
     // Concrete sub-classes of TypeDecl
     Typedef, Struct, Union, Class, Enum, ObjcInterface, ObjcClass, ObjcMethod,
     ObjcProtoMethod, ObjcProtocol, ObjcForwardProtocol, ObjcCategory,
+    ObjcImplementation,
     // Concrete sub-class of Decl
     Field, ObjcIvar
   };
@@ -86,6 +86,7 @@
     case ParmVariable:
     case EnumConstant:
     case ObjcInterface:
+    case ObjcProtocol:
       return IDNS_Ordinary;
     case Struct:
     case Union:
@@ -856,6 +857,49 @@
   }
   static bool classof(const ObjcCategoryDecl *D) { return true; }
 };
+  
+class ObjcImplementationDecl : public ScopedDecl {
+    
+  /// Implementation Class's super class.
+  ObjcInterfaceDecl *SuperClass;
+    
+  /// Optional Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
+  ObjcIvarDecl **Ivars;   // Null if not specified
+  int NumIvars;   // -1 if not defined.
+    
+  /// implemented instance methods
+  ObjcMethodDecl **InsMethods;  // Null if not defined
+  int NumInsMethods;  // -1 if not defined
+    
+  /// implemented class methods
+  ObjcMethodDecl **ClsMethods;  // Null if not defined
+  int NumClsMethods;  // -1 if not defined
+    
+  public:
+  ObjcImplementationDecl(SourceLocation L, IdentifierInfo *Id,
+                         ObjcInterfaceDecl* superDecl)
+    : ScopedDecl(ObjcImplementation, L, Id, 0),
+      SuperClass(superDecl),
+      Ivars(0), NumIvars(-1),
+      InsMethods(0), NumInsMethods(-1), ClsMethods(0), NumClsMethods(-1) {}
+  
+  void ObjcAddInstanceVariablesToClass(ObjcIvarDecl **ivars, 
+                                       unsigned numIvars);
+    
+  void ObjcAddMethods(ObjcMethodDecl **insMethods, unsigned numInsMembers,
+                        ObjcMethodDecl **clsMethods, unsigned numClsMembers);
+    
+  ObjcInterfaceDecl *getImplSuperClass() const { return SuperClass; }
+  
+  void setImplSuperClass(ObjcInterfaceDecl * superCls) 
+         { SuperClass = superCls; }
+    
+  static bool classof(const Decl *D) {
+    return D->getKind() == ObjcImplementation;
+  }
+  static bool classof(const ObjcImplementationDecl *D) { return true; }
+};
+  
 
 }  // end namespace clang
 #endif

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=42311&r1=42310&r2=42311&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Tue Sep 25 13:38:09 2007
@@ -420,6 +420,12 @@
      "cannot find interface declaration for '%0'")
 DIAG(err_dup_category_def, ERROR,
      "duplicate interface declaration for category '%0(%1)'")
+DIAG(warn_undef_interface, WARNING,
+     "cannot find interface declaration for '%0'")
+DIAG(err_dup_implementation_class, ERROR,
+     "reimplementation of class '%0'")
+DIAG(err_conflicting_super_class, ERROR,
+     "conflicting super class name '%0'")
 
 //===----------------------------------------------------------------------===//
 // Semantic Analysis

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue Sep 25 13:38:09 2007
@@ -437,7 +437,7 @@
   }
   //===----------------------- Obj-C Declarations -------------------------===//
   
-  virtual DeclTy *ObjcStartClassInterface(SourceLocation AtInterafceLoc,
+  virtual DeclTy *ObjcStartClassInterface(Scope* S, SourceLocation AtInterafceLoc,
                     IdentifierInfo *ClassName, SourceLocation ClassLoc,
                     IdentifierInfo *SuperName, SourceLocation SuperLoc,
                     IdentifierInfo **ProtocolNames, unsigned NumProtocols,
@@ -448,7 +448,8 @@
 				     DeclTy **allMethods, unsigned allNum) {
     return;
   }
-  virtual DeclTy *ObjcStartProtoInterface(SourceLocation AtProtoInterfaceLoc,
+  virtual DeclTy *ObjcStartProtoInterface(Scope* S,
+		    SourceLocation AtProtoInterfaceLoc,
                     IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
                     IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) {
     return 0;
@@ -459,6 +460,13 @@
                     IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) {
     return 0;
   }
+  virtual DeclTy *ObjcStartClassImplementation(Scope* S,
+		    SourceLocation AtClassImplLoc,
+                    IdentifierInfo *ClassName, SourceLocation ClassLoc,
+                    IdentifierInfo *SuperClassname, 
+                    SourceLocation SuperClassLoc) {
+    return 0;
+  }
   virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc, 
     tok::TokenKind MethodType, TypeTy *ReturnType,
     ObjcKeywordDecl *Keywords, unsigned NumKeywords, 
@@ -561,12 +569,13 @@
                                                  IdentifierInfo **IdentList,
                                                  unsigned NumElts);
    
-  virtual DeclTy *ObjcStartClassInterface(SourceLocation AtInterafceLoc,
+  virtual DeclTy *ObjcStartClassInterface(Scope* S, SourceLocation AtInterafceLoc,
                     IdentifierInfo *ClassName, SourceLocation ClassLoc,
                     IdentifierInfo *SuperName, SourceLocation SuperLoc,
                     IdentifierInfo **ProtocolNames, unsigned NumProtocols,
                     AttributeList *AttrList);
-  virtual DeclTy *ObjcStartProtoInterface(SourceLocation AtProtoInterfaceLoc,
+  virtual DeclTy *ObjcStartProtoInterface(Scope *S,
+		    SourceLocation AtProtoInterfaceLoc,
                     IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
                     IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs);
 };

Added: cfe/trunk/test/Sema/class-def-test-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/class-def-test-1.m?rev=42311&view=auto

==============================================================================
--- cfe/trunk/test/Sema/class-def-test-1.m (added)
+++ cfe/trunk/test/Sema/class-def-test-1.m Tue Sep 25 13:38:09 2007
@@ -0,0 +1,23 @@
+ at protocol SUPER;
+
+ at interface SUPER <SUPER> @end // expected-error {{cannot find protocol definition for 'SUPER', referenced by 'SUPER'}}
+
+typedef int INTF; //  expected-error {{previou sdefinition is here}}
+
+ at interface INTF @end // expected-error {{redefinition of 'INTF' as different kind of symbol}}
+
+ at interface OBJECT @end
+
+ at interface INTF1 : OBJECT @end
+
+ at interface INTF1 : OBJECT @end // expected-error {{duplicate interface declaration for class 'INTF1'}
+
+typedef int OBJECT; // expected-error {{previous definition is here}}
+
+ at interface INTF2 : OBJECT @end // expected-error {{redefinition of 'OBJECT' as different kind of symbol}}
+
+
+ at protocol PROTO;
+
+ at interface INTF3 : PROTO @end // expected-error {{cannot find interface declaration for 'PROTO', superclass of 'INTF3'}}
+

Added: cfe/trunk/test/Sema/class-impl-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/class-impl-1.m?rev=42311&view=auto

==============================================================================
--- cfe/trunk/test/Sema/class-impl-1.m (added)
+++ cfe/trunk/test/Sema/class-impl-1.m Tue Sep 25 13:38:09 2007
@@ -0,0 +1,31 @@
+typedef int INTF3; // expected-error {{previous definition is here}}
+
+ at interface SUPER @end // expected-error {{previous definition is here}}
+
+ at interface OBJECT @end
+
+ at interface INTF  : OBJECT
+ at end
+
+ at implementation INTF @end 
+
+ at implementation INTF //  expected-error {{reimplementation of class 'INTF'}}
+ at end
+
+
+ at interface INTF1 : OBJECT
+ at end
+
+ at implementation INTF1 : SUPER // expected-error {{conflicting super class name 'SUPER'}}
+ at end
+
+ at interface INTF2 
+ at end
+
+ at implementation INTF2 : SUPR //  expected-error {{cannot find interface declaration for 'SUPR', superclass of 'INTF2'}}
+ at end
+
+ at implementation INTF3 @end // expected-error {{redefinition of 'INTF3' as different kind of symbol}}
+
+ at implementation INTF4 @end // expected-warning {{cannot find interface declaration for 'INTF4'}}
+





More information about the cfe-commits mailing list