Changeset c6976ba
- Timestamp:
- Jul 13, 2017, 1:36:00 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:
- 0a81c3f
- Parents:
- c5e3208
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
rc5e3208 rc6976ba 54 54 55 55 protected: 56 FunctionType * ftype ;56 FunctionType * ftype = nullptr; 57 57 std::string funcName; 58 58 }; … … 138 138 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 139 139 assert( returnVals.size() == 0 || returnVals.size() == 1 ); 140 // hands off if the function returns a n lvalue - we don't want to allocate a temporary if a variable's address140 // hands off if the function returns a reference - we don't want to allocate a temporary if a variable's address 141 141 // is being returned 142 if ( returnStmt->get_expr() && returnVals.size() == 1 && ! returnVals.front()->get_type()->get_lvalue() ) {142 if ( returnStmt->get_expr() && returnVals.size() == 1 && ! dynamic_cast< ReferenceType * >( returnVals.front()->get_type() ) ) { 143 143 // explicitly construct the return value using the return expression and the retVal object 144 144 assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() ); 145 UntypedExpr *construct = new UntypedExpr( new NameExpr( "?{}" ) ); 146 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 147 construct->get_args().push_back( returnStmt->get_expr() ); 148 stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct)); 145 146 stmtsToAddBefore.push_back( genCtorDtor( "?{}", dynamic_cast< ObjectDecl *>( returnVals.front() ), returnStmt->get_expr() ) ); 149 147 150 148 // return the retVal object … … 213 211 214 212 bool CtorDtor::isManaged( Type * type ) const { 213 // at least for now, references are never constructed 214 if ( dynamic_cast< ReferenceType * >( type ) ) return false; 215 215 // need to clear and reset qualifiers when determining if a type is managed 216 216 ValueGuard< Type::Qualifiers > qualifiers( type->get_qualifiers() );
Note: See TracChangeset
for help on using the changeset viewer.