]> granicus.if.org Git - clang/commitdiff
Simplify GenerateCXXAggrDestructorHelper.
authorAnders Carlsson <andersca@mac.com>
Tue, 8 Jun 2010 22:14:59 +0000 (22:14 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 8 Jun 2010 22:14:59 +0000 (22:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105646 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGClass.cpp
lib/CodeGen/CGDeclCXX.cpp
lib/CodeGen/CodeGenFunction.h

index 348f85b32fd9ed05fb2aa2eea9b67f8f52025fa3..1a5f4c3af740e4e69e04a11f0a8ad13b8aafb297 100644 (file)
@@ -1036,7 +1036,7 @@ CodeGenFunction::EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
 /// GenerateCXXAggrDestructorHelper - Generates a helper function which when
 /// invoked, calls the default destructor on array elements in reverse order of
 /// construction.
-llvm::Constant * 
+llvm::Function * 
 CodeGenFunction::GenerateCXXAggrDestructorHelper(const CXXDestructorDecl *D,
                                                  const ArrayType *Array,
                                                  llvm::Value *This) {
@@ -1049,32 +1049,25 @@ CodeGenFunction::GenerateCXXAggrDestructorHelper(const CXXDestructorDecl *D,
   
   llvm::SmallString<16> Name;
   llvm::raw_svector_ostream(Name) << "__tcf_" << (++UniqueAggrDestructorCount);
-  QualType R = getContext().VoidTy;
-  const CGFunctionInfo &FI
-      = CGM.getTypes().getFunctionInfo(R, Args, FunctionType::ExtInfo());
+  const CGFunctionInfo &FI = 
+    CGM.getTypes().getFunctionInfo(getContext().VoidTy, Args, 
+                                   FunctionType::ExtInfo());
   const llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(FI, false);
   llvm::Function *Fn =
-    llvm::Function::Create(FTy, llvm::GlobalValue::InternalLinkage,
-                           Name.str(),
+    llvm::Function::Create(FTy, llvm::GlobalValue::InternalLinkage, Name.str(),
                            &CGM.getModule());
-  IdentifierInfo *II = &CGM.getContext().Idents.get(Name.str());
-  FunctionDecl *FD = FunctionDecl::Create(getContext(),
-                                          getContext().getTranslationUnitDecl(),
-                                          SourceLocation(), II, R, 0,
-                                          FunctionDecl::Static,
-                                          FunctionDecl::None,
-                                          false, true);
-  StartFunction(FD, R, Fn, Args, SourceLocation());
+
+  StartFunction(GlobalDecl(), getContext().VoidTy, Fn, Args, SourceLocation());
+
   QualType BaseElementTy = getContext().getBaseElementType(Array);
-  const llvm::Type *BasePtr = ConvertType(BaseElementTy);
-  BasePtr = llvm::PointerType::getUnqual(BasePtr);
+  const llvm::Type *BasePtr = ConvertType(BaseElementTy)->getPointerTo();
   llvm::Value *BaseAddrPtr = Builder.CreateBitCast(This, BasePtr);
+  
   EmitCXXAggrDestructorCall(D, Array, BaseAddrPtr);
+  
   FinishFunction();
-  llvm::Type *Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext),
-                                              0);
-  llvm::Constant *m = llvm::ConstantExpr::getBitCast(Fn, Ptr8Ty);
-  return m;
+  
+  return Fn;
 }
 
 
index f94ddd988662ba7a1856d245931ef9dd2c960fcf..fbdb685e76b15c92bd56a6a7c9f142eea41e5d47 100644 (file)
@@ -71,11 +71,10 @@ static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D,
   llvm::Constant *DtorFn;
   if (Array) {
     DtorFn = 
-    CodeGenFunction(CGM).GenerateCXXAggrDestructorHelper(Dtor, 
-                                                         Array, 
-                                                         DeclPtr);
+      CodeGenFunction(CGM).GenerateCXXAggrDestructorHelper(Dtor, Array, 
+                                                           DeclPtr);
     const llvm::Type *Int8PtrTy =
-    llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
+      llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
     DeclPtr = llvm::Constant::getNullValue(Int8PtrTy);
   } else
     DtorFn = CGM.GetAddrOfCXXDestructor(Dtor, Dtor_Complete);
index a0e5da1a0f6ff4b7c8f3940b8d7b16df176bfff0..21c085776939d1c86675f1e0625650b724d9a8f2 100644 (file)
@@ -835,9 +835,9 @@ public:
                                  llvm::Value *NumElements,
                                  llvm::Value *This);
 
-  llvm::Constant *GenerateCXXAggrDestructorHelper(const CXXDestructorDecl *D,
-                                                const ArrayType *Array,
-                                                llvm::Value *This);
+  llvm::Function *GenerateCXXAggrDestructorHelper(const CXXDestructorDecl *D,
+                                                  const ArrayType *Array,
+                                                  llvm::Value *This);
 
   void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type,
                              bool ForVirtualBase, llvm::Value *This);