diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-09 01:05:47 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-09 01:05:47 +0000 |
commit | 49c16da71b9c95cc53b4af6de2833a022cb69b6a (patch) | |
tree | a23a96e60a913aeb5abc11df742f7f71732ad090 /lib/CodeGen/CGCXX.cpp | |
parent | a8ce9ecae8670fe8e189755b14d73fd84087e51f (diff) |
Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors. This has a number of benefits:
1. Less code.
2. Explicit and implicit constructors get the same diagnostics.
3. The AST explicitly contains constructor calls from implicit default
constructors. This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86500 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index cc6f13be1a..0e394b56f5 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -1483,64 +1483,6 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD, PopCXXTemporary(); } - if (!CD->getNumBaseOrMemberInitializers() && !CD->isTrivial()) { - // Nontrivial default constructor with no initializer list. It may still - // have bases classes and/or contain non-static data members which require - // construction. - for (CXXRecordDecl::base_class_const_iterator Base = - ClassDecl->bases_begin(); - Base != ClassDecl->bases_end(); ++Base) { - // FIXME. copy assignment of virtual base NYI - if (Base->isVirtual()) - continue; - - CXXRecordDecl *BaseClassDecl - = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); - if (BaseClassDecl->hasTrivialConstructor()) - continue; - if (CXXConstructorDecl *BaseCX = - BaseClassDecl->getDefaultConstructor(getContext())) { - LoadOfThis = LoadCXXThis(); - llvm::Value *V = GetAddressCXXOfBaseClass(LoadOfThis, ClassDecl, - BaseClassDecl, - /*NullCheckValue=*/false); - EmitCXXConstructorCall(BaseCX, Ctor_Complete, V, 0, 0); - } - } - - for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(), - FieldEnd = ClassDecl->field_end(); - Field != FieldEnd; ++Field) { - QualType FieldType = getContext().getCanonicalType((*Field)->getType()); - const ConstantArrayType *Array = - getContext().getAsConstantArrayType(FieldType); - if (Array) - FieldType = getContext().getBaseElementType(FieldType); - if (!FieldType->getAs<RecordType>() || Field->isAnonymousStructOrUnion()) - continue; - const RecordType *ClassRec = FieldType->getAs<RecordType>(); - CXXRecordDecl *MemberClassDecl = - dyn_cast<CXXRecordDecl>(ClassRec->getDecl()); - if (!MemberClassDecl || MemberClassDecl->hasTrivialConstructor()) - continue; - if (CXXConstructorDecl *MamberCX = - MemberClassDecl->getDefaultConstructor(getContext())) { - LoadOfThis = LoadCXXThis(); - LValue LHS = EmitLValueForField(LoadOfThis, *Field, false, 0); - if (Array) { - const llvm::Type *BasePtr = ConvertType(FieldType); - BasePtr = llvm::PointerType::getUnqual(BasePtr); - llvm::Value *BaseAddrPtr = - Builder.CreateBitCast(LHS.getAddress(), BasePtr); - EmitCXXAggrConstructorCall(MamberCX, Array, BaseAddrPtr); - } - else - EmitCXXConstructorCall(MamberCX, Ctor_Complete, LHS.getAddress(), - 0, 0); - } - } - } - // Initialize the vtable pointer if (ClassDecl->isDynamicClass()) { if (!LoadOfThis) |