forked from OSchip/llvm-project
Set the correct vtable pointers _before_ generating code for any member initializers. Fixes about ~2000 clang/LLVM tests in the clang-on-clang build.
llvm-svn: 95116
This commit is contained in:
parent
29e0702dc8
commit
5dc86337fb
|
@ -862,6 +862,8 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
|
||||||
CXXCtorType CtorType) {
|
CXXCtorType CtorType) {
|
||||||
const CXXRecordDecl *ClassDecl = CD->getParent();
|
const CXXRecordDecl *ClassDecl = CD->getParent();
|
||||||
|
|
||||||
|
llvm::SmallVector<CXXBaseOrMemberInitializer *, 8> MemberInitializers;
|
||||||
|
|
||||||
// FIXME: Add vbase initialization
|
// FIXME: Add vbase initialization
|
||||||
|
|
||||||
for (CXXConstructorDecl::init_const_iterator B = CD->init_begin(),
|
for (CXXConstructorDecl::init_const_iterator B = CD->init_begin(),
|
||||||
|
@ -875,14 +877,17 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
|
||||||
if (Member->isBaseInitializer())
|
if (Member->isBaseInitializer())
|
||||||
EmitBaseInitializer(*this, ClassDecl, Member, CtorType);
|
EmitBaseInitializer(*this, ClassDecl, Member, CtorType);
|
||||||
else
|
else
|
||||||
EmitMemberInitializer(*this, ClassDecl, Member);
|
MemberInitializers.push_back(Member);
|
||||||
|
|
||||||
// Pop any live temporaries that the initializers might have pushed.
|
|
||||||
while (!LiveTemporaries.empty())
|
|
||||||
PopCXXTemporary();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeVtablePtrs(ClassDecl);
|
InitializeVtablePtrs(ClassDecl);
|
||||||
|
|
||||||
|
for (unsigned I = 0, E = MemberInitializers.size(); I != E; ++I) {
|
||||||
|
assert(LiveTemporaries.empty() &&
|
||||||
|
"Should not have any live temporaries at initializer start!");
|
||||||
|
|
||||||
|
EmitMemberInitializer(*this, ClassDecl, MemberInitializers[I]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitDtorEpilogue - Emit all code that comes at the end of class's
|
/// EmitDtorEpilogue - Emit all code that comes at the end of class's
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -O3 | FileCheck %s
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
virtual int f() { return 1; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct B : A {
|
||||||
|
B() : i(f()) { }
|
||||||
|
|
||||||
|
virtual int f() { return 2; }
|
||||||
|
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
// CHECK: define i32 @_Z1fv() nounwind
|
||||||
|
int f() {
|
||||||
|
B b;
|
||||||
|
|
||||||
|
// CHECK: call i32 @_ZN1B1fEv
|
||||||
|
return b.i;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue