Changeset 65aca88


Ignore:
Timestamp:
May 12, 2017, 4:49:38 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:
ce8c12f, fae2cf8
Parents:
edbdbe6
Message:

fix destruction of tuple-typed argument temporaries

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/GenType.cc

    redbdbe6 r65aca88  
    237237        void GenType::visit( TupleType * tupleType ) {
    238238                assertf( ! genC, "Tuple types should not reach code generation." );
    239                 Visitor::visit( tupleType );
    240239                unsigned int i = 0;
    241240                std::ostringstream os;
     
    245244                        os << genType( t, "", pretty, genC, lineMarks ) << (i == tupleType->size() ? "" : ", ");
    246245                }
    247                 os << "]";
     246                os << "] ";
    248247                typeString = os.str() + typeString;
    249248        }
  • src/InitTweak/FixInit.cc

    redbdbe6 r65aca88  
    619619
    620620                Expression * FixCopyCtors::mutate( StmtExpr * stmtExpr ) {
    621                         stmtExpr = safe_dynamic_cast< StmtExpr * >( Parent::mutate( stmtExpr ) );
     621                        // function call temporaries should be placed at statement-level, rather than nested inside of a new statement expression,
     622                        // since temporaries can be shared across sub-expressions, e.g.
     623                        //   [A, A] f();
     624                        //   g([A] x, [A] y);
     625                        //   f(g());
     626                        // f is executed once, so the return temporary is shared across the tuple constructors for x and y.
     627                        std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
     628                        for ( Statement *& stmt : stmts ) {
     629                                stmt = stmt->acceptMutator( *this );
     630                        } // for
     631                        // stmtExpr = safe_dynamic_cast< StmtExpr * >( Parent::mutate( stmtExpr ) );
    622632                        assert( stmtExpr->get_result() );
    623633                        Type * result = stmtExpr->get_result();
Note: See TracChangeset for help on using the changeset viewer.