Changeset 7641b6c


Ignore:
Timestamp:
Dec 18, 2017, 2:14:26 PM (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:
b8b075cd
Parents:
9058414
Message:

Run ResolveCopyCtors? on StmtExpr? generated as part of a TupleAssignExpr? to generate result temporary and ctor/dtor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r9058414 r7641b6c  
    382382                        } // if
    383383                        delete stmt;
     384                        if ( TupleAssignExpr * assign = dynamic_cast< TupleAssignExpr * >( resolved ) ) {
     385                                // fix newly generated StmtExpr
     386                                postvisit( assign->stmtExpr );
     387                        }
    384388                        return resolved;
    385389                }
     
    479483                                env->apply( result );
    480484                                ObjectDecl * ret = ObjectDecl::newObject( retNamer.newName(), result, nullptr );
    481                                 ret->get_type()->set_const( false );
    482                                 stmtExpr->get_returnDecls().push_front( ret );
     485                                ret->type->set_const( false );
     486                                stmtExpr->returnDecls.push_front( ret );
    483487
    484488                                // must have a non-empty body, otherwise it wouldn't have a result
    485                                 CompoundStmt * body = stmtExpr->get_statements();
     489                                CompoundStmt * body = stmtExpr->statements;
    486490                                assert( ! body->get_kids().empty() );
    487491                                // must be an ExprStmt, otherwise it wouldn't have a result
    488492                                ExprStmt * last = strict_dynamic_cast< ExprStmt * >( body->get_kids().back() );
    489                                 last->set_expr( makeCtorDtor( "?{}", ret, last->get_expr() ) );
    490 
    491                                 stmtExpr->get_dtors().push_front( makeCtorDtor( "^?{}", ret ) );
     493                                last->expr = makeCtorDtor( "?{}", ret, last->get_expr() );
     494
     495                                stmtExpr->dtors.push_front( makeCtorDtor( "^?{}", ret ) );
    492496                        } // if
    493497                }
     
    606610                                // must have a non-empty body, otherwise it wouldn't have a result
    607611                                assert( ! stmts.empty() );
    608                                 assert( ! stmtExpr->get_returnDecls().empty() );
     612                                assertf( ! stmtExpr->get_returnDecls().empty(), "StmtExpr returns non-void, but no return decls: %s", toString( stmtExpr ).c_str() );
    609613                                stmts.push_back( new ExprStmt( new VariableExpr( stmtExpr->get_returnDecls().front() ) ) );
    610614                                stmtExpr->get_returnDecls().clear();
Note: See TracChangeset for help on using the changeset viewer.