[cfe-commits] r42473 - in /cfe/trunk: Parse/ParseObjc.cpp Sema/SemaDecl.cpp include/clang/AST/Decl.h

Fariborz Jahanian fjahanian at apple.com
Sat Sep 29 11:24:59 PDT 2007


Author: fjahanian
Date: Sat Sep 29 13:24:58 2007
New Revision: 42473

URL: http://llvm.org/viewvc/llvm-project?rev=42473&view=rev
Log:
This patch fixes all issues mentioned in clattner's feedback of 
September 28, 2007 4:39:24 PM PDT
Please let me know if I missed anything.

Modified:
    cfe/trunk/Parse/ParseObjc.cpp
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/include/clang/AST/Decl.h

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

==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Sat Sep 29 13:24:58 2007
@@ -270,7 +270,6 @@
   /// Insert collected methods declarations into the @interface object.
   Actions.ObjcAddMethodsToClass(CurScope,
 				interfaceDecl,&allMethods[0],allMethods.size());
-  return;
 }
 
 ///   Parse property attribute declarations.

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

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sat Sep 29 13:24:58 2007
@@ -1678,12 +1678,11 @@
   QualType resultDeclType = QualType::getFromOpaquePtr(ReturnType);
   ObjcMethodDecl* ObjcMethod =  new ObjcMethodDecl(MethodLoc, Sel,
                                       resultDeclType, 0, -1, AttrList, 
-                                      MethodType == tok::minus);
+                                      MethodType == tok::minus,
+				      MethodDeclKind == tok::objc_optional ? 
+				      ObjcMethodDecl::Optional : 
+				      ObjcMethodDecl::Required);
   ObjcMethod->setMethodParams(&Params[0], Sel.getNumArgs());
-  if (MethodDeclKind == tok::objc_optional)
-    ObjcMethod->setDeclImplementation(ObjcMethodDecl::Optional);
-  else
-    ObjcMethod->setDeclImplementation(ObjcMethodDecl::Required);
   return ObjcMethod;
 }
 

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

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Sep 29 13:24:58 2007
@@ -56,6 +56,9 @@
     IDNS_Protocol,
     IDNS_Ordinary
   };
+  
+  enum ImplementationControl { None, Required, Optional };
+  
 private:
   /// DeclKind - This indicates which class this is.
   Kind DeclKind   :  8;
@@ -63,10 +66,22 @@
   /// InvalidDecl - This indicates a semantic error occurred.
   unsigned int InvalidDecl :  1;
 
+  /// instance (true) or class (false) method.
+  bool IsInstance : 1;
+  /// @required/@optional
+  ImplementationControl DeclImplementation : 2;
+  
 protected:
-  Decl(Kind DK) : DeclKind(DK), InvalidDecl(0) {
+  Decl(Kind DK) : DeclKind(DK), InvalidDecl(0), 
+  IsInstance(false), DeclImplementation(None) {
     if (Decl::CollectingStats()) addDeclKind(DK);
   }
+  
+  Decl(Kind DK, bool isInstance, ImplementationControl implControl) 
+  : DeclKind(DK), InvalidDecl(0), 
+  IsInstance(isInstance), DeclImplementation(implControl) {
+    if (Decl::CollectingStats()) addDeclKind(DK);
+  }  
   virtual ~Decl();
   
 public:
@@ -78,7 +93,10 @@
   /// allows for graceful error recovery.
   void setInvalidDecl() { InvalidDecl = 1; }
   int isInvalidDecl() const { return InvalidDecl; }
-  
+  bool isInstance() const { return IsInstance; }
+  ImplementationControl  getImplementationControl() const
+  { return DeclImplementation; }
+
   IdentifierNamespace getIdentifierNamespace() const {
     switch (DeclKind) {
     default: assert(0 && "Unknown decl kind!");
@@ -551,20 +569,20 @@
   ObjcInterfaceDecl *SuperClass;
   
   /// Protocols referenced in interface header declaration
-  ObjcProtocolDecl **IntfRefProtocols;  // Null if none
-  int NumIntfRefProtocols;  // -1 if none
+  ObjcProtocolDecl **IntfRefProtocols;  // Null if no referenced protocols
+  int NumIntfRefProtocols;  // -1 if no referenced protocols
   
   /// Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
-  ObjcIvarDecl **Ivars;   // Null if not defined.
-  int NumIvars;   // -1 if not defined.
+  ObjcIvarDecl **Ivars;   // Null if class has no ivars
+  int NumIvars;   // -1 if class has no ivars
   
   /// instance methods
-  ObjcMethodDecl **InsMethods;  // Null if not defined
-  int NumInsMethods;  // -1 if not defined
+  ObjcMethodDecl **InsMethods;  // Null if class has no instance methods
+  int NumInsMethods;  // -1 if class has no instance methods
   
   /// class methods
-  ObjcMethodDecl **ClsMethods;  // Null if not defined
-  int NumClsMethods;  // -1 if not defined
+  ObjcMethodDecl **ClsMethods;  // Null if class has no class methods
+  int NumClsMethods;  // -1 if class has no class methods
   
   /// List of categories defined for this class.
   ObjcCategoryDecl *ListCategories;
@@ -675,8 +693,6 @@
 /// ObjcMethodDecl - An instance of this class is created to represent an instance
 /// or class method declaration.
 class ObjcMethodDecl : public Decl {
-public:
-  enum ImplementationControl { None, Required, Optional };
 private:
   // A unigue name for this method.
   Selector SelName;
@@ -694,19 +710,16 @@
   /// Loc - location of this declaration.
   SourceLocation Loc;
 
-  /// instance (true) or class (false) method.
-  bool IsInstance : 1;
-  /// @required/@optional
-  ImplementationControl DeclImplementation : 2;
-
 public:
   ObjcMethodDecl(SourceLocation L, Selector SelInfo, QualType T,
 		 ParmVarDecl **paramInfo = 0, int numParams=-1,
-		 AttributeList *M = 0, bool isInstance = true, 
+		 AttributeList *M = 0, bool isInstance = true,
+                 ImplementationControl impControl = None,
 		 Decl *PrevDecl = 0)
-    : Decl(ObjcMethod), SelName(SelInfo), MethodDeclType(T), 
+    : Decl(ObjcMethod, isInstance, impControl), 
+      SelName(SelInfo), MethodDeclType(T), 
       ParamInfo(paramInfo), NumMethodParams(numParams),
-      MethodAttrs(M), Loc(L), IsInstance(isInstance) {}
+      MethodAttrs(M), Loc(L) {}
 #if 0
   ObjcMethodDecl(Kind DK, SourceLocation L, IdentifierInfo &SelId, QualType T,
 		 ParmVarDecl **paramInfo = 0, int numParams=-1,
@@ -728,13 +741,7 @@
 
   AttributeList *getMethodAttrs() const {return MethodAttrs;}
   SourceLocation getLocation() const { return Loc; }
-  bool isInstance() const { return IsInstance; }
-  // Related to protocols declared in  @protocol
-  void setDeclImplementation(ImplementationControl ic)
-         { DeclImplementation = ic; }
-  ImplementationControl  getImplementationControl() const
-                           { return DeclImplementation; }
-  
+    
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { 
     return D->getKind() == ObjcMethod 





More information about the cfe-commits mailing list