Changeset 4ffdd63 for src/InitTweak
- Timestamp:
- Apr 27, 2016, 5:16:22 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 21ae786
- Parents:
- c2ce2350
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
rc2ce2350 r4ffdd63 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Apr 26 14:57:13201612 // Last Modified On : Wed Apr 27 17:08:44 2016 13 13 // Update Count : 30 14 14 // … … 216 216 if ( function->get_var()->get_linkage() != LinkageSpec::Intrinsic ) { 217 217 // replace argument to function call with temporary 218 arg = new VariableExpr( tmp);218 arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) ); 219 219 impCpCtorExpr->get_tempDecls().push_back( tmp ); 220 impCpCtorExpr->get_copyCtors().push_back( cpCtor );221 220 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) ); 222 221 } … … 232 231 callExpr->set_env( impCpCtorExpr->get_env()->clone() ); 233 232 for ( Type * result : appExpr->get_results() ) { 234 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result->clone(), new SingleInit( callExpr ));233 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result->clone(), 0 ); 235 234 ret->get_type()->set_isConst( false ); 236 235 impCpCtorExpr->get_returnDecls().push_back( ret ); … … 249 248 assert( impCpCtorExpr ); 250 249 251 std::list< Expression * > & copyCtors = impCpCtorExpr->get_copyCtors();252 250 std::list< ObjectDecl * > & tempDecls = impCpCtorExpr->get_tempDecls(); 253 251 std::list< ObjectDecl * > & returnDecls = impCpCtorExpr->get_returnDecls(); … … 256 254 // add all temporary declarations and their constructors 257 255 for ( ObjectDecl * obj : tempDecls ) { 258 assert( ! copyCtors.empty() );259 256 stmtsToAdd.push_back( new DeclStmt( noLabels, obj ) ); 260 stmtsToAdd.push_back( new ExprStmt( noLabels, copyCtors.front() ) ); 261 copyCtors.pop_front(); 257 } 258 for ( ObjectDecl * obj : returnDecls ) { 259 stmtsToAdd.push_back( new DeclStmt( noLabels, obj ) ); 262 260 } 263 261 … … 274 272 275 273 // xxx - some of these aren't necessary, and can be removed once this is stable 276 copyCtors.clear();277 274 dtors.clear(); 278 275 tempDecls.clear(); … … 282 279 283 280 if ( returnDecl ) { 284 // call is currently attached to first returnDecl 285 stmtsToAdd.push_back( new DeclStmt( noLabels, returnDecl ) ); 286 return new VariableExpr( returnDecl ); 281 UntypedExpr * assign = new UntypedExpr( new NameExpr( "?=?" ) ); 282 assign->get_args().push_back( new VariableExpr( returnDecl ) ); 283 assign->get_args().push_back( callExpr ); 284 // know the result type of the assignment is the type of the LHS (minus the pointer), so 285 // add that onto the assignment expression so that later steps have the necessary information 286 assign->add_result( returnDecl->get_type()->clone() ); 287 // return new CommaExpr( assign, new VariableExpr( returnDecl ) ); 288 return assign; 287 289 } else { 288 // add call expression - if no return values, can call directly289 assert( callExpr );290 290 return callExpr; 291 291 }
Note: See TracChangeset
for help on using the changeset viewer.