diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2008-04-16 22:00:24 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-04-16 22:00:24 +0000 |
commit | 61d46159af2a740207de8dc024211d531ae290d9 (patch) | |
tree | 2bfa91250f8e27dcfa204b034c8a26f5bf81097e | |
parent | d9a3c330b02c52630014dc26fc009236facf8227 (diff) |
New AST class for property implementation declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49821 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/DeclBase.h | 1 | ||||
-rw-r--r-- | include/clang/AST/DeclObjC.h | 40 | ||||
-rw-r--r-- | lib/AST/Decl.cpp | 7 |
3 files changed, 48 insertions, 0 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 3575faaaf5..257ed25b9c 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -62,6 +62,7 @@ public: ObjCMethod, ObjCClass, ObjCForwardProtocol, + ObjCPropertyImpl, LinkageSpec, FileScopeAsm, diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 89261d9f53..80634fe760 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -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 diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index cee7ddad02..900096f1ec 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -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; } |