Changeset bd91e2a


Ignore:
Timestamp:
Mar 3, 2016, 3:59:25 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, string, with_gc
Children:
2e60a1a
Parents:
3627356
Message:

Properly clone types in layout function generation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r3627356 rbd91e2a  
    337337                        DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member );
    338338                        assert( dwt );
     339                        Type *memberType = dwt->get_type();
    339340
    340341                        if ( firstMember ) {
     
    342343                        } else {
    343344                                // make sure all members after the first (automatically aligned at 0) are properly padded for alignment
    344                                 addStmt( layoutDecl->get_statements(), makeAlignTo( derefVar( sizeParam ), new AlignofExpr( dwt->get_type() ) ) );
     345                                addStmt( layoutDecl->get_statements(), makeAlignTo( derefVar( sizeParam ), new AlignofExpr( memberType->clone() ) ) );
    345346                        }
    346347                       
     
    351352
    352353                        // add member size to current size
    353                         addExpr( layoutDecl->get_statements(), makeOp( "?+=?", derefVar( sizeParam ), new SizeofExpr( dwt->get_type() ) ) );
     354                        addExpr( layoutDecl->get_statements(), makeOp( "?+=?", derefVar( sizeParam ), new SizeofExpr( memberType->clone() ) ) );
    354355                       
    355356                        // take max of member alignment and global alignment
    356                         addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( alignParam ), new AlignofExpr( dwt->get_type() ) ) );
     357                        addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( alignParam ), new AlignofExpr( memberType->clone() ) ) );
    357358                }
    358359                // make sure the type is end-padded to a multiple of its alignment
     
    391392                        DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member );
    392393                        assert( dwt );
     394                        Type *memberType = dwt->get_type();
    393395                       
    394396                        // take max member size and global size
    395                         addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( sizeParam ), new SizeofExpr( dwt->get_type() ) ) );
     397                        addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( sizeParam ), new SizeofExpr( memberType->clone() ) ) );
    396398                       
    397399                        // take max of member alignment and global alignment
    398                         addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( alignParam ), new AlignofExpr( dwt->get_type() ) ) );
     400                        addStmt( layoutDecl->get_statements(), makeAssignMax( derefVar( alignParam ), new AlignofExpr( memberType->clone() ) ) );
    399401                }
    400402                // make sure the type is end-padded to a multiple of its alignment
Note: See TracChangeset for help on using the changeset viewer.