Changes in src/InitTweak/GenInit.cc [c6976ba:9ff56e7]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
rc6976ba r9ff56e7 54 54 55 55 protected: 56 FunctionType * ftype = nullptr;56 FunctionType * ftype; 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( 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; } 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; } 80 79 81 80 void previsit( CompoundStmt * compoundStmt ); … … 138 137 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 139 138 assert( returnVals.size() == 0 || returnVals.size() == 1 ); 140 // hands off if the function returns a reference - we don't want to allocate a temporary if a variable's address139 // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address 141 140 // is being returned 142 if ( returnStmt->get_expr() && returnVals.size() == 1 && ! dynamic_cast< ReferenceType * >( returnVals.front()->get_type()) ) {141 if ( returnStmt->get_expr() && returnVals.size() == 1 && ! returnVals.front()->get_type()->get_lvalue() ) { 143 142 // explicitly construct the return value using the return expression and the retVal object 144 143 assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() ); 145 146 stmtsToAddBefore.push_back( genCtorDtor( "?{}", dynamic_cast< ObjectDecl *>( returnVals.front() ), returnStmt->get_expr() ) ); 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)); 147 148 148 149 // return the retVal object … … 211 212 212 213 bool CtorDtor::isManaged( Type * type ) const { 213 // at least for now, references are never constructed214 if ( dynamic_cast< ReferenceType * >( type ) ) return false;215 214 // need to clear and reset qualifiers when determining if a type is managed 216 215 ValueGuard< Type::Qualifiers > qualifiers( type->get_qualifiers() ); … … 239 238 std::list< DeclarationWithType * > & params = GenPoly::getFunctionType( dwt->get_type() )->get_parameters(); 240 239 assert( ! params.empty() ); 241 Type * type = InitTweak::getPointerBase( params.front()->get_type() ); 242 assert( type ); 243 managedTypes.insert( SymTab::Mangler::mangle( type ) ); 240 PointerType * type = safe_dynamic_cast< PointerType * >( params.front()->get_type() ); 241 managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) ); 244 242 } 245 243 } … … 337 335 } 338 336 339 void CtorDtor::previsit( CompoundStmt * compoundStmt ) {337 void CtorDtor::previsit( __attribute__((unused)) CompoundStmt * compoundStmt ) { 340 338 GuardScope( managedTypes ); 341 339 }
Note:
See TracChangeset
for help on using the changeset viewer.