Changeset 3aeaecd for src/InitTweak
- Timestamp:
- Sep 25, 2017, 3:26:03 PM (7 years ago)
- 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:
- 696bf6e
- Parents:
- f265042
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
rf265042 r3aeaecd 404 404 result = result->clone(); 405 405 env->apply( result ); 406 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0);406 ObjectDecl * tmp = ObjectDecl::newObject( "__tmp", result, nullptr ); 407 407 tmp->get_type()->set_const( false ); 408 408 … … 418 418 if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) return; 419 419 } 420 421 // set a unique name for the temporary once it's certain the call is necessary 422 tmp->name = tempNamer.newName(); 420 423 421 424 // replace argument to function call with temporary … … 447 450 result = result->clone(); 448 451 env->apply( result ); 449 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0);452 ObjectDecl * ret = ObjectDecl::newObject( retNamer.newName(), result, nullptr ); 450 453 ret->get_type()->set_const( false ); 451 454 impCpCtorExpr->get_returnDecls().push_back( ret ); 452 455 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; ) 453 456 if ( ! dynamic_cast< ReferenceType * >( result ) ) { 454 // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary457 // destructing reference returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary 455 458 destructRet( ret, impCpCtorExpr ); 456 459 } … … 469 472 result = result->clone(); 470 473 env->apply( result ); 471 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0);474 ObjectDecl * ret = ObjectDecl::newObject( retNamer.newName(), result, nullptr ); 472 475 ret->get_type()->set_const( false ); 473 476 stmtExpr->get_returnDecls().push_front( ret ); … … 506 509 } else { 507 510 // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression 508 unqExpr->set_object( new ObjectDecl( toString("_unq", unqExpr->get_id()), Type::StorageClasses(), LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) );511 unqExpr->set_object( ObjectDecl::newObject( toString("_unq", unqExpr->get_id()), unqExpr->get_result()->clone(), nullptr ) ); 509 512 unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) ); 510 513 } … … 1149 1152 1150 1153 // xxx - ideally we would reuse the temporary generated from the copy constructor passes from within firstArg if it exists and not generate a temporary if it's unnecessary. 1151 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );1154 ObjectDecl * tmp = ObjectDecl::newObject( tempNamer.newName(), ctorExpr->get_result()->clone(), nullptr ); 1152 1155 addDeclaration( tmp ); 1153 1156
Note: See TracChangeset
for help on using the changeset viewer.