]> granicus.if.org Git - clang/commitdiff
New AST class for property implementation declarations.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Apr 2008 22:00:24 +0000 (22:00 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Apr 2008 22:00:24 +0000 (22:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49821 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
include/clang/AST/DeclObjC.h
lib/AST/Decl.cpp

index 3575faaaf512b18dbcd3182df57b9f2606e7e63d..257ed25b9c272a2e04eac7dc38f355c0441cdffc 100644 (file)
@@ -62,6 +62,7 @@ public:
          ObjCMethod,
          ObjCClass,
          ObjCForwardProtocol,
+         ObjCPropertyImpl,
          LinkageSpec,
    FileScopeAsm,
   
index 89261d9f5378a23fb9f1d56120e50df7ab14e269..80634fe760147805797e1aa1a57297e0b18e47b6 100644 (file)
@@ -999,5 +999,45 @@ public:
   static bool classof(const ObjCPropertyDecl *D) { return true; }
 };
 
+/// ObjCPropertyImplDecl - Represents implementation declaration of a property 
+/// in a class or category implementation block. For example:
+/// @synthesize prop1 = ivar1;
+///
+class ObjCPropertyImplDecl : public Decl {
+public:
+  enum PropertyImplKind {
+    OBJC_PR_IMPL_None,
+    OBJC_PR_IMPL_SYNTHSIZE,
+    OBJC_PR_IMPL_DYNAMIC
+  };
+private:
+  /// Property declaration being implemented
+  ObjCPropertyDecl *PropertyDecl;
+  PropertyImplKind PropertyImplementation;
+  /// Null for @dynamic. Required for @synthesize.
+  ObjCIvarDecl *PropertyIvarDecl;
+public:
+  ObjCPropertyImplDecl(SourceLocation L)
+  : Decl(ObjCPropertyImpl, L), PropertyDecl(0), 
+  PropertyImplementation(OBJC_PR_IMPL_None), PropertyIvarDecl(0) {}
+
+  void setPropertyDecl(ObjCPropertyDecl *property) { PropertyDecl = property; }
+  ObjCPropertyDecl *getPropertyDecl() const { return PropertyDecl; }
+  
+  void setImplKind (PropertyImplKind propImplKind) 
+    { PropertyImplementation = propImplKind; }
+  PropertyImplKind getPropertyImplementation() const 
+    { return PropertyImplementation; }
+  
+  void setPropertyIvarDecl(ObjCIvarDecl *ivarDecl) 
+    { PropertyIvarDecl = ivarDecl; }
+  ObjCIvarDecl *getPropertyIvarDecl() { return PropertyIvarDecl; }
+  
+  static bool classof(const Decl *D) {
+    return D->getKind() == ObjCPropertyImpl;
+  }
+  static bool classof(const ObjCPropertyImplDecl *D) { return true; }  
+};
+
 }  // end namespace clang
 #endif
index cee7ddad02277d442e5c8ad6798cfd6a1cc4b1a5..900096f1eccc18adcff0e0fd98d26c148636efce 100644 (file)
@@ -42,6 +42,7 @@ static unsigned nObjCImplementationDecls = 0;
 static unsigned nObjCCategoryImpl = 0;
 static unsigned nObjCCompatibleAlias = 0;
 static unsigned nObjCPropertyDecl = 0;
+static unsigned nObjCPropertyImplDecl = 0;
 static unsigned nLinkageSpecDecl = 0;
 static unsigned nFileScopeAsmDecl = 0;
 
@@ -146,6 +147,10 @@ void Decl::PrintStats() {
           nObjCPropertyDecl, (int)sizeof(ObjCPropertyDecl),
           int(nObjCPropertyDecl*sizeof(ObjCPropertyDecl)));
   
+  fprintf(stderr, "    %d property implementation decls, %d each (%d bytes)\n", 
+          nObjCPropertyImplDecl, (int)sizeof(ObjCPropertyImplDecl),
+          int(nObjCPropertyImplDecl*sizeof(ObjCPropertyImplDecl)));
+  
   fprintf(stderr, "Total bytes = %d\n", 
           int(nFuncs*sizeof(FunctionDecl)+
               nVars*sizeof(VarDecl)+nParmVars*sizeof(ParmVarDecl)+
@@ -163,6 +168,7 @@ void Decl::PrintStats() {
               nObjCCategoryImpl*sizeof(ObjCCategoryImplDecl)+
               nObjCCompatibleAlias*sizeof(ObjCCompatibleAliasDecl)+
               nObjCPropertyDecl*sizeof(ObjCPropertyDecl)+
+              nObjCPropertyImplDecl*sizeof(ObjCPropertyImplDecl)+
               nLinkageSpecDecl*sizeof(LinkageSpecDecl)+
               nFileScopeAsmDecl*sizeof(FileScopeAsmDecl)));
     
@@ -189,6 +195,7 @@ void Decl::addDeclKind(Kind k) {
   case ObjCCategoryImpl:    nObjCCategoryImpl++; break;
   case ObjCCompatibleAlias: nObjCCompatibleAlias++; break;
   case ObjCProperty:        nObjCPropertyDecl++; break;
+  case ObjCPropertyImpl:    nObjCPropertyImplDecl++; break;
   case LinkageSpec:         nLinkageSpecDecl++; break;
   case FileScopeAsm:        nFileScopeAsmDecl++; break;
   }