Changes in src/InitTweak/GenInit.cc [9ff56e7:c6976ba]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
r9ff56e7 rc6976ba 54 54 55 55 protected: 56 FunctionType * ftype ;56 FunctionType * ftype = nullptr; 57 57 std::string funcName; 58 58 }; … … 71 71 // that need to be constructed or destructed 72 72 void previsit( StructDecl *aggregateDecl ); 73 void previsit( __attribute__((unused)) UnionDecl * aggregateDecl ) { visit_children = false; } 74 void previsit( __attribute__((unused)) EnumDecl * aggregateDecl ) { visit_children = false; } 75 void previsit( __attribute__((unused)) TraitDecl * aggregateDecl ) { visit_children = false; } 76 void previsit( __attribute__((unused)) TypeDecl * typeDecl ) { visit_children = false; } 77 void previsit( __attribute__((unused)) TypedefDecl * typeDecl ) { visit_children = false; } 78 void previsit( __attribute__((unused)) FunctionType * funcType ) { visit_children = false; } 73 void previsit( UnionDecl *aggregateDecl ) { visit_children = false; } 74 void previsit( EnumDecl *aggregateDecl ) { visit_children = false; } 75 void previsit( TraitDecl *aggregateDecl ) { visit_children = false; } 76 void previsit( TypeDecl *typeDecl ) { visit_children = false; } 77 void previsit( TypedefDecl *typeDecl ) { visit_children = false; } 78 79 void previsit( FunctionType *funcType ) { visit_children = false; } 79 80 80 81 void previsit( CompoundStmt * compoundStmt ); … … 137 138 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 138 139 assert( returnVals.size() == 0 || returnVals.size() == 1 ); 139 // 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 140 141 // is being returned 141 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() ) ) { 142 143 // explicitly construct the return value using the return expression and the retVal object 143 144 assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() ); 144 UntypedExpr *construct = new UntypedExpr( new NameExpr( "?{}" ) ); 145 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 146 construct->get_args().push_back( returnStmt->get_expr() ); 147 stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct)); 145 146 stmtsToAddBefore.push_back( genCtorDtor( "?{}", dynamic_cast< ObjectDecl *>( returnVals.front() ), returnStmt->get_expr() ) ); 148 147 149 148 // return the retVal object … … 212 211 213 212 bool CtorDtor::isManaged( Type * type ) const { 213 // at least for now, references are never constructed 214 if ( dynamic_cast< ReferenceType * >( type ) ) return false; 214 215 // need to clear and reset qualifiers when determining if a type is managed 215 216 ValueGuard< Type::Qualifiers > qualifiers( type->get_qualifiers() ); … … 238 239 std::list< DeclarationWithType * > & params = GenPoly::getFunctionType( dwt->get_type() )->get_parameters(); 239 240 assert( ! params.empty() ); 240 PointerType * type = safe_dynamic_cast< PointerType * >( params.front()->get_type() ); 241 managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) ); 241 Type * type = InitTweak::getPointerBase( params.front()->get_type() ); 242 assert( type ); 243 managedTypes.insert( SymTab::Mangler::mangle( type ) ); 242 244 } 243 245 } … … 335 337 } 336 338 337 void CtorDtor::previsit( __attribute__((unused))CompoundStmt * compoundStmt ) {339 void CtorDtor::previsit( CompoundStmt * compoundStmt ) { 338 340 GuardScope( managedTypes ); 339 341 }
Note:
See TracChangeset
for help on using the changeset viewer.