Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r64ac636 r233e4d9  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:08:04 2017
    13 // Update Count     : 67
     12// Last Modified On : Fri Mar 17 09:13:47 2017
     13// Update Count     : 71
    1414//
    1515
     
    434434                        env->apply( result );
    435435                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 );
    436                         tmp->get_type()->set_isConst( false );
     436                        tmp->get_type()->set_const( false );
    437437
    438438                        // create and resolve copy constructor
     
    480480                                env->apply( result );
    481481                                ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 );
    482                                 ret->get_type()->set_isConst( false );
     482                                ret->get_type()->set_const( false );
    483483                                impCpCtorExpr->get_returnDecls().push_back( ret );
    484484                                CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
    485                                 if ( ! result->get_isLvalue() ) {
     485                                if ( ! result->get_lvalue() ) {
    486486                                        // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary
    487487                                        destructRet( ret, impCpCtorExpr );
     
    503503                                env->apply( result );
    504504                                ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 );
    505                                 ret->get_type()->set_isConst( false );
     505                                ret->get_type()->set_const( false );
    506506                                stmtExpr->get_returnDecls().push_front( ret );
    507507
     
    534534                        } else {
    535535                                // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression
    536                                 unqExpr->set_object( new ObjectDecl( toString("_unq_expr_", unqExpr->get_id()), Type::StorageClasses(), LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) );
     536                                unqExpr->set_object( new ObjectDecl( toString("_unq", unqExpr->get_id()), Type::StorageClasses(), LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) );
    537537                                unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) );
    538538                        }
     
    584584
    585585                                Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) );
    586                                 if ( callExpr->get_result()->get_isLvalue() ) {
     586                                if ( callExpr->get_result()->get_lvalue() ) {
    587587                                        // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning
    588588                                        // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the
     
    764764                                                }
    765765                                        } else {
    766                                                 stmtsToAddAfter.push_back( ctor );
     766                                                ImplicitCtorDtorStmt * implicit = safe_dynamic_cast< ImplicitCtorDtorStmt * > ( ctor );
     767                                                ExprStmt * ctorStmt = dynamic_cast< ExprStmt * >( implicit->get_callStmt() );
     768                                                ApplicationExpr * ctorCall = nullptr;
     769                                                if ( ctorStmt && (ctorCall = isIntrinsicCallExpr( ctorStmt->get_expr() )) && ctorCall->get_args().size() == 2 ) {
     770                                                        // clean up intrinsic copy constructor calls by making them into SingleInits
     771                                                        objDecl->set_init( new SingleInit( ctorCall->get_args().back() ) );
     772                                                        ctorCall->get_args().pop_back();
     773                                                } else {
     774                                                        stmtsToAddAfter.push_back( ctor );
     775                                                        objDecl->set_init( NULL );
     776                                                        ctorInit->set_ctor( NULL );
     777                                                }
    767778                                        } // if
    768                                         objDecl->set_init( NULL );
    769                                         ctorInit->set_ctor( NULL );
    770779                                } else if ( Initializer * init = ctorInit->get_init() ) {
    771780                                        objDecl->set_init( init );
Note: See TracChangeset for help on using the changeset viewer.