[cfe-commits] r76493 - in /cfe/trunk/lib/CodeGen: CodeGenFunction.cpp CodeGenFunction.h

Anders Carlsson andersca at mac.com
Mon Jul 20 16:03:20 PDT 2009


On Jul 20, 2009, at 3:35 PM, Fariborz Jahanian wrote:

> Author: fjahanian
> Date: Mon Jul 20 17:35:22 2009
> New Revision: 76493
>
> URL: http://llvm.org/viewvc/llvm-project?rev=76493&view=rev
> Log:
> Early ir-gen for constructor prologue. This is on going.
>

Very nice!

> +/// 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) {

Could you move this function to CGCXX where the rest of the ctor/dtor  
stuff lives?

> +  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.
> +      ;

I like to add asserts so we don't forget about this.

> +    }
> +    else {
> +      // non-static data member initilaizers.
> +      FieldDecl *Field = Member->getMember();
> +      QualType FieldType = getContext().getCanonicalType((Field)- 
> >getType());
> +      assert(!getContext().getAsArrayType(FieldType)
> +             && "Field arrays initialization unsupported");
> +      assert(!FieldType->getAsRecordType()
> +             && "Field class initialization unsupported");

... like this :) I also like using FIXME in the assertions so we know  
that it's something that needs to be fixed.

Anders




More information about the cfe-commits mailing list