Ignore:
Timestamp:
Oct 19, 2017, 11:13:11 AM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
189d800
Parents:
6137fbb
git-author:
Rob Schluntz <rschlunt@…> (10/11/17 16:04:22)
git-committer:
Rob Schluntz <rschlunt@…> (10/19/17 11:13:11)
Message:

Make ReturnFixer? idempotent and rearrange passes in Validate in anticipation of autogen changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

    r6137fbb rbd7e609  
    129129                // hands off if the function returns a reference - we don't want to allocate a temporary if a variable's address
    130130                // is being returned
    131                 if ( returnStmt->get_expr() && returnVals.size() == 1 && isConstructable( returnVals.front()->get_type() ) ) {
     131                if ( returnStmt->expr && returnVals.size() == 1 && isConstructable( returnVals.front()->get_type() ) ) {
    132132                        // explicitly construct the return value using the return expression and the retVal object
    133133                        assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() );
    134134
    135                         stmtsToAddBefore.push_back( genCtorDtor( "?{}", dynamic_cast< ObjectDecl *>( returnVals.front() ), returnStmt->get_expr() ) );
     135                        ObjectDecl * retVal = strict_dynamic_cast< ObjectDecl * >( returnVals.front() );
     136                        if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( returnStmt->expr ) ) {
     137                                // return statement has already been mutated - don't need to do it again
     138                                if ( varExpr->var == retVal ) return;
     139                        }
     140                        stmtsToAddBefore.push_back( genCtorDtor( "?{}", retVal, returnStmt->get_expr() ) );
    136141
    137142                        // return the retVal object
Note: See TracChangeset for help on using the changeset viewer.