Changeset 68f9c43
- Timestamp:
- Mar 16, 2018, 5:15:02 PM (5 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
- Files:
-
- 4 added
- 79 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/Generate.cc
r6171841 r68f9c43 41 41 void cleanTree( std::list< Declaration * > & translationUnit ) { 42 42 PassVisitor<TreeCleaner> cleaner; 43 filter( translationUnit, [](Declaration * decl) { return TreeCleaner::shouldClean(decl); } , false);43 filter( translationUnit, [](Declaration * decl) { return TreeCleaner::shouldClean(decl); } ); 44 44 mutateAll( translationUnit, cleaner ); 45 45 } // cleanTree … … 79 79 } 80 80 return false; 81 } , false);81 } ); 82 82 } 83 83 … … 85 85 Statement * callStmt = nullptr; 86 86 std::swap( stmt->callStmt, callStmt ); 87 delete stmt;88 87 return callStmt; 89 88 } -
src/Common/PassVisitor.h
r6171841 r68f9c43 152 152 virtual void visit( Attribute * attribute ) override final; 153 153 154 virtual void visit( TypeSubstitution * sub ) final; 155 154 156 virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) override final; 155 157 virtual DeclarationWithType * mutate( FunctionDecl * functionDecl ) override final; -
src/Common/PassVisitor.impl.h
r6171841 r68f9c43 2556 2556 // TypeSubstitution 2557 2557 template< typename pass_type > 2558 void PassVisitor< pass_type >::visit( TypeSubstitution * node ) { 2559 VISIT_START( node ); 2560 2561 for ( auto & p : node->typeEnv ) { 2562 indexerScopedAccept( p.second, *this ); 2563 } 2564 for ( auto & p : node->varEnv ) { 2565 indexerScopedAccept( p.second, *this ); 2566 } 2567 2568 VISIT_END( node ); 2569 } 2570 2571 template< typename pass_type > 2558 2572 TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) { 2559 2573 MUTATE_START( node ); -
src/Common/module.mk
r6171841 r68f9c43 18 18 Common/UniqueName.cc \ 19 19 Common/DebugMalloc.cc \ 20 Common/GC.cc \ 20 21 Common/Assert.cc -
src/Common/utility.h
r6171841 r68f9c43 190 190 191 191 template <typename E, typename UnaryPredicate, template< typename, typename...> class Container, typename... Args > 192 void filter( Container< E *, Args... > & container, UnaryPredicate pred , bool doDelete) {192 void filter( Container< E *, Args... > & container, UnaryPredicate pred ) { 193 193 auto i = begin( container ); 194 194 while ( i != end( container ) ) { 195 195 auto it = next( i ); 196 196 if ( pred( *i ) ) { 197 if ( doDelete ) {198 delete *i;199 } // if200 197 container.erase( i ); 201 198 } // if -
src/Concurrency/Keywords.cc
r6171841 r68f9c43 291 291 StructDecl * forward = decl->clone(); 292 292 forward->set_body( false ); 293 deleteAll( forward->get_members() );294 293 forward->get_members().clear(); 295 294 … … 355 354 fixupGenerics(main_type, decl); 356 355 } 357 358 delete this_decl;359 356 360 357 declsToAddBefore.push_back( forward ); -
src/Concurrency/Waitfor.cc
r6171841 r68f9c43 476 476 } 477 477 478 delete setter;479 480 478 return new VariableExpr( timeout ); 481 479 } -
src/ControlStruct/ExceptTranslate.cc
r6171841 r68f9c43 204 204 call->get_args().push_back( throwStmt->get_expr() ); 205 205 throwStmt->set_expr( nullptr ); 206 delete throwStmt;207 206 return new ExprStmt( call ); 208 207 } … … 234 233 new UntypedExpr( new NameExpr( "__cfaabi_ehm__rethrow_terminate" ) ) 235 234 ) ); 236 delete throwStmt;237 235 return result; 238 236 } … … 251 249 ); 252 250 result->labels = throwStmt->labels; 253 delete throwStmt;254 251 return result; 255 252 } … … 384 381 modded_handler->set_cond( nullptr ); 385 382 modded_handler->set_body( nullptr ); 386 delete modded_handler;387 383 return block; 388 384 } … … 530 526 CompoundStmt * body = finally->get_block(); 531 527 finally->set_block( nullptr ); 532 delete finally;533 528 tryStmt->set_finally( nullptr ); 534 529 -
src/ControlStruct/MLEMutator.cc
r6171841 r68f9c43 151 151 152 152 // transform break/continue statements into goto to simplify later handling of branches 153 delete branchStmt;154 153 return new BranchStmt( exitLabel, BranchStmt::Goto ); 155 154 } -
src/GenPoly/Box.cc
r6171841 r68f9c43 860 860 // do not carry over attributes to real type parameters/return values 861 861 for ( DeclarationWithType * dwt : realType->parameters ) { 862 deleteAll( dwt->get_type()->attributes );863 862 dwt->get_type()->attributes.clear(); 864 863 } 865 864 for ( DeclarationWithType * dwt : realType->returnVals ) { 866 deleteAll( dwt->get_type()->attributes );867 865 dwt->get_type()->attributes.clear(); 868 866 } … … 985 983 } // if 986 984 appExpr->get_args().clear(); 987 delete appExpr;988 985 return addAssign; 989 986 } … … 1016 1013 } // if 1017 1014 if ( baseType1 || baseType2 ) { 1018 delete ret->get_result();1019 1015 ret->set_result( appExpr->get_result()->clone() ); 1020 1016 if ( appExpr->get_env() ) { … … 1023 1019 } // if 1024 1020 appExpr->get_args().clear(); 1025 delete appExpr;1026 1021 return ret; 1027 1022 } // if … … 1033 1028 Expression *ret = appExpr->get_args().front(); 1034 1029 // fix expr type to remove pointer 1035 delete ret->get_result();1036 1030 ret->set_result( appExpr->get_result()->clone() ); 1037 1031 if ( appExpr->get_env() ) { … … 1040 1034 } // if 1041 1035 appExpr->get_args().clear(); 1042 delete appExpr;1043 1036 return ret; 1044 1037 } // if … … 1180 1173 Expression *ret = expr->args.front(); 1181 1174 expr->args.clear(); 1182 delete expr;1183 1175 return ret; 1184 1176 } // if … … 1214 1206 if ( polytype || needs ) { 1215 1207 Expression *ret = addrExpr->arg; 1216 delete ret->result;1217 1208 ret->result = addrExpr->result->clone(); 1218 1209 addrExpr->arg = nullptr; 1219 delete addrExpr;1220 1210 return ret; 1221 1211 } else { … … 1227 1217 if ( retval && returnStmt->expr ) { 1228 1218 assert( returnStmt->expr->result && ! returnStmt->expr->result->isVoid() ); 1229 delete returnStmt->expr;1230 1219 returnStmt->expr = nullptr; 1231 1220 } // if … … 1270 1259 } 1271 1260 } 1272 // deleteAll( functions );1273 1261 } 1274 1262 … … 1290 1278 for ( Declaration * param : functionDecl->type->parameters ) { 1291 1279 if ( ObjectDecl * obj = dynamic_cast< ObjectDecl * >( param ) ) { 1292 delete obj->init;1293 1280 obj->init = nullptr; 1294 1281 } … … 1499 1486 // polymorphic aggregate members should be converted into monomorphic members. 1500 1487 // Using char[size_T] here respects the expected sizing rules of an aggregate type. 1501 Type * newType = polyToMonoType( field->type ); 1502 delete field->type; 1503 field->type = newType; 1488 field->type = polyToMonoType( field->type ); 1504 1489 } 1505 1490 } … … 1524 1509 stmtsToAddBefore.push_back( new DeclStmt( newBuf ) ); 1525 1510 1526 delete objectDecl->get_init();1527 1511 objectDecl->set_init( new SingleInit( new VariableExpr( newBuf ) ) ); 1528 1512 } … … 1603 1587 } 1604 1588 1605 delete memberType;1606 delete memberExpr;1607 1589 return newMemberExpr; 1608 1590 } … … 1624 1606 addrExpr->arg = nullptr; 1625 1607 std::swap( addrExpr->env, ret->env ); 1626 delete addrExpr;1627 1608 return ret; 1628 1609 } … … 1750 1731 Type *ty = sizeofExpr->get_isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result(); 1751 1732 if ( findGeneric( ty ) ) { 1752 Expression *ret = new NameExpr( sizeofName( mangleType( ty ) ) ); 1753 delete sizeofExpr; 1754 return ret; 1733 return new NameExpr( sizeofName( mangleType( ty ) ) ); 1755 1734 } 1756 1735 return sizeofExpr; … … 1760 1739 Type *ty = alignofExpr->get_isType() ? alignofExpr->get_type() : alignofExpr->get_expr()->get_result(); 1761 1740 if ( findGeneric( ty ) ) { 1762 Expression *ret = new NameExpr( alignofName( mangleType( ty ) ) ); 1763 delete alignofExpr; 1764 return ret; 1741 return new NameExpr( alignofName( mangleType( ty ) ) ); 1765 1742 } 1766 1743 return alignofExpr; … … 1777 1754 if ( i == -1 ) return offsetofExpr; 1778 1755 1779 Expression *offsetInd = makeOffsetIndex( ty, i ); 1780 delete offsetofExpr; 1781 return offsetInd; 1756 return makeOffsetIndex( ty, i ); 1782 1757 } else if ( dynamic_cast< UnionInstType* >( ty ) ) { 1783 1758 // all union members are at offset zero 1784 delete offsetofExpr;1785 1759 return new ConstantExpr( Constant::from_ulong( 0 ) ); 1786 1760 } else return offsetofExpr; … … 1822 1796 } 1823 1797 1824 delete offsetPackExpr;1825 1798 return ret; 1826 1799 } -
src/GenPoly/InstantiateGeneric.cc
r6171841 r68f9c43 58 58 59 59 TypeList& operator= ( const TypeList &that ) { 60 deleteAll( params );61 62 60 params.clear(); 63 61 cloneAll( that.params, params ); … … 67 65 68 66 TypeList& operator= ( TypeList &&that ) { 69 deleteAll( params );70 71 67 params = std::move( that.params ); 72 68 … … 74 70 } 75 71 76 ~TypeList() { deleteAll( params );}72 ~TypeList() {} 77 73 78 74 bool operator== ( const TypeList& that ) const { … … 293 289 /// Strips the instances's type parameters 294 290 void stripInstParams( ReferenceToType *inst ) { 295 deleteAll( inst->get_parameters() );296 291 inst->get_parameters().clear(); 297 292 } … … 300 295 substituteMembers( base->get_members(), baseParams, typeSubs ); 301 296 302 // xxx - can't delete type parameters because they may have assertions that are used303 // deleteAll( baseParams );304 297 baseParams.clear(); 305 298 … … 380 373 newInst->set_baseStruct( concDecl ); 381 374 382 delete inst;383 375 inst = newInst; 384 376 break; … … 390 382 } 391 383 392 deleteAll( typeSubs );393 384 return inst; 394 385 } … … 430 421 newInst->set_baseUnion( concDecl ); 431 422 432 delete inst;433 423 inst = newInst; 434 424 break; … … 439 429 } 440 430 441 deleteAll( typeSubs );442 431 return inst; 443 432 } … … 477 466 ResolvExpr::adjustExprType( ret->result ); // pointer decay 478 467 std::swap( ret->env, memberExpr->env ); 479 delete memberExpr;480 468 return ret; 481 469 } -
src/GenPoly/Lvalue.cc
r6171841 r68f9c43 50 50 assertf( base, "expected pointer type in dereference (type was %s)", toString( arg->result ).c_str() ); 51 51 ApplicationExpr * ret = new ApplicationExpr( deref, { arg } ); 52 delete ret->result;53 52 ret->result = base->clone(); 54 53 ret->result->set_lvalue( true ); … … 171 170 return ret; 172 171 } 173 delete result;174 172 } 175 173 return appExpr; … … 214 212 Type * baseType = InitTweak::getPointerBase( arg->get_result() ); 215 213 assertf( baseType, "parameter is reference, arg must be pointer or reference: %s", toString( arg->get_result() ).c_str() ); 216 PointerType * ptrType = new PointerType( Type::Qualifiers(), baseType->clone() ); 217 delete arg->get_result(); 218 arg->set_result( ptrType ); 214 arg->set_result( new PointerType{ Type::Qualifiers(), baseType->clone() } ); 219 215 arg = mkDeref( arg ); 220 216 } … … 294 290 ) 295 291 callExpr = new AddressExpr( callExpr ); // this doesn't work properly for multiple casts 296 delete callExpr->get_result();297 292 callExpr->set_result( refType->clone() ); 298 293 // move environment out to new top-level … … 300 295 castExpr->set_arg( nullptr ); 301 296 castExpr->set_env( nullptr ); 302 delete castExpr;303 297 return callExpr; 304 298 } … … 318 312 } 319 313 ret->env = castExpr->env; 320 delete ret->result;321 314 ret->result = castExpr->result; 322 315 ret->result->set_lvalue( true ); // ensure result is lvalue … … 324 317 castExpr->arg = nullptr; 325 318 castExpr->result = nullptr; 326 delete castExpr;327 319 return ret; 328 320 } else if ( diff > 0 ) { … … 333 325 } 334 326 ret->env = castExpr->env; 335 delete ret->result;336 327 ret->result = castExpr->result; 337 328 castExpr->env = nullptr; 338 329 castExpr->arg = nullptr; 339 330 castExpr->result = nullptr; 340 delete castExpr;341 331 return ret; 342 332 } … … 360 350 } 361 351 ret->env = castExpr->env; 362 delete ret->result;363 352 ret->result = castExpr->result; 364 353 castExpr->env = nullptr; 365 354 castExpr->arg = nullptr; 366 355 castExpr->result = nullptr; 367 delete castExpr;368 356 return ret; 369 357 } else { … … 390 378 ret->result->set_lvalue( true ); // ensure result is lvalue 391 379 castExpr->arg = nullptr; 392 delete castExpr;393 380 } else { 394 381 // must keep cast if types are different … … 407 394 Type::Qualifiers qualifiers = refType->get_qualifiers(); 408 395 refType->set_base( nullptr ); 409 delete refType;410 396 return new PointerType( qualifiers, base ); 411 397 } … … 419 405 ret->set_env( expr->get_env() ); 420 406 expr->set_env( nullptr ); 421 delete expr;422 407 return ret; 423 408 } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( arg ) ) { … … 428 413 ret->set_env( expr->get_env() ); 429 414 expr->set_env( nullptr ); 430 delete expr;431 415 432 416 // conditional expr type may not be either of the argument types, need to unify … … 461 445 arg0 = nullptr; 462 446 addrExpr->set_env( nullptr ); 463 delete addrExpr;464 447 return ret; 465 448 } … … 491 474 addrExpr->set_arg( nullptr ); 492 475 appExpr->set_env( nullptr ); 493 delete appExpr;494 476 return ret; 495 477 } -
src/GenPoly/ScrubTyVars.cc
r6171841 r68f9c43 28 28 if ( ! tyVars ) { 29 29 if ( typeInst->get_isFtype() ) { 30 delete typeInst; 31 return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 30 return new PointerType{ Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) }; 32 31 } else { 33 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) ); 34 delete typeInst; 35 return ret; 32 return new PointerType{ Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) }; 36 33 } 37 34 } … … 42 39 case TypeDecl::Dtype: 43 40 case TypeDecl::Ttype: 44 { 45 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) ); 46 delete typeInst; 47 return ret; 48 } 41 return new PointerType{ Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) }; 49 42 case TypeDecl::Ftype: 50 delete typeInst; 51 return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 43 return new PointerType{ Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) }; 52 44 } // switch 53 45 } // if … … 57 49 Type * ScrubTyVars::mutateAggregateType( Type * ty ) { 58 50 if ( shouldScrub( ty ) ) { 59 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) ); 60 delete ty; 61 return ret; 51 return new PointerType{ Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) }; 62 52 } 63 53 return ty; … … 104 94 Type * ret = dynType->acceptMutator( *visitor ); 105 95 ret->get_qualifiers() |= pointer->get_qualifiers(); 106 pointer->base = nullptr;107 delete pointer;108 96 return ret; 109 97 } -
src/GenPoly/Specialize.cc
r6171841 r68f9c43 193 193 explodeSimple( new TupleIndexExpr( expr->clone(), i ), out ); 194 194 } 195 delete expr;196 195 } else { 197 196 // non-tuple type - output a clone of the expression -
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 { -
src/MakeLibCfa.cc
r6171841 r68f9c43 65 65 struct ZeroOneReplacer { 66 66 ZeroOneReplacer( Type * t ) : type( t ) {} 67 ~ZeroOneReplacer() { delete type; }68 67 Type * type = nullptr; 69 68 70 69 Type * common( Type * t ) { 71 70 if ( ! type ) return t; 72 delete t;73 71 return type->clone(); 74 72 } -
src/Makefile.in
r6171841 r68f9c43 163 163 Common/driver_cfa_cpp-UniqueName.$(OBJEXT) \ 164 164 Common/driver_cfa_cpp-DebugMalloc.$(OBJEXT) \ 165 Common/driver_cfa_cpp-GC.$(OBJEXT) \ 165 166 Common/driver_cfa_cpp-Assert.$(OBJEXT) \ 166 167 ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) \ … … 249 250 SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \ 250 251 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \ 252 SynTree/driver_cfa_cpp-GcTracer.$(OBJEXT) \ 251 253 SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT) \ 252 254 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \ … … 485 487 CodeTools/TrackLoc.cc Concurrency/Keywords.cc \ 486 488 Concurrency/Waitfor.cc Common/SemanticError.cc \ 487 Common/UniqueName.cc Common/DebugMalloc.cc Common/ Assert.cc \488 Co ntrolStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \489 ControlStruct/ MLEMutator.cc ControlStruct/Mutate.cc \490 ControlStruct/ ForExprMutator.cc \489 Common/UniqueName.cc Common/DebugMalloc.cc Common/GC.cc \ 490 Common/Assert.cc ControlStruct/LabelGenerator.cc \ 491 ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \ 492 ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \ 491 493 ControlStruct/ExceptTranslate.cc GenPoly/Box.cc \ 492 494 GenPoly/GenPoly.cc GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc \ … … 526 528 SynTree/NamedTypeDecl.cc SynTree/TypeDecl.cc \ 527 529 SynTree/Initializer.cc SynTree/TypeSubstitution.cc \ 528 SynTree/Attribute.cc SynTree/VarExprReplacer.cc \ 529 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \ 530 Tuples/Explode.cc Virtual/ExpandCasts.cc 530 SynTree/Attribute.cc SynTree/GcTracer.cc \ 531 SynTree/VarExprReplacer.cc Tuples/TupleAssignment.cc \ 532 Tuples/TupleExpansion.cc Tuples/Explode.cc \ 533 Virtual/ExpandCasts.cc 531 534 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 532 535 ${cfa_cpplib_PROGRAMS}} … … 670 673 Common/$(DEPDIR)/$(am__dirstamp) 671 674 Common/driver_cfa_cpp-DebugMalloc.$(OBJEXT): Common/$(am__dirstamp) \ 675 Common/$(DEPDIR)/$(am__dirstamp) 676 Common/driver_cfa_cpp-GC.$(OBJEXT): Common/$(am__dirstamp) \ 672 677 Common/$(DEPDIR)/$(am__dirstamp) 673 678 Common/driver_cfa_cpp-Assert.$(OBJEXT): Common/$(am__dirstamp) \ … … 912 917 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \ 913 918 SynTree/$(DEPDIR)/$(am__dirstamp) 919 SynTree/driver_cfa_cpp-GcTracer.$(OBJEXT): SynTree/$(am__dirstamp) \ 920 SynTree/$(DEPDIR)/$(am__dirstamp) 914 921 SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT): \ 915 922 SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp) … … 973 980 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Assert.Po@am__quote@ 974 981 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-DebugMalloc.Po@am__quote@ 982 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-GC.Po@am__quote@ 975 983 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@ 976 984 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-UniqueName.Po@am__quote@ … … 1045 1053 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-FunctionDecl.Po@am__quote@ 1046 1054 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-FunctionType.Po@am__quote@ 1055 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-GcTracer.Po@am__quote@ 1047 1056 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Initializer.Po@am__quote@ 1048 1057 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-NamedTypeDecl.Po@am__quote@ … … 1294 1303 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-DebugMalloc.obj `if test -f 'Common/DebugMalloc.cc'; then $(CYGPATH_W) 'Common/DebugMalloc.cc'; else $(CYGPATH_W) '$(srcdir)/Common/DebugMalloc.cc'; fi` 1295 1304 1305 Common/driver_cfa_cpp-GC.o: Common/GC.cc 1306 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-GC.o -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo -c -o Common/driver_cfa_cpp-GC.o `test -f 'Common/GC.cc' || echo '$(srcdir)/'`Common/GC.cc 1307 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo Common/$(DEPDIR)/driver_cfa_cpp-GC.Po 1308 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Common/GC.cc' object='Common/driver_cfa_cpp-GC.o' libtool=no @AMDEPBACKSLASH@ 1309 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1310 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-GC.o `test -f 'Common/GC.cc' || echo '$(srcdir)/'`Common/GC.cc 1311 1312 Common/driver_cfa_cpp-GC.obj: Common/GC.cc 1313 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-GC.obj -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo -c -o Common/driver_cfa_cpp-GC.obj `if test -f 'Common/GC.cc'; then $(CYGPATH_W) 'Common/GC.cc'; else $(CYGPATH_W) '$(srcdir)/Common/GC.cc'; fi` 1314 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo Common/$(DEPDIR)/driver_cfa_cpp-GC.Po 1315 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Common/GC.cc' object='Common/driver_cfa_cpp-GC.obj' libtool=no @AMDEPBACKSLASH@ 1316 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1317 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-GC.obj `if test -f 'Common/GC.cc'; then $(CYGPATH_W) 'Common/GC.cc'; else $(CYGPATH_W) '$(srcdir)/Common/GC.cc'; fi` 1318 1296 1319 Common/driver_cfa_cpp-Assert.o: Common/Assert.cc 1297 1320 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-Assert.o -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-Assert.Tpo -c -o Common/driver_cfa_cpp-Assert.o `test -f 'Common/Assert.cc' || echo '$(srcdir)/'`Common/Assert.cc … … 2497 2520 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2498 2521 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Attribute.obj `if test -f 'SynTree/Attribute.cc'; then $(CYGPATH_W) 'SynTree/Attribute.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Attribute.cc'; fi` 2522 2523 SynTree/driver_cfa_cpp-GcTracer.o: SynTree/GcTracer.cc 2524 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-GcTracer.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-GcTracer.Tpo -c -o SynTree/driver_cfa_cpp-GcTracer.o `test -f 'SynTree/GcTracer.cc' || echo '$(srcdir)/'`SynTree/GcTracer.cc 2525 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-GcTracer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-GcTracer.Po 2526 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/GcTracer.cc' object='SynTree/driver_cfa_cpp-GcTracer.o' libtool=no @AMDEPBACKSLASH@ 2527 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2528 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-GcTracer.o `test -f 'SynTree/GcTracer.cc' || echo '$(srcdir)/'`SynTree/GcTracer.cc 2529 2530 SynTree/driver_cfa_cpp-GcTracer.obj: SynTree/GcTracer.cc 2531 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-GcTracer.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-GcTracer.Tpo -c -o SynTree/driver_cfa_cpp-GcTracer.obj `if test -f 'SynTree/GcTracer.cc'; then $(CYGPATH_W) 'SynTree/GcTracer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/GcTracer.cc'; fi` 2532 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-GcTracer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-GcTracer.Po 2533 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/GcTracer.cc' object='SynTree/driver_cfa_cpp-GcTracer.obj' libtool=no @AMDEPBACKSLASH@ 2534 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2535 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-GcTracer.obj `if test -f 'SynTree/GcTracer.cc'; then $(CYGPATH_W) 'SynTree/GcTracer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/GcTracer.cc'; fi` 2499 2536 2500 2537 SynTree/driver_cfa_cpp-VarExprReplacer.o: SynTree/VarExprReplacer.cc -
src/Parser/DeclarationNode.cc
r6171841 r68f9c43 986 986 obj->location = cur->location; 987 987 * out++ = obj; 988 delete agg;989 988 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 990 989 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() ); -
src/Parser/ExpressionNode.cc
r6171841 r68f9c43 427 427 Type * targetType = maybeMoveBuildType( decl_node ); 428 428 if ( dynamic_cast< VoidType * >( targetType ) ) { 429 delete targetType;430 429 return new CastExpr( maybeMoveBuild< Expression >(expr_node) ); 431 430 } else { … … 451 450 452 451 Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) { 453 Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() ); 454 delete member; 455 return ret; 452 return new UntypedOffsetofExpr{ maybeMoveBuildType( decl_node ), member->get_name() }; 456 453 } // build_offsetOf 457 454 -
src/ResolvExpr/AdjustExprType.cc
r6171841 r68f9c43 66 66 67 67 Type * AdjustExprType::postmutate( ArrayType * arrayType ) { 68 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base ); 69 arrayType->base = nullptr; 70 delete arrayType; 71 return pointerType; 68 return new PointerType{ arrayType->get_qualifiers(), arrayType->base }; 72 69 } 73 70 74 71 Type * AdjustExprType::postmutate( FunctionType * functionType ) { 75 return new PointerType ( Type::Qualifiers(), functionType );72 return new PointerType{ Type::Qualifiers(), functionType }; 76 73 } 77 74 … … 80 77 if ( env.lookup( typeInst->get_name(), eqvClass ) ) { 81 78 if ( eqvClass.data.kind == TypeDecl::Ftype ) { 82 PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst ); 83 return pointerType; 79 return new PointerType{ Type::Qualifiers(), typeInst }; 84 80 } 85 81 } else if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) { 86 82 if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) { 87 83 if ( tyDecl->get_kind() == TypeDecl::Ftype ) { 88 PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst ); 89 return pointerType; 84 return new PointerType{ Type::Qualifiers(), typeInst }; 90 85 } // if 91 86 } // if -
src/ResolvExpr/Alternative.cc
r6171841 r68f9c43 34 34 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost, const Cost &cvtCost ) 35 35 : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env ) {} 36 37 Alternative::Alternative( const Alternative &other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( maybeClone( other.expr ) ), env( other.env ) {38 }39 40 Alternative &Alternative::operator=( const Alternative &other ) {41 if ( &other == this ) return *this;42 delete expr;43 cost = other.cost;44 cvtCost = other.cvtCost;45 expr = maybeClone( other.expr );46 env = other.env;47 return *this;48 }49 50 Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( other.env ) {51 other.expr = nullptr;52 }53 54 Alternative & Alternative::operator=( Alternative && other ) {55 if ( &other == this ) return *this;56 delete expr;57 cost = other.cost;58 cvtCost = other.cvtCost;59 expr = other.expr;60 env = other.env;61 other.expr = nullptr;62 return *this;63 }64 65 Alternative::~Alternative() {66 delete expr;67 }68 36 69 37 void Alternative::print( std::ostream &os, Indenter indent ) const { -
src/ResolvExpr/Alternative.h
r6171841 r68f9c43 29 29 Alternative( Expression *expr, const TypeEnvironment &env, const Cost &cost ); 30 30 Alternative( Expression *expr, const TypeEnvironment &env, const Cost &cost, const Cost &cvtCost ); 31 Alternative( const Alternative &other ); 32 Alternative &operator=( const Alternative &other ); 33 Alternative( Alternative && other ); 34 Alternative &operator=( Alternative && other ); 35 ~Alternative(); 31 Alternative( const Alternative &other ) = default; 32 Alternative &operator=( const Alternative &other ) = default; 36 33 37 34 void print( std::ostream &os, Indenter indent = {} ) const; 38 35 39 /// Returns the stored expression, but released from management of this Alternative40 Expression* release_expr() {41 Expression* tmp = expr;42 expr = nullptr;43 return tmp;44 }45 46 36 Cost cost; 47 37 Cost cvtCost; 48 Expression * expr;38 Expression * expr; 49 39 TypeEnvironment env; 50 40 }; -
src/ResolvExpr/AlternativeFinder.cc
r6171841 r68f9c43 165 165 candidate->env.apply( newType ); 166 166 mangleName = SymTab::Mangler::mangle( newType ); 167 delete newType;168 167 } 169 168 std::map< std::string, PruneStruct >::iterator mapPlace = selected.find( mangleName ); … … 568 567 569 568 Expression *varExpr = data.combine( newerAlt.cvtCost ); 570 delete varExpr->get_result();571 569 varExpr->set_result( adjType->clone() ); 572 570 PRINT( … … 585 583 (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( candidate->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr ); 586 584 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, /*newNeedParents,*/ level, indexer, out ); 587 } else {588 delete adjType;589 585 } 590 586 } … … 1264 1260 componentExprs.push_back( restructureCast( idx, toType->getComponent( i ) ) ); 1265 1261 } 1266 delete argExpr;1267 1262 assert( componentExprs.size() > 0 ); 1268 1263 // produce the tuple of casts … … 1600 1595 alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt.expr->clone() ), alt.env, alt.cost ) ); 1601 1596 } // for 1602 delete newFirstArg;1603 1597 } 1604 1598 -
src/ResolvExpr/ResolveTypeof.cc
r6171841 r68f9c43 70 70 Expression * newExpr = resolveInVoidContext( typeofType->expr, indexer ); 71 71 assert( newExpr->result && ! newExpr->result->isVoid() ); 72 Type * newType = newExpr->result; 73 newExpr->result = nullptr; 74 delete typeofType; 75 delete newExpr; 76 return newType; 72 return newExpr->result; 77 73 } // if 78 74 return typeofType; -
src/ResolvExpr/Resolver.cc
r6171841 r68f9c43 138 138 castExpr->arg = nullptr; 139 139 std::swap( expr->env, castExpr->env ); 140 delete castExpr;141 140 } 142 141 } … … 198 197 findUnfinishedKindExpression( untyped, choice, indexer, kindStr, pred, adjust, prune, failFast ); 199 198 finishExpr( choice.expr, choice.env, untyped->env ); 200 delete untyped;201 199 untyped = choice.expr; 202 200 choice.expr = nullptr; … … 244 242 Expression * newExpr = resolveInVoidContext( untyped, indexer, env ); 245 243 finishExpr( newExpr, env, untyped->env ); 246 delete untyped;247 244 untyped = newExpr; 248 245 } … … 418 415 caseStmt->condition = castExpr->arg; 419 416 castExpr->arg = nullptr; 420 delete castExpr;421 417 } 422 418 } … … 700 696 std::swap( initExpr->env, newExpr->env ); 701 697 std::swap( initExpr->inferParams, newExpr->inferParams ) ; 702 delete initExpr;703 698 704 699 // get the actual object's type (may not exactly match what comes back from the resolver due to conversions) … … 718 713 ce->set_arg( nullptr ); 719 714 std::swap( ce->env, newExpr->env ); 720 delete ce;721 715 } 722 716 } … … 769 763 // could not find valid constructor, or found an intrinsic constructor 770 764 // fall back on C-style initializer 771 delete ctorInit->get_ctor(); 772 ctorInit->set_ctor( NULL ); 773 delete ctorInit->get_dtor(); 774 ctorInit->set_dtor( NULL ); 765 ctorInit->set_ctor( nullptr ); 766 ctorInit->set_dtor( nullptr ); 775 767 maybeAccept( ctorInit->get_init(), *visitor ); 776 768 } … … 798 790 799 791 // found a constructor - can get rid of C-style initializer 800 delete ctorInit->init;801 792 ctorInit->init = nullptr; 802 793 … … 805 796 // to clean up generated code. 806 797 if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->ctor ) ) { 807 delete ctorInit->ctor;808 798 ctorInit->ctor = nullptr; 809 799 } 810 800 811 801 if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->dtor ) ) { 812 delete ctorInit->dtor;813 802 ctorInit->dtor = nullptr; 814 803 } -
src/ResolvExpr/TypeEnvironment.cc
r6171841 r68f9c43 59 59 EqvClass &EqvClass::operator=( const EqvClass &other ) { 60 60 if ( this == &other ) return *this; 61 delete type;62 61 initialize( other, *this ); 63 62 return *this; 64 }65 66 EqvClass::~EqvClass() {67 delete type;68 63 } 69 64 … … 147 142 /// std::cerr << " bound to variable " << *theClass->vars.begin() << std::endl; 148 143 sub.add( *theVar, newTypeInst ); 149 delete newTypeInst;150 144 } // if 151 145 } // for … … 188 182 if ( secondClass->type ) { 189 183 if ( newClass.type ) { 190 Type *newType = combineFunc( newClass.type, secondClass->type ); 191 delete newClass.type; 192 newClass.type = newType; 184 newClass.type = combineFunc( newClass.type, secondClass->type ); 193 185 newClass.allowWidening = newClass.allowWidening && secondClass->allowWidening; 194 186 } else { -
src/ResolvExpr/TypeEnvironment.h
r6171841 r68f9c43 67 67 EqvClass( const EqvClass &other ); 68 68 EqvClass &operator=( const EqvClass &other ); 69 ~EqvClass();70 69 void print( std::ostream &os, Indenter indent = {} ) const; 71 70 }; -
src/ResolvExpr/Unify.cc
r6171841 r68f9c43 99 99 findOpenVars( newSecond, openVars, closedVars, needAssertions, haveAssertions, true ); 100 100 101 bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 102 delete newFirst; 103 delete newSecond; 104 return result; 101 return unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 105 102 } 106 103 … … 123 120 /// newSecond->print( std::cerr ); 124 121 /// std::cerr << std::endl; 125 bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 126 delete newFirst; 127 delete newSecond; 128 return result; 122 return unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 129 123 } 130 124 … … 176 170 if ( common ) { 177 171 common->get_qualifiers() = Type::Qualifiers(); 178 delete curClass.type;179 172 curClass.type = common; 180 173 env.add( curClass ); … … 239 232 if ( common ) { 240 233 common->get_qualifiers() = Type::Qualifiers(); 241 delete class1.type;242 234 class1.type = common; 243 235 } // if … … 272 264 env.add( newClass ); 273 265 } // if 274 delete type1;275 delete type2;276 266 return result; 277 267 } … … 282 272 findOpenVars( type2, openVars, closedVars, needAssertions, haveAssertions, true ); 283 273 Type *commonType = 0; 284 if ( unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType ) ) { 285 if ( commonType ) { 286 delete commonType; 287 } // if 288 return true; 289 } else { 290 return false; 291 } // if 274 return unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType ); 292 275 } 293 276 … … 544 527 // expand ttype parameter into its actual type 545 528 if ( eqvClass.type ) { 546 delete typeInst;547 529 return eqvClass.type->clone(); 548 530 } … … 569 551 dst.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) ); 570 552 } 571 delete dcl;572 553 } 573 554 } -
src/ResolvExpr/Unify.h
r6171841 r68f9c43 64 64 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 65 65 std::list< Type* > commonTypes; 66 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) { 67 deleteAll( commonTypes ); 68 return true; 69 } else { 70 return false; 71 } // if 66 return unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ); 72 67 } 73 68 -
src/SymTab/Autogen.cc
r6171841 r68f9c43 214 214 void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) { 215 215 FunctionDecl * decl = functionDecl->clone(); 216 delete decl->statements;217 216 decl->statements = nullptr; 218 217 declsToAdd.push_back( decl ); … … 333 332 } catch ( SemanticErrorException err ) { 334 333 // okay if decl does not resolve - that means the function should not be generated 335 delete dcl;336 334 } 337 335 } … … 373 371 // do not carry over field's attributes to parameter type 374 372 Type * paramType = field->get_type()->clone(); 375 deleteAll( paramType->attributes );376 373 paramType->attributes.clear(); 377 374 // add a parameter corresponding to this field … … 383 380 resolve( ctor ); 384 381 } 385 delete memCtorType;386 382 } 387 383 … … 511 507 // do not carry over field's attributes to parameter type 512 508 Type * paramType = field->get_type()->clone(); 513 deleteAll( paramType->attributes );514 509 paramType->attributes.clear(); 515 510 // add a parameter corresponding to this field … … 524 519 break; 525 520 } 526 delete memCtorType;527 521 } 528 522 -
src/SymTab/Autogen.h
r6171841 r68f9c43 97 97 // return if adding reference fails - will happen on default constructor and destructor 98 98 if ( isReferenceCtorDtor && ! srcParam.addReference() ) { 99 delete fExpr;100 99 return listInit; 101 100 } -
src/SymTab/FixFunction.cc
r6171841 r68f9c43 28 28 29 29 DeclarationWithType * FixFunction::postmutate(FunctionDecl *functionDecl) { 30 // can't delete function type because it may contain assertions, so transfer ownership to new object 31 ObjectDecl *pointer = new ObjectDecl( functionDecl->name, functionDecl->get_storageClasses(), functionDecl->linkage, nullptr, new PointerType( Type::Qualifiers(), functionDecl->type ), nullptr, functionDecl->attributes ); 32 functionDecl->attributes.clear(); 33 functionDecl->type = nullptr; 34 delete functionDecl; 35 return pointer; 30 return new ObjectDecl{ 31 functionDecl->name, functionDecl->get_storageClasses(), functionDecl->linkage, nullptr, 32 new PointerType{ Type::Qualifiers(), functionDecl->type }, 33 nullptr, functionDecl->attributes }; 36 34 } 37 35 … … 42 40 Type * FixFunction::postmutate(ArrayType *arrayType) { 43 41 // need to recursively mutate the base type in order for multi-dimensional arrays to work. 44 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->isVarLen, arrayType->isStatic ); 45 arrayType->base = nullptr; 46 arrayType->dimension = nullptr; 47 delete arrayType; 48 return pointerType; 42 return new PointerType{ arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->isVarLen, arrayType->isStatic }; 49 43 } 50 44 -
src/SymTab/Validate.cc
r6171841 r68f9c43 310 310 } // if 311 311 // Always remove the hoisted aggregate from the inner structure. 312 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion , false); } );312 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion ); } ); 313 313 } 314 314 … … 365 365 // one void is the only thing in the list; remove it. 366 366 if ( containsVoid ) { 367 delete dwts.front();368 367 dwts.clear(); 369 368 } … … 492 491 } 493 492 } 494 deleteAll( td->assertions );495 493 td->assertions.clear(); 496 494 } // for … … 608 606 // expand trait instance into all of its members 609 607 expandAssertions( traitInst, back_inserter( type->assertions ) ); 610 delete traitInst;611 608 } else { 612 609 // pass other assertions through … … 682 679 SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); 683 680 } 684 filter( translationUnit, isTypedef , true);681 filter( translationUnit, isTypedef ); 685 682 } 686 683 … … 696 693 ret->attributes.splice( ret->attributes.end(), typeInst->attributes ); 697 694 } else { 698 deleteAll( ret->attributes );699 695 ret->attributes.clear(); 700 696 } … … 709 705 mutateAll( rtt->parameters, *visitor ); // recursively fix typedefs on parameters 710 706 } // if 711 delete typeInst;712 707 return ret; 713 708 } else { … … 795 790 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( objDecl->get_type() ) ) { // function type? 796 791 // replace the current object declaration with a function declaration 797 FunctionDecl * newDecl = new FunctionDecl( objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() ); 798 objDecl->get_attributes().clear(); 799 objDecl->set_type( nullptr ); 800 delete objDecl; 801 return newDecl; 792 return new FunctionDecl{ 793 objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), 794 funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() }; 802 795 } // if 803 796 return objDecl; … … 823 816 } // if 824 817 return false; 825 } , true);818 } ); 826 819 return compoundStmt; 827 820 } … … 831 824 template<typename AggDecl> 832 825 AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) { 833 filter( aggDecl->members, isTypedef , true);826 filter( aggDecl->members, isTypedef ); 834 827 return aggDecl; 835 828 } … … 961 954 static UniqueName indexName( "_compLit" ); 962 955 963 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() ); 964 compLitExpr->set_result( nullptr ); 965 compLitExpr->set_initializer( nullptr ); 966 delete compLitExpr; 956 ObjectDecl * tempvar = new ObjectDecl{ 957 indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() }; 967 958 declsToAddBefore.push_back( tempvar ); // add modified temporary to current block 968 959 return new VariableExpr( tempvar ); … … 1000 991 // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false. 1001 992 ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 1002 deleteAll( retVals );1003 993 retVals.clear(); 1004 994 retVals.push_back( newRet ); … … 1041 1031 if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( inner->arg ) ) { 1042 1032 if ( labels.count( nameExpr->name ) ) { 1043 Label name = nameExpr->name; 1044 delete addrExpr; 1045 return new LabelAddressExpr( name ); 1033 return new LabelAddressExpr{ nameExpr->name }; 1046 1034 } 1047 1035 } -
src/SynTree/AddressExpr.cc
r6171841 r68f9c43 58 58 } 59 59 60 AddressExpr::~AddressExpr() {61 delete arg;62 }63 64 60 void AddressExpr::print( std::ostream &os, Indenter indent ) const { 65 61 os << "Address of:" << std::endl; … … 75 71 } 76 72 LabelAddressExpr::LabelAddressExpr( const LabelAddressExpr & other ) : Expression( other ), arg( other.arg ) {} 77 LabelAddressExpr::~LabelAddressExpr() {}78 73 79 74 void LabelAddressExpr::print( std::ostream & os, Indenter ) const { -
src/SynTree/AggregateDecl.cc
r6171841 r68f9c43 33 33 cloneAll( other.attributes, attributes ); 34 34 body = other.body; 35 }36 37 AggregateDecl::~AggregateDecl() {38 deleteAll( attributes );39 deleteAll( parameters );40 deleteAll( members );41 35 } 42 36 -
src/SynTree/ApplicationExpr.cc
r6171841 r68f9c43 43 43 } 44 44 45 ParamEntry::~ParamEntry() {46 delete actualType;47 delete formalType;48 delete expr;49 }50 51 45 ApplicationExpr::ApplicationExpr( Expression *funcExpr, const std::list<Expression *> & args ) : function( funcExpr ), args( args ) { 52 46 PointerType *pointer = strict_dynamic_cast< PointerType* >( funcExpr->get_result() ); … … 61 55 Expression( other ), function( maybeClone( other.function ) ) { 62 56 cloneAll( other.args, args ); 63 }64 65 ApplicationExpr::~ApplicationExpr() {66 delete function;67 deleteAll( args );68 57 } 69 58 -
src/SynTree/ArrayType.cc
r6171841 r68f9c43 34 34 } 35 35 36 ArrayType::~ArrayType() {37 delete base;38 delete dimension;39 }40 41 36 void ArrayType::print( std::ostream &os, Indenter indent ) const { 42 37 Type::print( os, indent ); -
src/SynTree/AttrType.cc
r6171841 r68f9c43 37 37 } 38 38 39 AttrType::~AttrType() {40 delete expr;41 delete type;42 }43 44 39 void AttrType::print( std::ostream &os, Indenter indent ) const { 45 40 Type::print( os, indent ); -
src/SynTree/Attribute.cc
r6171841 r68f9c43 23 23 Attribute::Attribute( const Attribute &other ) : name( other.name ) { 24 24 cloneAll( other.parameters, parameters ); 25 }26 27 Attribute::~Attribute() {28 deleteAll( parameters );29 25 } 30 26 -
src/SynTree/Attribute.h
r6171841 r68f9c43 36 36 Attribute( std::string name = "", const std::list< Expression * > & parameters = std::list< Expression * >() ) : name( name ), parameters( parameters ) {} 37 37 Attribute( const Attribute &other ); 38 virtual ~Attribute();39 38 40 39 std::string get_name() const { return name; } -
src/SynTree/BaseSyntaxNode.h
r6171841 r68f9c43 17 17 18 18 #include "Common/CodeLocation.h" 19 #include "Common/GC.h" 19 20 #include "Common/Indenter.h" 21 20 22 class Visitor; 21 23 class Mutator; 22 24 23 class BaseSyntaxNode {24 25 class BaseSyntaxNode : GC_Object { 26 public: 25 27 CodeLocation location; 26 27 virtual ~BaseSyntaxNode() {}28 28 29 29 virtual BaseSyntaxNode * clone() const = 0; -
src/SynTree/CommaExpr.cc
r6171841 r68f9c43 34 34 } 35 35 36 CommaExpr::~CommaExpr() {37 delete arg1;38 delete arg2;39 }40 41 36 void CommaExpr::print( std::ostream &os, Indenter indent ) const { 42 37 os << "Comma Expression:" << std::endl; -
src/SynTree/CompoundStmt.cc
r6171841 r68f9c43 68 68 } 69 69 70 CompoundStmt::~CompoundStmt() {71 deleteAll( kids );72 }73 74 70 void CompoundStmt::print( std::ostream &os, Indenter indent ) const { 75 71 os << "CompoundStmt" << endl; -
src/SynTree/Constant.cc
r6171841 r68f9c43 27 27 type = other.type->clone(); 28 28 } 29 30 Constant::~Constant() { delete type; }31 29 32 30 Constant Constant::from_bool( bool b ) { -
src/SynTree/Constant.h
r6171841 r68f9c43 30 30 Constant( Type * type, std::string rep, double val ); 31 31 Constant( const Constant & other ); 32 virtual ~Constant(); 33 32 34 33 virtual Constant * clone() const { return new Constant( *this ); } 35 34 -
src/SynTree/DeclStmt.cc
r6171841 r68f9c43 29 29 } 30 30 31 DeclStmt::~DeclStmt() {32 delete decl;33 }34 35 31 void DeclStmt::print( std::ostream &os, Indenter indent ) const { 36 32 assert( decl != 0 ); -
src/SynTree/Declaration.cc
r6171841 r68f9c43 38 38 } 39 39 40 Declaration::~Declaration() {41 }42 43 40 void Declaration::fixUniqueId() { 44 41 // don't need to set unique ID twice … … 68 65 } 69 66 70 AsmDecl::~AsmDecl() {71 delete stmt;72 }73 74 67 void AsmDecl::print( std::ostream &os, Indenter indent ) const { 75 68 stmt->print( os, indent ); -
src/SynTree/Declaration.h
r6171841 r68f9c43 45 45 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 46 46 Declaration( const Declaration &other ); 47 virtual ~Declaration();48 47 49 48 const std::string &get_name() const { return name; } … … 87 86 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs ); 88 87 DeclarationWithType( const DeclarationWithType &other ); 89 virtual ~DeclarationWithType(); 90 88 91 89 std::string get_mangleName() const { return mangleName; } 92 90 DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; } … … 126 124 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); 127 125 ObjectDecl( const ObjectDecl &other ); 128 virtual ~ObjectDecl();129 126 130 127 virtual Type * get_type() const override { return type; } … … 156 153 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); 157 154 FunctionDecl( const FunctionDecl &other ); 158 virtual ~FunctionDecl();159 155 160 156 virtual Type * get_type() const override { return type; } … … 184 180 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 185 181 NamedTypeDecl( const NamedTypeDecl &other ); 186 virtual ~NamedTypeDecl();187 182 188 183 Type *get_base() const { return base; } … … 219 214 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr ); 220 215 TypeDecl( const TypeDecl &other ); 221 virtual ~TypeDecl();222 216 223 217 Kind get_kind() const { return kind; } … … 268 262 AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ); 269 263 AggregateDecl( const AggregateDecl &other ); 270 virtual ~AggregateDecl(); 271 264 272 265 std::list<Declaration*>& get_members() { return members; } 273 266 std::list<TypeDecl*>& get_parameters() { return parameters; } … … 353 346 AsmDecl( AsmStmt *stmt ); 354 347 AsmDecl( const AsmDecl &other ); 355 virtual ~AsmDecl();356 348 357 349 AsmStmt *get_stmt() { return stmt; } -
src/SynTree/DeclarationWithType.cc
r6171841 r68f9c43 34 34 } 35 35 36 DeclarationWithType::~DeclarationWithType() {37 deleteAll( attributes );38 delete asmName;39 }40 41 36 // Local Variables: // 42 37 // tab-width: 4 // -
src/SynTree/Expression.cc
r6171841 r68f9c43 52 52 Expression::~Expression() { 53 53 delete env; 54 delete result;55 54 } 56 55 … … 74 73 ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) { 75 74 } 76 77 ConstantExpr::~ConstantExpr() {}78 75 79 76 void ConstantExpr::print( std::ostream &os, Indenter indent ) const { … … 120 117 } 121 118 122 VariableExpr::~VariableExpr() {123 // don't delete the declaration, since it points somewhere else in the tree124 }125 126 119 VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) { 127 120 VariableExpr * funcExpr = new VariableExpr( func ); … … 150 143 } 151 144 152 SizeofExpr::~SizeofExpr() {153 delete expr;154 delete type;155 }156 157 145 void SizeofExpr::print( std::ostream &os, Indenter indent) const { 158 146 os << "Sizeof Expression on: "; … … 176 164 } 177 165 178 AlignofExpr::~AlignofExpr() {179 delete expr;180 delete type;181 }182 183 166 void AlignofExpr::print( std::ostream &os, Indenter indent) const { 184 167 os << "Alignof Expression on: "; … … 196 179 UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) : 197 180 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {} 198 199 UntypedOffsetofExpr::~UntypedOffsetofExpr() {200 delete type;201 }202 181 203 182 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const { … … 217 196 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {} 218 197 219 OffsetofExpr::~OffsetofExpr() {220 delete type;221 }222 223 198 void OffsetofExpr::print( std::ostream &os, Indenter indent) const { 224 199 os << "Offsetof Expression on member " << member->name << " of "; … … 234 209 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {} 235 210 236 OffsetPackExpr::~OffsetPackExpr() { delete type; }237 238 211 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const { 239 212 os << "Offset pack expression on "; … … 252 225 AttrExpr::AttrExpr( const AttrExpr &other ) : 253 226 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) { 254 }255 256 AttrExpr::~AttrExpr() {257 delete attr;258 delete expr;259 delete type;260 227 } 261 228 … … 280 247 281 248 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) { 282 }283 284 CastExpr::~CastExpr() {285 delete arg;286 249 } 287 250 … … 306 269 } 307 270 308 VirtualCastExpr::~VirtualCastExpr() {309 delete arg;310 }311 312 271 void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const { 313 272 os << "Virtual Cast of:" << std::endl << indent+1; … … 332 291 } 333 292 334 UntypedMemberExpr::~UntypedMemberExpr() {335 delete aggregate;336 delete member;337 }338 339 293 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const { 340 294 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 363 317 } 364 318 365 MemberExpr::~MemberExpr() {366 // don't delete the member declaration, since it points somewhere else in the tree367 delete aggregate;368 }369 370 319 void MemberExpr::print( std::ostream &os, Indenter indent ) const { 371 320 os << "Member Expression, with field: " << std::endl; … … 383 332 Expression( other ), function( maybeClone( other.function ) ) { 384 333 cloneAll( other.args, args ); 385 }386 387 UntypedExpr::~UntypedExpr() {388 delete function;389 deleteAll( args );390 334 } 391 335 … … 436 380 } 437 381 438 NameExpr::~NameExpr() {}439 440 382 void NameExpr::print( std::ostream &os, Indenter indent ) const { 441 383 os << "Name: " << get_name(); … … 450 392 LogicalExpr::LogicalExpr( const LogicalExpr &other ) : 451 393 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) { 452 }453 454 LogicalExpr::~LogicalExpr() {455 delete arg1;456 delete arg2;457 394 } 458 395 … … 470 407 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) : 471 408 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) { 472 }473 474 ConditionalExpr::~ConditionalExpr() {475 delete arg1;476 delete arg2;477 delete arg3;478 409 } 479 410 … … 513 444 ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() { 514 445 set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment 515 delete callExpr;516 deleteAll( tempDecls );517 deleteAll( returnDecls );518 deleteAll( dtors );519 446 } 520 447 … … 541 468 } 542 469 543 ConstructorExpr::~ConstructorExpr() {544 delete callExpr;545 }546 547 470 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const { 548 471 os << "Constructor Expression: " << std::endl << indent+1; … … 559 482 560 483 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {} 561 562 CompoundLiteralExpr::~CompoundLiteralExpr() {563 delete initializer;564 }565 484 566 485 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const { … … 589 508 cloneAll( other.dtors, dtors ); 590 509 } 591 StmtExpr::~StmtExpr() {592 delete statements;593 deleteAll( dtors );594 deleteAll( returnDecls );595 }596 510 void StmtExpr::computeResult() { 597 511 assert( statements ); 598 512 std::list< Statement * > & body = statements->kids; 599 delete result;600 513 result = nullptr; 601 514 if ( ! returnDecls.empty() ) { … … 640 553 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) { 641 554 } 642 UniqueExpr::~UniqueExpr() { 643 delete expr; 644 delete object; 645 delete var; 646 } 555 647 556 void UniqueExpr::print( std::ostream &os, Indenter indent ) const { 648 557 os << "Unique Expression with id:" << id << std::endl << indent+1; … … 657 566 InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {} 658 567 InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {} 659 InitAlternative::~InitAlternative() {660 delete type;661 delete designation;662 }663 568 664 569 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {} 665 570 UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {} 666 UntypedInitExpr::~UntypedInitExpr() {667 delete expr;668 }669 571 670 572 void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const { … … 684 586 } 685 587 InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {} 686 InitExpr::~InitExpr() {687 delete expr;688 delete designation;689 }690 588 691 589 void InitExpr::print( std::ostream & os, Indenter indent ) const { … … 701 599 } 702 600 DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {} 703 DeletedExpr::~DeletedExpr() {704 delete expr;705 }706 601 707 602 void DeletedExpr::print( std::ostream & os, Indenter indent ) const { -
src/SynTree/Expression.h
r6171841 r68f9c43 41 41 ParamEntry( UniqueId decl, Type * actualType, Type * formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ), inferParams( new InferredParams ) {} 42 42 ParamEntry( const ParamEntry & other ); 43 ~ParamEntry();44 43 ParamEntry & operator=( const ParamEntry & other ); 45 44 … … 53 52 /// Expression is the root type for all expressions 54 53 class Expression : public BaseSyntaxNode { 54 protected: 55 virtual ~Expression(); 56 55 57 public: 56 58 Type * result; … … 61 63 Expression(); 62 64 Expression( const Expression & other ); 63 virtual ~Expression();64 65 65 66 Type *& get_result() { return result; } … … 89 90 ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); 90 91 ApplicationExpr( const ApplicationExpr & other ); 91 virtual ~ApplicationExpr();92 92 93 93 Expression * get_function() const { return function; } … … 111 111 UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); 112 112 UntypedExpr( const UntypedExpr & other ); 113 virtual ~UntypedExpr();114 113 115 114 Expression * get_function() const { return function; } … … 136 135 NameExpr( std::string name ); 137 136 NameExpr( const NameExpr & other ); 138 virtual ~NameExpr();139 137 140 138 const std::string & get_name() const { return name; } … … 157 155 AddressExpr( Expression * arg ); 158 156 AddressExpr( const AddressExpr & other ); 159 virtual ~AddressExpr();160 157 161 158 Expression * get_arg() const { return arg; } … … 176 173 LabelAddressExpr( const Label &arg ); 177 174 LabelAddressExpr( const LabelAddressExpr & other ); 178 virtual ~LabelAddressExpr();179 175 180 176 virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); } … … 192 188 CastExpr( Expression * arg, Type * toType ); 193 189 CastExpr( const CastExpr & other ); 194 virtual ~CastExpr();195 190 196 191 Expression * get_arg() const { return arg; } … … 210 205 VirtualCastExpr( Expression * arg, Type * toType ); 211 206 VirtualCastExpr( const VirtualCastExpr & other ); 212 virtual ~VirtualCastExpr();213 207 214 208 Expression * get_arg() const { return arg; } … … 229 223 UntypedMemberExpr( Expression * member, Expression * aggregate ); 230 224 UntypedMemberExpr( const UntypedMemberExpr & other ); 231 virtual ~UntypedMemberExpr();232 225 233 226 Expression * get_member() const { return member; } … … 251 244 MemberExpr( DeclarationWithType * member, Expression * aggregate ); 252 245 MemberExpr( const MemberExpr & other ); 253 virtual ~MemberExpr();254 246 255 247 DeclarationWithType * get_member() const { return member; } … … 272 264 VariableExpr( DeclarationWithType * var ); 273 265 VariableExpr( const VariableExpr & other ); 274 virtual ~VariableExpr();275 266 276 267 DeclarationWithType * get_var() const { return var; } … … 292 283 ConstantExpr( Constant constant ); 293 284 ConstantExpr( const ConstantExpr & other ); 294 virtual ~ConstantExpr();295 285 296 286 Constant * get_constant() { return & constant; } … … 316 306 SizeofExpr( const SizeofExpr & other ); 317 307 SizeofExpr( Type * type ); 318 virtual ~SizeofExpr();319 308 320 309 Expression * get_expr() const { return expr; } … … 341 330 AlignofExpr( const AlignofExpr & other ); 342 331 AlignofExpr( Type * type ); 343 virtual ~AlignofExpr();344 332 345 333 Expression * get_expr() const { return expr; } … … 364 352 UntypedOffsetofExpr( Type * type, const std::string & member ); 365 353 UntypedOffsetofExpr( const UntypedOffsetofExpr & other ); 366 virtual ~UntypedOffsetofExpr();367 354 368 355 std::string get_member() const { return member; } … … 385 372 OffsetofExpr( Type * type, DeclarationWithType * member ); 386 373 OffsetofExpr( const OffsetofExpr & other ); 387 virtual ~OffsetofExpr();388 374 389 375 Type * get_type() const { return type; } … … 405 391 OffsetPackExpr( StructInstType * type ); 406 392 OffsetPackExpr( const OffsetPackExpr & other ); 407 virtual ~OffsetPackExpr();408 393 409 394 StructInstType * get_type() const { return type; } … … 427 412 AttrExpr( const AttrExpr & other ); 428 413 AttrExpr( Expression * attr, Type * type ); 429 virtual ~AttrExpr();430 414 431 415 Expression * get_attr() const { return attr; } … … 452 436 LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true ); 453 437 LogicalExpr( const LogicalExpr & other ); 454 virtual ~LogicalExpr();455 438 456 439 bool get_isAnd() const { return isAnd; } … … 478 461 ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ); 479 462 ConditionalExpr( const ConditionalExpr & other ); 480 virtual ~ConditionalExpr();481 463 482 464 Expression * get_arg1() const { return arg1; } … … 501 483 CommaExpr( Expression * arg1, Expression * arg2 ); 502 484 CommaExpr( const CommaExpr & other ); 503 virtual ~CommaExpr();504 485 505 486 Expression * get_arg1() const { return arg1; } … … 521 502 TypeExpr( Type * type ); 522 503 TypeExpr( const TypeExpr & other ); 523 virtual ~TypeExpr();524 504 525 505 Type * get_type() const { return type; } … … 541 521 AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 542 522 AsmExpr( const AsmExpr & other ); 543 virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };544 523 545 524 Expression * get_inout() const { return inout; } … … 563 542 /// along with a set of copy constructor calls, one for each argument. 564 543 class ImplicitCopyCtorExpr : public Expression { 544 protected: 545 virtual ~ImplicitCopyCtorExpr(); 546 565 547 public: 566 548 ApplicationExpr * callExpr; … … 571 553 ImplicitCopyCtorExpr( ApplicationExpr * callExpr ); 572 554 ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ); 573 virtual ~ImplicitCopyCtorExpr();574 555 575 556 ApplicationExpr * get_callExpr() const { return callExpr; } … … 593 574 ConstructorExpr( Expression * callExpr ); 594 575 ConstructorExpr( const ConstructorExpr & other ); 595 ~ConstructorExpr();596 576 597 577 Expression * get_callExpr() const { return callExpr; } … … 611 591 CompoundLiteralExpr( Type * type, Initializer * initializer ); 612 592 CompoundLiteralExpr( const CompoundLiteralExpr & other ); 613 virtual ~CompoundLiteralExpr();614 593 615 594 Initializer * get_initializer() const { return initializer; } … … 648 627 UntypedTupleExpr( const std::list< Expression * > & exprs ); 649 628 UntypedTupleExpr( const UntypedTupleExpr & other ); 650 virtual ~UntypedTupleExpr();651 629 652 630 std::list<Expression*>& get_exprs() { return exprs; } … … 665 643 TupleExpr( const std::list< Expression * > & exprs ); 666 644 TupleExpr( const TupleExpr & other ); 667 virtual ~TupleExpr();668 645 669 646 std::list<Expression*>& get_exprs() { return exprs; } … … 683 660 TupleIndexExpr( Expression * tuple, unsigned int index ); 684 661 TupleIndexExpr( const TupleIndexExpr & other ); 685 virtual ~TupleIndexExpr();686 662 687 663 Expression * get_tuple() const { return tuple; } … … 703 679 TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls ); 704 680 TupleAssignExpr( const TupleAssignExpr & other ); 705 virtual ~TupleAssignExpr();706 681 707 682 TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; } … … 723 698 StmtExpr( CompoundStmt * statements ); 724 699 StmtExpr( const StmtExpr & other ); 725 virtual ~StmtExpr();726 700 727 701 CompoundStmt * get_statements() const { return statements; } … … 748 722 UniqueExpr( Expression * expr, long long idVal = -1 ); 749 723 UniqueExpr( const UniqueExpr & other ); 750 ~UniqueExpr();751 724 752 725 Expression * get_expr() const { return expr; } … … 778 751 InitAlternative( const InitAlternative & other ); 779 752 InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it 780 ~InitAlternative();781 753 }; 782 754 … … 788 760 UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ); 789 761 UntypedInitExpr( const UntypedInitExpr & other ); 790 ~UntypedInitExpr();791 762 792 763 Expression * get_expr() const { return expr; } … … 808 779 InitExpr( Expression * expr, Designation * designation ); 809 780 InitExpr( const InitExpr & other ); 810 ~InitExpr();811 781 812 782 Expression * get_expr() const { return expr; } … … 830 800 DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt ); 831 801 DeletedExpr( const DeletedExpr & other ); 832 ~DeletedExpr();833 802 834 803 virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); } -
src/SynTree/FunctionDecl.cc
r6171841 r68f9c43 52 52 } 53 53 cloneAll( other.withExprs, withExprs ); 54 }55 56 FunctionDecl::~FunctionDecl() {57 delete type;58 delete statements;59 deleteAll( withExprs );60 54 } 61 55 -
src/SynTree/FunctionType.cc
r6171841 r68f9c43 31 31 cloneAll( other.returnVals, returnVals ); 32 32 cloneAll( other.parameters, parameters ); 33 }34 35 FunctionType::~FunctionType() {36 deleteAll( returnVals );37 deleteAll( parameters );38 33 } 39 34 -
src/SynTree/Initializer.cc
r6171841 r68f9c43 32 32 } 33 33 34 Designation::~Designation() {35 // std::cerr << "destroying designation" << std::endl;36 deleteAll( designators );37 // std::cerr << "finished destroying designation" << std::endl;38 }39 40 34 void Designation::print( std::ostream &os, Indenter indent ) const { 41 35 if ( ! designators.empty() ) { … … 52 46 Initializer::Initializer( const Initializer & other ) : BaseSyntaxNode( other ), maybeConstructed( other.maybeConstructed ) { 53 47 } 54 Initializer::~Initializer() {}55 48 56 49 SingleInit::SingleInit( Expression *v, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ) { … … 58 51 59 52 SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( maybeClone( other.value ) ) { 60 }61 62 SingleInit::~SingleInit() {63 delete value;64 53 } 65 54 … … 87 76 } 88 77 89 ListInit::~ListInit() {90 deleteAll( initializers );91 deleteAll( designations );92 }93 94 78 void ListInit::print( std::ostream &os, Indenter indent ) const { 95 79 os << "Compound initializer: " << std::endl; … … 110 94 ConstructorInit::ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init ) : Initializer( true ), ctor( ctor ), dtor( dtor ), init( init ) {} 111 95 ConstructorInit::ConstructorInit( const ConstructorInit &other ) : Initializer( other ), ctor( maybeClone( other.ctor ) ), dtor( maybeClone( other.dtor ) ), init( maybeClone( other.init ) ) { 112 }113 114 ConstructorInit::~ConstructorInit() {115 delete ctor;116 delete dtor;117 delete init;118 96 } 119 97 -
src/SynTree/Initializer.h
r6171841 r68f9c43 33 33 Designation( const std::list< Expression * > & designators ); 34 34 Designation( const Designation & other ); 35 virtual ~Designation();36 35 37 36 std::list< Expression * > & get_designators() { return designators; } … … 50 49 Initializer( bool maybeConstructed ); 51 50 Initializer( const Initializer & other ); 52 virtual ~Initializer();53 51 54 52 bool get_maybeConstructed() { return maybeConstructed; } … … 70 68 SingleInit( Expression *value, bool maybeConstructed = false ); 71 69 SingleInit( const SingleInit &other ); 72 virtual ~SingleInit();73 70 74 71 Expression *get_value() { return value; } … … 91 88 const std::list<Designation *> &designators = {}, bool maybeConstructed = false ); 92 89 ListInit( const ListInit & other ); 93 virtual ~ListInit();94 90 95 91 std::list<Designation *> & get_designations() { return designations; } … … 123 119 ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init ); 124 120 ConstructorInit( const ConstructorInit &other ); 125 virtual ~ConstructorInit();126 121 127 122 void set_ctor( Statement * newValue ) { ctor = newValue; } -
src/SynTree/NamedTypeDecl.cc
r6171841 r68f9c43 30 30 cloneAll( other.parameters, parameters ); 31 31 cloneAll( other.assertions, assertions ); 32 }33 34 NamedTypeDecl::~NamedTypeDecl() {35 delete base;36 deleteAll( parameters );37 deleteAll( assertions );38 32 } 39 33 -
src/SynTree/ObjectDecl.cc
r6171841 r68f9c43 32 32 ObjectDecl::ObjectDecl( const ObjectDecl &other ) 33 33 : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) { 34 }35 36 ObjectDecl::~ObjectDecl() {37 delete type;38 delete init;39 delete bitfieldWidth;40 34 } 41 35 -
src/SynTree/PointerType.cc
r6171841 r68f9c43 36 36 } 37 37 38 PointerType::~PointerType() {39 delete base;40 delete dimension;41 }42 43 38 void PointerType::print( std::ostream &os, Indenter indent ) const { 44 39 Type::print( os, indent ); -
src/SynTree/ReferenceToType.cc
r6171841 r68f9c43 32 32 ReferenceToType::ReferenceToType( const ReferenceToType &other ) : Type( other ), name( other.name ), hoistType( other.hoistType ) { 33 33 cloneAll( other.parameters, parameters ); 34 }35 36 ReferenceToType::~ReferenceToType() {37 deleteAll( parameters );38 34 } 39 35 … … 170 166 } 171 167 172 TraitInstType::~TraitInstType() {173 }174 175 168 bool TraitInstType::isComplete() const { assert( false ); } 176 169 … … 183 176 184 177 TypeInstType::TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) { 185 }186 187 188 TypeInstType::~TypeInstType() {189 // delete baseType; //This is shared and should not be deleted190 178 } 191 179 -
src/SynTree/ReferenceType.cc
r6171841 r68f9c43 28 28 } 29 29 30 ReferenceType::~ReferenceType() {31 delete base;32 }33 34 30 int ReferenceType::referenceDepth() const { 35 31 return base->referenceDepth()+1; -
src/SynTree/Statement.cc
r6171841 r68f9c43 44 44 } 45 45 46 Statement::~Statement() {}47 48 46 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {} 49 47 50 48 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 51 52 ExprStmt::~ExprStmt() {53 delete expr;54 }55 49 56 50 void ExprStmt::print( std::ostream &os, Indenter indent ) const { … … 66 60 cloneAll( other.input, input ); 67 61 cloneAll( other.clobber, clobber ); 68 }69 70 AsmStmt::~AsmStmt() {71 delete instruction;72 deleteAll( output );73 deleteAll( input );74 deleteAll( clobber );75 62 } 76 63 … … 122 109 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 123 110 124 ReturnStmt::~ReturnStmt() {125 delete expr;126 }127 128 111 void ReturnStmt::print( std::ostream &os, Indenter indent ) const { 129 112 os << "Return Statement, returning: "; … … 141 124 Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) { 142 125 cloneAll( other.initialization, initialization ); 143 }144 145 IfStmt::~IfStmt() {146 deleteAll( initialization );147 delete condition;148 delete thenPart;149 delete elsePart;150 126 } 151 127 … … 185 161 } 186 162 187 SwitchStmt::~SwitchStmt() {188 delete condition;189 // destroy statements190 deleteAll( statements );191 }192 193 163 void SwitchStmt::print( std::ostream &os, Indenter indent ) const { 194 164 os << "Switch on condition: "; … … 209 179 Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) { 210 180 cloneAll( other.stmts, stmts ); 211 }212 213 CaseStmt::~CaseStmt() {214 delete condition;215 deleteAll( stmts );216 181 } 217 182 … … 243 208 } 244 209 245 WhileStmt::~WhileStmt() {246 delete body;247 delete condition;248 }249 250 210 void WhileStmt::print( std::ostream &os, Indenter indent ) const { 251 211 os << "While on condition: " << endl ; … … 265 225 cloneAll( other.initialization, initialization ); 266 226 267 }268 269 ForStmt::~ForStmt() {270 deleteAll( initialization );271 delete condition;272 delete increment;273 delete body;274 227 } 275 228 … … 311 264 ThrowStmt::ThrowStmt( const ThrowStmt &other ) : 312 265 Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) { 313 }314 315 ThrowStmt::~ThrowStmt() {316 delete expr;317 delete target;318 266 } 319 267 … … 336 284 } 337 285 338 TryStmt::~TryStmt() {339 delete block;340 deleteAll( handlers );341 delete finallyBlock;342 }343 344 286 void TryStmt::print( std::ostream &os, Indenter indent ) const { 345 287 os << "Try Statement" << endl; … … 370 312 } 371 313 372 CatchStmt::~CatchStmt() {373 delete decl;374 delete body;375 }376 377 314 void CatchStmt::print( std::ostream &os, Indenter indent ) const { 378 315 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; … … 397 334 398 335 FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) { 399 }400 401 FinallyStmt::~FinallyStmt() {402 delete block;403 336 } 404 337 … … 434 367 } 435 368 436 WaitForStmt::~WaitForStmt() {437 for( auto & clause : clauses ) {438 delete clause.target.function;439 deleteAll( clause.target.arguments );440 delete clause.statement;441 delete clause.condition;442 }443 444 delete timeout.time;445 delete timeout.statement;446 delete timeout.condition;447 448 delete orelse.statement;449 delete orelse.condition;450 }451 452 369 void WaitForStmt::print( std::ostream &os, Indenter indent ) const { 453 370 os << "Waitfor Statement" << endl; … … 460 377 WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) { 461 378 cloneAll( other.exprs, exprs ); 462 }463 WithStmt::~WithStmt() {464 deleteAll( exprs );465 delete stmt;466 379 } 467 380 … … 489 402 } 490 403 491 ImplicitCtorDtorStmt::~ImplicitCtorDtorStmt() {492 delete callStmt;493 }494 495 404 void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const { 496 405 os << "Implicit Ctor Dtor Statement" << endl; -
src/SynTree/Statement.h
r6171841 r68f9c43 38 38 39 39 Statement( const std::list<Label> & labels = {} ); 40 virtual ~Statement();41 40 42 41 std::list<Label> & get_labels() { return labels; } … … 56 55 CompoundStmt( std::list<Statement *> stmts ); 57 56 CompoundStmt( const CompoundStmt &other ); 58 virtual ~CompoundStmt();59 57 60 58 std::list<Statement*>& get_kids() { return kids; } … … 84 82 ExprStmt( Expression *expr ); 85 83 ExprStmt( const ExprStmt &other ); 86 virtual ~ExprStmt();87 84 88 85 Expression *get_expr() { return expr; } … … 105 102 AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 106 103 AsmStmt( const AsmStmt &other ); 107 virtual ~AsmStmt();108 104 109 105 bool get_voltile() { return voltile; } … … 136 132 std::list<Statement *> initialization = std::list<Statement *>() ); 137 133 IfStmt( const IfStmt &other ); 138 virtual ~IfStmt();139 134 140 135 std::list<Statement *> &get_initialization() { return initialization; } … … 159 154 SwitchStmt( Expression *condition, const std::list<Statement *> &statements ); 160 155 SwitchStmt( const SwitchStmt &other ); 161 virtual ~SwitchStmt();162 156 163 157 Expression *get_condition() { return condition; } … … 181 175 CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException); 182 176 CaseStmt( const CaseStmt &other ); 183 virtual ~CaseStmt();184 177 185 178 static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() ); … … 212 205 Statement *body, bool isDoWhile = false ); 213 206 WhileStmt( const WhileStmt &other ); 214 virtual ~WhileStmt();215 207 216 208 Expression *get_condition() { return condition; } … … 237 229 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); 238 230 ForStmt( const ForStmt &other ); 239 virtual ~ForStmt();240 231 241 232 std::list<Statement *> &get_initialization() { return initialization; } … … 290 281 ReturnStmt( Expression *expr ); 291 282 ReturnStmt( const ReturnStmt &other ); 292 virtual ~ReturnStmt();293 283 294 284 Expression *get_expr() { return expr; } … … 311 301 ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr ); 312 302 ThrowStmt( const ThrowStmt &other ); 313 virtual ~ThrowStmt();314 303 315 304 Kind get_kind() { return kind; } … … 333 322 TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); 334 323 TryStmt( const TryStmt &other ); 335 virtual ~TryStmt();336 324 337 325 CompoundStmt *get_block() const { return block; } … … 360 348 Expression *cond, Statement *body ); 361 349 CatchStmt( const CatchStmt &other ); 362 virtual ~CatchStmt();363 350 364 351 Kind get_kind() { return kind; } … … 382 369 FinallyStmt( CompoundStmt *block ); 383 370 FinallyStmt( const FinallyStmt &other ); 384 virtual ~FinallyStmt();385 371 386 372 CompoundStmt *get_block() const { return block; } … … 409 395 WaitForStmt(); 410 396 WaitForStmt( const WaitForStmt & ); 411 virtual ~WaitForStmt();412 397 413 398 std::vector<Clause> clauses; … … 438 423 WithStmt( const std::list< Expression * > & exprs, Statement * stmt ); 439 424 WithStmt( const WithStmt & other ); 440 virtual ~WithStmt();441 425 442 426 virtual WithStmt * clone() const override { return new WithStmt( *this ); } … … 454 438 DeclStmt( Declaration *decl ); 455 439 DeclStmt( const DeclStmt &other ); 456 virtual ~DeclStmt();457 440 458 441 Declaration *get_decl() const { return decl; } … … 476 459 ImplicitCtorDtorStmt( Statement * callStmt ); 477 460 ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); 478 virtual ~ImplicitCtorDtorStmt();479 461 480 462 Statement *get_callStmt() const { return callStmt; } -
src/SynTree/TupleExpr.cc
r6171841 r68f9c43 35 35 } 36 36 37 UntypedTupleExpr::~UntypedTupleExpr() {38 deleteAll( exprs );39 }40 41 37 void UntypedTupleExpr::print( std::ostream &os, Indenter indent ) const { 42 38 os << "Untyped Tuple:" << std::endl; … … 51 47 TupleExpr::TupleExpr( const TupleExpr &other ) : Expression( other ) { 52 48 cloneAll( other.exprs, exprs ); 53 }54 55 TupleExpr::~TupleExpr() {56 deleteAll( exprs );57 49 } 58 50 … … 72 64 73 65 TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) { 74 }75 76 TupleIndexExpr::~TupleIndexExpr() {77 delete tuple;78 66 } 79 67 … … 105 93 } 106 94 107 TupleAssignExpr::~TupleAssignExpr() {108 delete stmtExpr;109 }110 111 95 void TupleAssignExpr::print( std::ostream &os, Indenter indent ) const { 112 96 os << "Tuple Assignment Expression, with stmt expr:" << std::endl; -
src/SynTree/TupleType.cc
r6171841 r68f9c43 43 43 } 44 44 45 TupleType::~TupleType() {46 deleteAll( types );47 deleteAll( members );48 }49 50 45 void TupleType::print( std::ostream &os, Indenter indent ) const { 51 46 Type::print( os, indent ); -
src/SynTree/Type.cc
r6171841 r68f9c43 57 57 } 58 58 59 Type::~Type() {60 deleteAll( forall );61 deleteAll( attributes );62 }63 64 59 // These must remain in the same order as the corresponding bit fields. 65 60 const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" }; -
src/SynTree/Type.h
r6171841 r68f9c43 141 141 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 142 142 Type( const Type & other ); 143 virtual ~Type();144 143 145 144 Qualifiers & get_qualifiers() { return tq; } … … 261 260 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 262 261 PointerType( const PointerType& ); 263 virtual ~PointerType();264 262 265 263 Type *get_base() { return base; } … … 291 289 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 292 290 ArrayType( const ArrayType& ); 293 virtual ~ArrayType();294 291 295 292 Type *get_base() { return base; } … … 319 316 ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 320 317 ReferenceType( const ReferenceType & ); 321 virtual ~ReferenceType();322 318 323 319 Type *get_base() { return base; } … … 352 348 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 353 349 FunctionType( const FunctionType& ); 354 virtual ~FunctionType();355 350 356 351 std::list<DeclarationWithType*> & get_returnVals() { return returnVals; } … … 376 371 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 377 372 ReferenceToType( const ReferenceToType & other ); 378 virtual ~ReferenceToType();379 373 380 374 const std::string & get_name() const { return name; } … … 503 497 TraitInstType( const Type::Qualifiers & tq, TraitDecl * baseTrait, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 504 498 TraitInstType( const TraitInstType & other ); 505 ~TraitInstType();506 499 507 500 virtual bool isComplete() const override; … … 525 518 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 526 519 TypeInstType( const TypeInstType & other ); 527 ~TypeInstType();528 520 529 521 TypeDecl *get_baseType() const { return baseType; } … … 549 541 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 550 542 TupleType( const TupleType& ); 551 virtual ~TupleType();552 543 553 544 typedef std::list<Type*> value_type; … … 583 574 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 584 575 TypeofType( const TypeofType& ); 585 virtual ~TypeofType();586 576 587 577 Expression *get_expr() const { return expr; } … … 606 596 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 607 597 AttrType( const AttrType& ); 608 virtual ~AttrType();609 598 610 599 const std::string & get_name() const { return name; } -
src/SynTree/TypeDecl.cc
r6171841 r68f9c43 25 25 26 26 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) { 27 }28 29 TypeDecl::~TypeDecl() {30 delete init;31 27 } 32 28 -
src/SynTree/TypeExpr.cc
r6171841 r68f9c43 26 26 } 27 27 28 TypeExpr::~TypeExpr() {29 delete type;30 }31 32 28 void TypeExpr::print( std::ostream &os, Indenter indent ) const { 33 29 if ( type ) type->print( os, indent ); -
src/SynTree/TypeSubstitution.cc
r6171841 r68f9c43 26 26 } 27 27 28 TypeSubstitution::~TypeSubstitution() {29 for ( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {30 delete( i->second );31 }32 for ( VarEnvType::iterator i = varEnv.begin(); i != varEnv.end(); ++i ) {33 delete( i->second );34 }35 }36 37 28 TypeSubstitution &TypeSubstitution::operator=( const TypeSubstitution &other ) { 38 29 if ( this == &other ) return *this; … … 57 48 58 49 void TypeSubstitution::add( std::string formalType, Type *actualType ) { 59 TypeEnvType::iterator i = typeEnv.find( formalType );60 if ( i != typeEnv.end() ) {61 delete i->second;62 } // if63 50 typeEnv[ formalType ] = actualType->clone(); 64 51 } 65 52 66 53 void TypeSubstitution::remove( std::string formalType ) { 67 TypeEnvType::iterator i = typeEnv.find( formalType ); 68 if ( i != typeEnv.end() ) { 69 delete i->second; 70 typeEnv.erase( formalType ); 71 } // if 54 typeEnv.erase( formalType ); 72 55 } 73 56 … … 155 138 Type * newtype = i->second->clone(); 156 139 newtype->get_qualifiers() |= inst->get_qualifiers(); 157 delete inst;158 140 return newtype; 159 141 } // if … … 166 148 } else { 167 149 subCount++; 168 delete nameExpr;169 150 return i->second->clone(); 170 151 } // if -
src/SynTree/TypeSubstitution.h
r6171841 r68f9c43 35 35 TypeSubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ); 36 36 TypeSubstitution( const TypeSubstitution &other ); 37 virtual ~TypeSubstitution();38 37 39 38 TypeSubstitution &operator=( const TypeSubstitution &other ); … … 101 100 if ( TypeExpr *actual = dynamic_cast< TypeExpr* >( *actualIt ) ) { 102 101 if ( formal->get_name() != "" ) { 103 TypeEnvType::iterator i = typeEnv.find( formal->get_name() );104 if ( i != typeEnv.end() ) {105 delete i->second;106 } // if107 102 typeEnv[ formal->get_name() ] = actual->get_type()->clone(); 108 103 } // if -
src/SynTree/TypeofType.cc
r6171841 r68f9c43 29 29 } 30 30 31 TypeofType::~TypeofType() {32 delete expr;33 }34 35 31 void TypeofType::print( std::ostream &os, Indenter indent ) const { 36 32 Type::print( os, indent ); -
src/SynTree/module.mk
r6171841 r68f9c43 48 48 SynTree/TypeSubstitution.cc \ 49 49 SynTree/Attribute.cc \ 50 SynTree/GcTracer.cc \ 50 51 SynTree/VarExprReplacer.cc 51 52 -
src/Tuples/Explode.cc
r6171841 r68f9c43 70 70 // should now be a tuple of references rather than a reference to a tuple. 71 71 // Still, this code is a bit awkward, and could use some improvement. 72 UniqueExpr * newUniqueExpr = new UniqueExpr( applyCast( uniqueExpr->get_expr() ), uniqueExpr->get_id() ); 73 delete uniqueExpr; 72 UniqueExpr * newUniqueExpr = new UniqueExpr{ applyCast( uniqueExpr->get_expr() ), uniqueExpr->get_id() }; 74 73 if ( castAdded ) { 75 74 // if a cast was added by applyCast, then unique expr now has one more layer of reference … … 88 87 // field is consistent with the type of the tuple expr, since the field 89 88 // may have changed from type T to T&. 90 Expression * expr = tupleExpr->get_tuple(); 91 tupleExpr->set_tuple( nullptr ); 92 TupleIndexExpr * ret = new TupleIndexExpr( expr, tupleExpr->get_index() ); 93 delete tupleExpr; 94 return ret; 89 return new TupleIndexExpr{ tupleExpr->get_tuple(), tupleExpr->get_index() }; 95 90 } 96 91 }; -
src/Tuples/Explode.h
r6171841 r68f9c43 27 27 namespace SymTab { 28 28 class Indexer; 29 } // namespace SymTab 29 } // namespace SymTabf 30 30 31 31 namespace Tuples { … … 67 67 for ( ResolvExpr::Alternative & alt : alts ) { 68 68 // distribute reference cast over all components 69 append( std::forward<Output>(out), distributeReference( alt. release_expr()),69 append( std::forward<Output>(out), distributeReference( alt.expr ), 70 70 alt.env, alt.cost, alt.cvtCost ); 71 71 } … … 96 96 TupleIndexExpr * idx = new TupleIndexExpr( arg->clone(), i ); 97 97 explodeUnique( idx, alt, indexer, std::forward<Output>(out), isTupleAssign ); 98 delete idx;99 98 } 100 delete arg;101 99 } 102 100 } else { -
src/Tuples/TupleExpansion.cc
r6171841 r68f9c43 45 45 46 46 std::map< int, Expression * > decls; // not vector, because order added may not be increasing order 47 48 ~UniqueExprExpander() {49 for ( std::pair<const int, Expression *> & p : decls ) {50 delete p.second;51 }52 }53 47 }; 54 48 … … 111 105 UntypedMemberExpr * newMemberExpr = new UntypedMemberExpr( memberExpr->member, inner ); 112 106 inner->location = newMemberExpr->location = loc; 113 memberExpr->member = nullptr;114 memberExpr->aggregate = nullptr;115 delete memberExpr;116 107 return newMemberExpr->acceptMutator( expander ); 117 108 } else { … … 135 126 expr->location = memberExpr->location; 136 127 } 137 delete aggr;138 128 tupleExpr->location = memberExpr->location; 139 129 return tupleExpr; … … 181 171 decls[id] = condExpr; 182 172 } 183 delete unqExpr;184 173 return decls[id]->clone(); 185 174 } … … 191 180 ret->set_env( assnExpr->get_env() ); 192 181 assnExpr->set_env( nullptr ); 193 delete assnExpr;194 182 return ret; 195 183 } … … 222 210 newType->get_parameters().push_back( new TypeExpr( t->clone() ) ); 223 211 } 224 delete tupleType;225 212 return newType; 226 213 } … … 233 220 TypeSubstitution * env = tupleExpr->get_env(); 234 221 tupleExpr->set_env( nullptr ); 235 delete tupleExpr;236 222 237 223 StructInstType * type = strict_dynamic_cast< StructInstType * >( tuple->get_result() ); … … 275 261 TypeSubstitution * env = tupleExpr->get_env(); 276 262 277 // remove data from shell and delete it 278 tupleExpr->set_result( nullptr ); 279 tupleExpr->get_exprs().clear(); 263 // remove data from shell 280 264 tupleExpr->set_env( nullptr ); 281 delete tupleExpr;282 265 283 266 return replaceTupleExpr( result, exprs, env ); -
src/Virtual/ExpandCasts.cc
r6171841 r68f9c43 139 139 ObjectDecl * table = found->second; 140 140 141 Expression * result = new CastExpr(141 return new CastExpr{ 142 142 //new ApplicationExpr( 143 143 //new AddressExpr( new VariableExpr( vcast_decl ) ), … … 158 158 } ), 159 159 castExpr->get_result()->clone() 160 ); 161 162 castExpr->set_arg( nullptr ); 163 castExpr->set_result( nullptr ); 164 delete castExpr; 165 return result; 160 }; 166 161 } 167 162 -
src/main.cc
r6171841 r68f9c43 37 37 #include "Common/PassVisitor.h" 38 38 #include "Common/CompilerError.h" // for CompilerError 39 #include "Common/GC.h" // for GC 39 40 #include "Common/SemanticError.h" // for SemanticError 40 41 #include "Common/UnimplementedError.h" // for UnimplementedError … … 57 58 #include "SymTab/Validate.h" // for validate 58 59 #include "SynTree/Declaration.h" // for Declaration 60 #include "SynTree/GcTracer.h" // for GC << TranslationUnit 59 61 #include "SynTree/Visitor.h" // for acceptAll 60 62 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... … … 64 66 65 67 #define OPTPRINT(x) if ( errorp ) cerr << x << endl; 66 67 68 68 69 LinkageSpec::Spec linkage = LinkageSpec::Cforall; … … 233 234 delete parseTree; 234 235 parseTree = nullptr; 236 collect( translationUnit ); 235 237 236 238 if ( astp ) { … … 242 244 OPTPRINT( "validate" ) 243 245 SymTab::validate( translationUnit, symtabp ); 244 if ( symtabp ) { 245 deleteAll( translationUnit ); 246 return 0; 247 } // if 246 collect( translationUnit ); 247 if ( symtabp ) return 0; 248 248 249 249 if ( expraltp ) { … … 266 266 OPTPRINT( "expandMemberTuples" ); 267 267 Tuples::expandMemberTuples( translationUnit ); 268 collect( translationUnit ); 268 269 if ( libcfap ) { 269 270 // generate the bodies of cfa library functions … … 273 274 if ( declstatsp ) { 274 275 CodeTools::printDeclStats( translationUnit ); 275 deleteAll( translationUnit );276 276 return 0; 277 277 } … … 286 286 OPTPRINT( "resolve" ) 287 287 ResolvExpr::resolve( translationUnit ); 288 collect( translationUnit ); 288 289 if ( exprp ) { 289 290 dump( translationUnit ); … … 294 295 OPTPRINT( "fixInit" ) 295 296 InitTweak::fix( translationUnit, filename, libcfap || treep ); 297 collect( translationUnit ); 296 298 if ( ctorinitp ) { 297 299 dump ( translationUnit ); … … 313 315 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this? 314 316 Tuples::expandTuples( translationUnit ); 317 collect( translationUnit ); 315 318 if ( tuplep ) { 316 319 dump( translationUnit ); … … 323 326 OPTPRINT("instantiateGenerics") 324 327 GenPoly::instantiateGeneric( translationUnit ); 328 collect( translationUnit ); 325 329 if ( genericsp ) { 326 330 dump( translationUnit ); 327 331 return 0; 328 332 } 333 329 334 OPTPRINT( "convertLvalue" ) 330 335 GenPoly::convertLvalue( translationUnit ); 331 332 336 collect( translationUnit ); 333 337 if ( bboxp ) { 334 338 dump( translationUnit ); 335 339 return 0; 336 340 } // if 341 337 342 OPTPRINT( "box" ) 338 343 GenPoly::box( translationUnit ); 339 344 collect( translationUnit ); 340 345 if ( bcodegenp ) { 341 346 dump( translationUnit ); … … 383 388 } // try 384 389 385 deleteAll( translationUnit );386 390 return 0; 387 391 } // main … … 568 572 printAll( decls, out ); 569 573 } 570 deleteAll( translationUnit );571 574 } // dump 572 575
Note: See TracChangeset
for help on using the changeset viewer.