Changeset 6b224a52 for src/InitTweak/GenInit.cc
- Timestamp:
- Aug 25, 2017, 12:11:53 PM (8 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:
- bf7b9da7
- Parents:
- 135b431 (diff), f676b84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/InitTweak/GenInit.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
r135b431 r6b224a52 21 21 #include <list> // for _List_iterator, list 22 22 23 #include "CodeGen/OperatorTable.h" 23 24 #include "Common/PassVisitor.h" // for PassVisitor, WithGuards, WithShort... 24 25 #include "Common/SemanticError.h" // for SemanticError … … 57 58 58 59 protected: 59 FunctionType * ftype ;60 FunctionType * ftype = nullptr; 60 61 std::string funcName; 61 62 }; … … 140 141 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 141 142 assert( returnVals.size() == 0 || returnVals.size() == 1 ); 142 // hands off if the function returns a n lvalue - we don't want to allocate a temporary if a variable's address143 // hands off if the function returns a reference - we don't want to allocate a temporary if a variable's address 143 144 // is being returned 144 if ( returnStmt->get_expr() && returnVals.size() == 1 && ! returnVals.front()->get_type()->get_lvalue() ) {145 if ( returnStmt->get_expr() && returnVals.size() == 1 && ! dynamic_cast< ReferenceType * >( returnVals.front()->get_type() ) ) { 145 146 // explicitly construct the return value using the return expression and the retVal object 146 147 assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() ); 147 UntypedExpr *construct = new UntypedExpr( new NameExpr( "?{}" ) ); 148 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 149 construct->get_args().push_back( returnStmt->get_expr() ); 150 stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct)); 148 149 stmtsToAddBefore.push_back( genCtorDtor( "?{}", dynamic_cast< ObjectDecl *>( returnVals.front() ), returnStmt->get_expr() ) ); 151 150 152 151 // return the retVal object … … 215 214 216 215 bool CtorDtor::isManaged( Type * type ) const { 216 // at least for now, references are never constructed 217 if ( dynamic_cast< ReferenceType * >( type ) ) return false; 217 218 // need to clear and reset qualifiers when determining if a type is managed 218 219 ValueGuard< Type::Qualifiers > qualifiers( type->get_qualifiers() ); … … 238 239 void CtorDtor::handleDWT( DeclarationWithType * dwt ) { 239 240 // if this function is a user-defined constructor or destructor, mark down the type as "managed" 240 if ( ! LinkageSpec::isOverridable( dwt->get_linkage() ) && isCtorDtor( dwt->get_name() ) ) {241 if ( ! LinkageSpec::isOverridable( dwt->get_linkage() ) && CodeGen::isCtorDtor( dwt->get_name() ) ) { 241 242 std::list< DeclarationWithType * > & params = GenPoly::getFunctionType( dwt->get_type() )->get_parameters(); 242 243 assert( ! params.empty() ); 243 PointerType * type = safe_dynamic_cast< PointerType * >( params.front()->get_type() ); 244 managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) ); 244 Type * type = InitTweak::getPointerBase( params.front()->get_type() ); 245 assert( type ); 246 managedTypes.insert( SymTab::Mangler::mangle( type ) ); 245 247 } 246 248 }
Note:
See TracChangeset
for help on using the changeset viewer.