Changeset 68f9c43 for src/InitTweak
- Timestamp:
- Mar 16, 2018, 5:15:02 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 8d7bef2
- Parents:
- 6171841
- git-author:
- Aaron Moss <a3moss@…> (03/16/18 17:04:24)
- git-committer:
- Aaron Moss <a3moss@…> (03/16/18 17:15:02)
- Location:
- src/InitTweak
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixGlobalInit.cc
r6171841 r68f9c43 57 57 GlobalFixer & fixer = visitor.pass; 58 58 // don't need to include function if it's empty 59 if ( fixer.initFunction->get_statements()->get_kids().empty() ) { 60 delete fixer.initFunction; 61 } else { 59 if ( ! fixer.initFunction->get_statements()->get_kids().empty() ) { 62 60 translationUnit.push_back( fixer.initFunction ); 63 61 } // if 64 62 65 if ( fixer.destroyFunction->get_statements()->get_kids().empty() ) { 66 delete fixer.destroyFunction; 67 } else { 63 if ( ! fixer.destroyFunction->get_statements()->get_kids().empty() ) { 68 64 translationUnit.push_back( fixer.destroyFunction ); 69 65 } // if … … 130 126 objDecl->set_init( NULL ); 131 127 } // if 132 delete ctorInit;133 128 } // if 134 129 } -
src/InitTweak/FixInit.cc
r6171841 r68f9c43 454 454 resolved->env = nullptr; 455 455 } // if 456 delete stmt;457 456 if ( TupleAssignExpr * assign = dynamic_cast< TupleAssignExpr * >( resolved ) ) { 458 457 // fix newly generated StmtExpr … … 554 553 result = result->clone(); 555 554 env->apply( result ); 556 if ( ! InitTweak::isConstructable( result ) ) { 557 delete result; 558 return; 559 } 555 if ( ! InitTweak::isConstructable( result ) ) return; 560 556 561 557 // create variable that will hold the result of the stmt expr … … 652 648 std::swap( impCpCtorExpr->env, callExpr->env ); 653 649 assert( impCpCtorExpr->env == nullptr ); 654 delete impCpCtorExpr;655 650 656 651 if ( returnDecl ) { … … 711 706 if ( unqMap.count( unqExpr->get_id() ) ) { 712 707 // take data from other UniqueExpr to ensure consistency 713 delete unqExpr->get_expr();714 708 unqExpr->set_expr( unqMap[unqExpr->get_id()]->get_expr()->clone() ); 715 delete unqExpr->get_result();716 709 unqExpr->set_result( maybeClone( unqExpr->get_expr()->get_result() ) ); 717 710 if ( unqCount[ unqExpr->get_id() ] == 0 ) { // insert destructor after the last use of the unique expression … … 824 817 // create a new object which is never used 825 818 static UniqueName dummyNamer( "_dummy" ); 826 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } ); 827 delete ctorInit; 828 return dummy; 819 return new ObjectDecl{ 820 dummyNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, 821 new PointerType{ Type::Qualifiers(), new VoidType( Type::Qualifiers() ) }, 822 0, std::list< Attribute * >{ new Attribute("unused") } }; 829 823 } 830 824 } else { … … 852 846 objDecl->init = nullptr; 853 847 } // if 854 delete ctorInit;855 848 } // if 856 849 return objDecl; … … 1228 1221 ObjectDecl * tmp = ObjectDecl::newObject( tempNamer.newName(), callExpr->args.front()->result->clone(), nullptr ); 1229 1222 declsToAddBefore.push_back( tmp ); 1230 delete ctorExpr;1231 1223 1232 1224 // build assignment and replace constructor's first argument with new temporary … … 1237 1229 // resolve assignment and dispose of new env 1238 1230 ResolvExpr::findVoidExpression( assign, indexer ); 1239 delete assign->env;1240 1231 assign->env = nullptr; 1241 1232 -
src/InitTweak/InitTweak.cc
r6171841 r68f9c43 122 122 public: 123 123 ExprImpl( Expression * expr ) : arg( expr ) {} 124 virtual ~ExprImp l() { delete arg; }124 virtual ~ExprImp() = default; 125 125 126 126 virtual std::list< Expression * > next( std::list< Expression * > & indices ) { … … 166 166 167 167 void InitExpander::clearArrayIndices() { 168 deleteAll( indices );169 168 indices.clear(); 170 169 } … … 263 262 build( dst, indices.begin(), indices.end(), init, back_inserter( block->get_kids() ) ); 264 263 if ( block->get_kids().empty() ) { 265 delete block;266 264 return nullptr; 267 265 } else {
Note: See TracChangeset
for help on using the changeset viewer.