diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-04-27 17:18:58 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-04-27 17:18:58 +0000 |
commit | 786cd154f2a48d2b464679d33fcd5df0cd794c06 (patch) | |
tree | 0511ce027010113499156a8e94e13cdaafb31f05 | |
parent | 0237941e0beb0c929934b66ad29443b484d987fe (diff) |
Move CollectIvarsToConstructOrDestruct to Sema
from AST, consider ivar array of objects
(per Doug's comment).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102446 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/ASTContext.h | 3 | ||||
-rw-r--r-- | lib/AST/ASTContext.cpp | 49 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 6 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 52 |
4 files changed, 58 insertions, 52 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index b4aa03daaa..f8a8f179ae 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -957,9 +957,6 @@ public: llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars); void CollectNonClassIvars(const ObjCInterfaceDecl *OI, llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars); - void CollectIvarsToConstructOrDestruct(const ObjCInterfaceDecl *OI, - llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars, - bool construct=true); unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI); void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols); diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 0a39575c43..91fafbabc2 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -807,55 +807,6 @@ void ASTContext::CollectInheritedProtocols(const Decl *CDecl, } } -/// CollectIvarsToConstructOrDestruct - Collect those ivars which require -/// construction (construct=true) or destruction (construct=false) -/// -void ASTContext::CollectIvarsToConstructOrDestruct(const ObjCInterfaceDecl *OI, - llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars, - bool construct) { - if (!getLangOptions().CPlusPlus) - return; - for (ObjCInterfaceDecl::ivar_iterator I = OI->ivar_begin(), - E = OI->ivar_end(); I != E; ++I) { - ObjCIvarDecl *Iv = (*I); - if (const RecordType *RT = Iv->getType()->getAs<RecordType>()) { - if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) - if (construct && !RD->hasTrivialConstructor() || - !construct && !RD->hasTrivialDestructor()) - Ivars.push_back(*I); - } - } - - // Find ivars to construct/destruct in class extension. - if (const ObjCCategoryDecl *CDecl = OI->getClassExtension()) { - for (ObjCCategoryDecl::ivar_iterator I = CDecl->ivar_begin(), - E = CDecl->ivar_end(); I != E; ++I) { - ObjCIvarDecl *Iv = (*I); - if (const RecordType *RT = Iv->getType()->getAs<RecordType>()) { - if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) - if (construct && !RD->hasTrivialConstructor() || - !construct && !RD->hasTrivialDestructor()) - Ivars.push_back(*I); - } - } - } - - // Also add any ivar defined in this class's implementation. This - // includes synthesized ivars. - if (ObjCImplementationDecl *ImplDecl = OI->getImplementation()) { - for (ObjCImplementationDecl::ivar_iterator I = ImplDecl->ivar_begin(), - E = ImplDecl->ivar_end(); I != E; ++I) { - ObjCIvarDecl *Iv = (*I); - if (const RecordType *RT = Iv->getType()->getAs<RecordType>()) { - if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) - if (construct && !RD->hasTrivialConstructor() || - !construct && !RD->hasTrivialDestructor()) - Ivars.push_back(*I); - } - } - } -} - unsigned ASTContext::CountNonClassIvars(const ObjCInterfaceDecl *OI) { unsigned count = 0; // Count ivars declared in class extension. diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 212a36f3cc..f22c1ad852 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1590,6 +1590,12 @@ public: /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods. void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method); + + /// CollectIvarsToConstructOrDestruct - Collect those ivars which require + /// construction (construct=true) or destruction (construct=false) + void CollectIvarsToConstructOrDestruct(const ObjCInterfaceDecl *OI, + llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars, + bool construct=true); //===--------------------------------------------------------------------===// // Statement Parsing Callbacks: SemaStmt.cpp. public: diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 0e93ebda08..1324e05b6d 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1798,3 +1798,55 @@ Sema::DeclPtrTy Sema::ActOnObjCExceptionDecl(Scope *S, Declarator &D) { Diag(New->getLocation(), diag::err_block_on_nonlocal); return DeclPtrTy::make(New); } + +/// CollectIvarsToConstructOrDestruct - Collect those ivars which require +/// construction (construct=true) or destruction (construct=false) +/// +void Sema::CollectIvarsToConstructOrDestruct(const ObjCInterfaceDecl *OI, + llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars, + bool construct) { + if (!getLangOptions().CPlusPlus) + return; + for (ObjCInterfaceDecl::ivar_iterator I = OI->ivar_begin(), + E = OI->ivar_end(); I != E; ++I) { + ObjCIvarDecl *Iv = (*I); + QualType QT = Context.getBaseElementType(Iv->getType()); + if (const RecordType *RT = QT->getAs<RecordType>()) { + if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) + if (construct && !RD->hasTrivialConstructor() || + !construct && !RD->hasTrivialDestructor()) + Ivars.push_back(*I); + } + } + + // Find ivars to construct/destruct in class extension. + if (const ObjCCategoryDecl *CDecl = OI->getClassExtension()) { + for (ObjCCategoryDecl::ivar_iterator I = CDecl->ivar_begin(), + E = CDecl->ivar_end(); I != E; ++I) { + ObjCIvarDecl *Iv = (*I); + QualType QT = Context.getBaseElementType(Iv->getType()); + if (const RecordType *RT = QT->getAs<RecordType>()) { + if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) + if (construct && !RD->hasTrivialConstructor() || + !construct && !RD->hasTrivialDestructor()) + Ivars.push_back(*I); + } + } + } + + // Also add any ivar defined in this class's implementation. This + // includes synthesized ivars. + if (ObjCImplementationDecl *ImplDecl = OI->getImplementation()) { + for (ObjCImplementationDecl::ivar_iterator I = ImplDecl->ivar_begin(), + E = ImplDecl->ivar_end(); I != E; ++I) { + ObjCIvarDecl *Iv = (*I); + QualType QT = Context.getBaseElementType(Iv->getType()); + if (const RecordType *RT = QT->getAs<RecordType>()) { + if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) + if (construct && !RD->hasTrivialConstructor() || + !construct && !RD->hasTrivialDestructor()) + Ivars.push_back(*I); + } + } + } +} |