Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    ra4dd728 redbdbe6  
    361361                                        FunctionType * ftype = dynamic_cast< FunctionType * >( GenPoly::getFunctionType( funcDecl->get_type() ) );
    362362                                        assert( ftype );
    363                                         if ( (isConstructor( funcDecl->get_name() ) || funcDecl->get_name() == "?=?") && ftype->get_parameters().size() == 2 ) {
     363                                        if ( isConstructor( funcDecl->get_name() ) && ftype->get_parameters().size() == 2 ) {
    364364                                                Type * t1 = ftype->get_parameters().front()->get_type();
    365365                                                Type * t2 = ftype->get_parameters().back()->get_type();
     
    367367
    368368                                                if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
    369                                                         // optimization: don't need to copy construct in order to call a copy constructor or
    370                                                         // assignment operator
     369                                                        // optimization: don't need to copy construct in order to call a copy constructor
    371370                                                        return appExpr;
    372371                                                } // if
     
    636635                                assert( ! stmtExpr->get_returnDecls().empty() );
    637636                                body->get_kids().push_back( new ExprStmt( noLabels, new VariableExpr( stmtExpr->get_returnDecls().front() ) ) );
    638                         }
    639                         stmtExpr->get_returnDecls().clear();
    640                         stmtExpr->get_dtors().clear();
     637                                stmtExpr->get_returnDecls().clear();
     638                                stmtExpr->get_dtors().clear();
     639                        }
     640                        assert( stmtExpr->get_returnDecls().empty() );
     641                        assert( stmtExpr->get_dtors().empty() );
    641642                        return stmtExpr;
    642643                }
     
    655656                                unqExpr->set_result( maybeClone( unqExpr->get_expr()->get_result() ) );
    656657                                if ( unqCount[ unqExpr->get_id() ] == 0 ) {  // insert destructor after the last use of the unique expression
    657                                         stmtsToAdd.splice( stmtsToAddAfter.end(), dtors[ unqExpr->get_id() ] );
     658                                        stmtsToAddAfter.splice( stmtsToAddAfter.end(), dtors[ unqExpr->get_id() ] );
    658659                                }
    659660                                if ( addDeref.count( unqExpr->get_id() ) ) {
     
    667668                        stmtsToAdd.splice( stmtsToAdd.end(), fixer.stmtsToAdd );
    668669                        unqMap[unqExpr->get_id()] = unqExpr;
     670                        if ( unqCount[ unqExpr->get_id() ] == 0 ) {  // insert destructor after the last use of the unique expression
     671                                stmtsToAddAfter.splice( stmtsToAddAfter.end(), dtors[ unqExpr->get_id() ] );
     672                        } else { // remember dtors for last instance of unique expr
     673                                dtors[ unqExpr->get_id() ] = fixer.stmtsToAddAfter;
     674                        }
    669675                        if ( UntypedExpr * deref = dynamic_cast< UntypedExpr * >( unqExpr->get_expr() ) ) {
    670676                                // unique expression is now a dereference, because the inner expression is an lvalue returning function call.
     
    675681                                getCallArg( deref, 0 ) = unqExpr;
    676682                                addDeref.insert( unqExpr->get_id() );
    677                                 if ( unqCount[ unqExpr->get_id() ] == 0 ) {  // insert destructor after the last use of the unique expression
    678                                         stmtsToAdd.splice( stmtsToAddAfter.end(), dtors[ unqExpr->get_id() ] );
    679                                 } else { // remember dtors for last instance of unique expr
    680                                         dtors[ unqExpr->get_id() ] = fixer.stmtsToAddAfter;
    681                                 }
    682683                                return deref;
    683684                        }
Note: See TracChangeset for help on using the changeset viewer.