diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-20 23:18:55 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-20 23:18:55 +0000 |
commit | e7d346b6d5cee14b75e34928b3fd423f21d8d80d (patch) | |
tree | 917de35bb3f05c11cf38771417d41b161f3bd75b /lib/CodeGen/CGCXX.cpp | |
parent | 25c545788da6e3a725206cfa378b9b83a7da6024 (diff) |
Move EmitCtorPrologue to CGCXX. Add an assert and FIXMEs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76498 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 07f387f83f..4a2db05532 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -414,3 +414,36 @@ const char *CodeGenModule::getMangledCXXDtorName(const CXXDestructorDecl *D, Name += '\0'; return UniqueMangledName(Name.begin(), Name.end()); } + +/// EmitCtorPrologue - This routine generates necessary code to initialize +/// base classes and non-static data members belonging to this constructor. +void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) { + for (CXXConstructorDecl::init_const_iterator B = CD->init_begin(), + E = CD->init_end(); + B != E; ++B) { + CXXBaseOrMemberInitializer *Member = (*B); + if (Member->isBaseInitializer()) { + // FIXME. Added base initialilzers here. + assert(false && "FIXME. base initialization unsupported"); + } + else { + // non-static data member initilaizers. + FieldDecl *Field = Member->getMember(); + QualType FieldType = getContext().getCanonicalType((Field)->getType()); + assert(!getContext().getAsArrayType(FieldType) + && "FIXME. Field arrays initialization unsupported"); + assert(!FieldType->getAsRecordType() + && "FIXME. Field class initialization unsupported"); + llvm::Value *LoadOfThis = LoadCXXThis(); + LValue LHS = EmitLValueForField(LoadOfThis, Field, false, 0); + + assert(Member->getNumArgs() == 1 && "Initializer count must be 1 only"); + Expr *RhsExpr = *Member->begin(); + llvm::Value *RHS = EmitScalarExpr(RhsExpr, true); + if (LHS.isBitfield()) + EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, FieldType, 0); + else + EmitStoreThroughLValue(RValue::get(RHS), LHS, FieldType); + } + } +} |