Changeset 5ccb10d for src/InitTweak
- Timestamp:
- Aug 22, 2017, 6:41:28 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:
- 0b5d871
- Parents:
- d104b02
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
rd104b02 r5ccb10d 591 591 592 592 Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) ); 593 if ( callExpr->get_result()->get_lvalue() ) {594 // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning595 // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the596 // type of the return temporary from T to T* to properly capture the return value. Then dereference597 // the result of the comma expression, since the lvalue returning call was originally wrapped with598 // an AddressExpr. Effectively, this turns599 // lvalue T f();600 // &*f();601 // into602 // T * f();603 // T * tmp_cp_retN;604 // &*(tmp_cp_retN = &*f(), tmp_cp_retN); // the first * and second & are generated here605 // which work out in terms of types, but is pretty messy. It would be nice to find a better way.606 assign->get_args().back() = new AddressExpr( assign->get_args().back() );607 608 returnDecl->set_type( new PointerType( Type::Qualifiers(), returnDecl->get_type() ) );609 retExpr->set_result( new PointerType( Type::Qualifiers(), retExpr->get_result() ) );610 retExpr = UntypedExpr::createDeref( retExpr );611 } // if612 593 // move env from callExpr to retExpr 613 594 retExpr->set_env( callExpr->get_env() );
Note: See TracChangeset
for help on using the changeset viewer.