[cfe-commits] r102446 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp

Fariborz Jahanian fjahanian at apple.com
Tue Apr 27 10:18:58 PDT 2010


Author: fjahanian
Date: Tue Apr 27 12:18:58 2010
New Revision: 102446

URL: http://llvm.org/viewvc/llvm-project?rev=102446&view=rev
Log:
Move CollectIvarsToConstructOrDestruct to Sema
from AST, consider ivar array of objects
(per Doug's comment).

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=102446&r1=102445&r2=102446&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Apr 27 12:18:58 2010
@@ -957,9 +957,6 @@
                                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);

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=102446&r1=102445&r2=102446&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Apr 27 12:18:58 2010
@@ -807,55 +807,6 @@
   }
 }
 
-/// 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.

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=102446&r1=102445&r2=102446&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Apr 27 12:18:58 2010
@@ -1590,6 +1590,12 @@
 
   /// 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:

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=102446&r1=102445&r2=102446&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Apr 27 12:18:58 2010
@@ -1798,3 +1798,55 @@
     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);
+      }
+    }
+  }
+}





More information about the cfe-commits mailing list