summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2011-05-08 17:25:05 +0000
committerAnders Carlsson <andersca@mac.com>2011-05-08 17:25:05 +0000
commitcc53197903882dcb2d227c542018aa2a1191466d (patch)
tree4b770622c476ec3ec5817dffcc604005d3827508 /clang/lib/CodeGen
parentab39c6353856939eb83febd3ac9c93cab29ee0cd (diff)
downloadbcm5719-llvm-cc53197903882dcb2d227c542018aa2a1191466d.tar.gz
bcm5719-llvm-cc53197903882dcb2d227c542018aa2a1191466d.zip
Don't emit complete constructors for abstract classes. Also, don't emit
complete destructors for abstract classes unless the destructor is virtual and thus needs to be in the vtable. llvm-svn: 131068
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 184147cb728..4390f3a3e3e 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -187,7 +187,10 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
void CodeGenModule::EmitCXXConstructors(const CXXConstructorDecl *D) {
// The constructor used for constructing this as a complete class;
// constucts the virtual bases, then calls the base constructor.
- EmitGlobal(GlobalDecl(D, Ctor_Complete));
+ if (!D->getParent()->isAbstract()) {
+ // We don't need to emit the complete ctor if the class is abstract.
+ EmitGlobal(GlobalDecl(D, Ctor_Complete));
+ }
// The constructor used for constructing this as a base class;
// ignores virtual bases.
@@ -244,7 +247,11 @@ void CodeGenModule::EmitCXXDestructors(const CXXDestructorDecl *D) {
// The destructor used for destructing this as a most-derived class;
// call the base destructor and then destructs any virtual bases.
- EmitGlobal(GlobalDecl(D, Dtor_Complete));
+ if (!D->getParent()->isAbstract() || D->isVirtual()) {
+ // We don't need to emit the complete ctor if the class is abstract,
+ // unless the destructor is virtual and needs to be in the vtable.
+ EmitGlobal(GlobalDecl(D, Dtor_Complete));
+ }
// The destructor used for destructing this as a base class; ignores
// virtual bases.
OpenPOWER on IntegriCloud