Changeset 0a81c3f for src/InitTweak
- Timestamp:
- Jul 13, 2017, 1:44:58 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:
- 2463d0e
- Parents:
- c6976ba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
rc6976ba r0a81c3f 364 364 assert( ftype ); 365 365 if ( isConstructor( funcDecl->get_name() ) && ftype->get_parameters().size() == 2 ) { 366 Type * t1 = ftype->get_parameters().front()->get_type();366 Type * t1 = getPointerBase( ftype->get_parameters().front()->get_type() ); 367 367 Type * t2 = ftype->get_parameters().back()->get_type(); 368 PointerType * ptrType = safe_dynamic_cast< PointerType * >( t1 );369 370 if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {368 assert( t1 ); 369 370 if ( ResolvExpr::typesCompatible( t1, t2, SymTab::Indexer() ) ) { 371 371 // optimization: don't need to copy construct in order to call a copy constructor 372 372 return appExpr; … … 489 489 impCpCtorExpr->get_returnDecls().push_back( ret ); 490 490 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; ) 491 if ( ! result->get_lvalue() ) {491 if ( ! dynamic_cast< ReferenceType * >( result ) ) { 492 492 // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary 493 493 destructRet( ret, impCpCtorExpr ); … … 997 997 assert( ! type->get_parameters().empty() ); 998 998 thisParam = safe_dynamic_cast< ObjectDecl * >( type->get_parameters().front() ); 999 PointerType * ptrType = safe_dynamic_cast< PointerType * >( thisParam->get_type() );1000 StructInstType * structType = dynamic_cast< StructInstType * >( ptrType->get_base());999 Type * thisType = getPointerBase( thisParam->get_type() ); 1000 StructInstType * structType = dynamic_cast< StructInstType * >( thisType ); 1001 1001 if ( structType ) { 1002 1002 structDecl = structType->get_baseStruct(); … … 1046 1046 // insert and resolve default/copy constructor call for each field that's unhandled 1047 1047 std::list< Statement * > stmt; 1048 UntypedExpr * deref = UntypedExpr::createDeref( new VariableExpr( thisParam ) );1049 1050 1048 Expression * arg2 = 0; 1051 1049 if ( isCopyConstructor( function ) ) { … … 1056 1054 } 1057 1055 InitExpander srcParam( arg2 ); 1058 SymTab::genImplicitCall( srcParam, new MemberExpr( field, deref), function->get_name(), back_inserter( stmt ), field, isCtor );1056 SymTab::genImplicitCall( srcParam, new MemberExpr( field, new VariableExpr( thisParam ) ), function->get_name(), back_inserter( stmt ), field, isCtor ); 1059 1057 1060 1058 assert( stmt.size() <= 1 );
Note: See TracChangeset
for help on using the changeset viewer.