summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-09-15 19:20:10 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-09-15 19:20:10 +0000
commit91f68b43c326ce7b23856b8ebdb15cf59256728e (patch)
tree06664f1b53e0054a5bfd1e74cc5bae7fb2dd0eda /clang/lib/CodeGen/CGCXX.cpp
parent33d585cb25870eb83946280a2c422081fab65833 (diff)
downloadbcm5719-llvm-91f68b43c326ce7b23856b8ebdb15cf59256728e.tar.gz
bcm5719-llvm-91f68b43c326ce7b23856b8ebdb15cf59256728e.zip
Move emitCXXStructor to CGCXXABI.
A followup patch will address the code duplication. llvm-svn: 217807
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp77
1 files changed, 0 insertions, 77 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index aa53691d77b..58611e83eea 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -196,37 +196,6 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
return false;
}
-static void emitCXXConstructor(CodeGenModule &CGM,
- const CXXConstructorDecl *ctor,
- StructorType ctorType) {
- if (!CGM.getTarget().getCXXABI().hasConstructorVariants()) {
- // If there are no constructor variants, always emit the complete
- // destructor.
- ctorType = StructorType::Complete;
- } else if (!ctor->getParent()->getNumVBases() &&
- (ctorType == StructorType::Complete ||
- ctorType == StructorType::Base)) {
- // The complete constructor is equivalent to the base constructor
- // for classes with no virtual bases. Try to emit it as an alias.
- bool ProducedAlias = !CGM.TryEmitDefinitionAsAlias(
- GlobalDecl(ctor, Ctor_Complete), GlobalDecl(ctor, Ctor_Base), true);
- if (ctorType == StructorType::Complete && ProducedAlias)
- 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);
-}
-
llvm::GlobalValue *CodeGenModule::getAddrOfCXXStructor(
const CXXMethodDecl *MD, StructorType Type, const CGFunctionInfo *FnInfo,
llvm::FunctionType *FnType, bool DontDefer) {
@@ -253,52 +222,6 @@ llvm::GlobalValue *CodeGenModule::getAddrOfCXXStructor(
DontDefer));
}
-static void emitCXXDestructor(CodeGenModule &CGM, const CXXDestructorDecl *dtor,
- StructorType dtorType) {
- // The complete destructor is equivalent to the base destructor for
- // classes with no virtual bases, so try to emit it as an alias.
- if (!dtor->getParent()->getNumVBases() &&
- (dtorType == StructorType::Complete || dtorType == StructorType::Base)) {
- bool ProducedAlias = !CGM.TryEmitDefinitionAsAlias(
- GlobalDecl(dtor, Dtor_Complete), GlobalDecl(dtor, Dtor_Base), true);
- if (ProducedAlias) {
- if (dtorType == StructorType::Complete)
- return;
- if (dtor->isVirtual())
- CGM.getVTables().EmitThunks(GlobalDecl(dtor, Dtor_Complete));
- }
- }
-
- // The base destructor is equivalent to the base destructor of its
- // base class if there is exactly one non-virtual base class with a
- // non-trivial destructor, there are no fields with a non-trivial
- // destructor, and the body of the destructor is trivial.
- if (dtorType == StructorType::Base && !CGM.TryEmitBaseDestructorAsAlias(dtor))
- return;
-
- const CGFunctionInfo &fnInfo =
- CGM.getTypes().arrangeCXXStructorDeclaration(dtor, dtorType);
-
- auto *fn = cast<llvm::Function>(
- CGM.getAddrOfCXXStructor(dtor, dtorType, &fnInfo, nullptr, true));
-
- GlobalDecl GD(dtor, toCXXDtorType(dtorType));
- CGM.setFunctionLinkage(GD, fn);
- CodeGenFunction(CGM).GenerateCode(GD, fn, fnInfo);
-
- CGM.setFunctionDefinitionAttributes(dtor, fn);
- CGM.SetLLVMFunctionAttributesForDefinition(dtor, fn);
-}
-
-void CodeGenModule::emitCXXStructor(const CXXMethodDecl *MD,
- StructorType Type) {
- if (auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
- emitCXXConstructor(*this, CD, Type);
- return;
- }
- emitCXXDestructor(*this, cast<CXXDestructorDecl>(MD), Type);
-}
-
static llvm::Value *BuildAppleKextVirtualCall(CodeGenFunction &CGF,
GlobalDecl GD,
llvm::Type *Ty,
OpenPOWER on IntegriCloud