aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-03 03:40:11 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-03 03:40:11 +0000
commit9a70846c5ffd5ff5cce60de49cd7b312146bf502 (patch)
treed8971c8c58529d8150edebc7868b0520fe71620d /lib/CodeGen/CGCXX.cpp
parent89b7702c9a64e12093ed34fc02dc3cfbb6eb133a (diff)
Don't emit derived-to-base destructor aliases if we don't have a definition
for the base destructor, because aliases to declarations aren't legal. Fixes PR 6471. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97637 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r--lib/CodeGen/CGCXX.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index cb8489d202..4889fc08f4 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -93,12 +93,18 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
if (!UniqueBase)
return true;
+ /// If we don't have a definition for the destructor yet, don't
+ /// emit. We can't emit aliases to declarations; that's just not
+ /// how aliases work.
+ const CXXDestructorDecl *BaseD = UniqueBase->getDestructor(getContext());
+ if (!BaseD->isImplicit() && !BaseD->getBody())
+ return true;
+
// If the base is at a non-zero offset, give up.
const ASTRecordLayout &ClassLayout = Context.getASTRecordLayout(Class);
if (ClassLayout.getBaseClassOffset(UniqueBase) != 0)
return true;
- const CXXDestructorDecl *BaseD = UniqueBase->getDestructor(getContext());
return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base),
GlobalDecl(BaseD, Dtor_Base));
}