return false;
}
+llvm::Function *CodeGenModule::codegenCXXStructor(const CXXMethodDecl *MD,
+ StructorType Type) {
+ const CGFunctionInfo &FnInfo =
+ getTypes().arrangeCXXStructorDeclaration(MD, Type);
+ auto *Fn = cast<llvm::Function>(
+ getAddrOfCXXStructor(MD, Type, &FnInfo, nullptr, true));
+
+ GlobalDecl GD;
+ if (const auto *DD = dyn_cast<CXXDestructorDecl>(MD)) {
+ GD = GlobalDecl(DD, toCXXDtorType(Type));
+ } else {
+ const auto *CD = cast<CXXConstructorDecl>(MD);
+ GD = GlobalDecl(CD, toCXXCtorType(Type));
+ }
+
+ setFunctionLinkage(GD, Fn);
+ CodeGenFunction(*this).GenerateCode(GD, Fn, FnInfo);
+ setFunctionDefinitionAttributes(MD, Fn);
+ SetLLVMFunctionAttributesForDefinition(MD, Fn);
+ return Fn;
+}
+
llvm::GlobalValue *CodeGenModule::getAddrOfCXXStructor(
const CXXMethodDecl *MD, StructorType Type, const CGFunctionInfo *FnInfo,
llvm::FunctionType *FnType, bool DontDefer) {
/// Objective-C fast enumeration loop (for..in).
QualType getObjCFastEnumerationStateType();
+ // Produce code for this constructor/destructor. This method doesn't try
+ // to apply any ABI rules about which other constructors/destructors
+ // are needed or if they are alias to each other.
+ llvm::Function *codegenCXXStructor(const CXXMethodDecl *MD,
+ StructorType Type);
+
/// Return the address of the constructor/destructor of the given type.
llvm::GlobalValue *
getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type,
return;
}
- const CGFunctionInfo &fnInfo =
- CGM.getTypes().arrangeCXXStructorDeclaration(ctor, ctorType);
-
- auto *fn = cast<llvm::Function>(
- CGM.getAddrOfCXXStructor(ctor, ctorType, &fnInfo, nullptr, true));
- GlobalDecl GD(ctor, toCXXCtorType(ctorType));
- CGM.setFunctionLinkage(GD, fn);
- CodeGenFunction(CGM).GenerateCode(GD, fn, fnInfo);
-
- CGM.setFunctionDefinitionAttributes(ctor, fn);
- CGM.SetLLVMFunctionAttributesForDefinition(ctor, fn);
+ CGM.codegenCXXStructor(ctor, ctorType);
}
static void emitCXXDestructor(CodeGenModule &CGM, const CXXDestructorDecl *dtor,
const CXXConstructorDecl *ctor,
StructorType ctorType) {
// There are no constructor variants, always emit the complete destructor.
- ctorType = StructorType::Complete;
-
- const CGFunctionInfo &fnInfo =
- CGM.getTypes().arrangeCXXStructorDeclaration(ctor, ctorType);
-
- auto *fn = cast<llvm::Function>(
- CGM.getAddrOfCXXStructor(ctor, ctorType, &fnInfo, nullptr, true));
- GlobalDecl GD(ctor, toCXXCtorType(ctorType));
- CGM.setFunctionLinkage(GD, fn);
- CodeGenFunction(CGM).GenerateCode(GD, fn, fnInfo);
-
- CGM.setFunctionDefinitionAttributes(ctor, fn);
- CGM.SetLLVMFunctionAttributesForDefinition(ctor, fn);
+ CGM.codegenCXXStructor(ctor, StructorType::Complete);
}
static void emitCXXDestructor(CodeGenModule &CGM, const CXXDestructorDecl *dtor,