diff options
author | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
commit | c49018d9cce52d8c9f34b44865ec3ba8e89a1488 (patch) | |
tree | c5e9e10bc189de0058aa763c47b9920a8351b7df /lib/CodeGen/CGCXX.cpp | |
parent | 110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab (diff) | |
download | FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.zip FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.tar.gz |
Vendor import of clang trunk r132879:
http://llvm.org/svn/llvm-project/cfe/trunk@132879
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 184147c..f6fc202 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -28,17 +28,6 @@ using namespace clang; using namespace CodeGen; -/// Determines whether the given function has a trivial body that does -/// not require any specific codegen. -static bool HasTrivialBody(const FunctionDecl *FD) { - Stmt *S = FD->getBody(); - if (!S) - return true; - if (isa<CompoundStmt>(S) && cast<CompoundStmt>(S)->body_empty()) - return true; - return false; -} - /// Try to emit a base destructor as an alias to its primary /// base-class destructor. bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) { @@ -47,7 +36,7 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) { // If the destructor doesn't have a trivial body, we have to emit it // separately. - if (!HasTrivialBody(D)) + if (!D->hasTrivialBody()) return true; const CXXRecordDecl *Class = D->getParent(); @@ -187,7 +176,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 +236,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. |