Changes in src/SynTree/Expression.cc [42107b4:9a705dc8]
- File:
-
- 1 edited
-
src/SynTree/Expression.cc (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r42107b4 r9a705dc8 52 52 Expression::~Expression() { 53 53 delete env; 54 delete result; 54 55 } 55 56 … … 73 74 ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) { 74 75 } 76 77 ConstantExpr::~ConstantExpr() {} 75 78 76 79 void ConstantExpr::print( std::ostream &os, Indenter indent ) const { … … 117 120 } 118 121 122 VariableExpr::~VariableExpr() { 123 // don't delete the declaration, since it points somewhere else in the tree 124 } 125 119 126 VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) { 120 127 VariableExpr * funcExpr = new VariableExpr( func ); … … 143 150 } 144 151 152 SizeofExpr::~SizeofExpr() { 153 delete expr; 154 delete type; 155 } 156 145 157 void SizeofExpr::print( std::ostream &os, Indenter indent) const { 146 158 os << "Sizeof Expression on: "; … … 164 176 } 165 177 178 AlignofExpr::~AlignofExpr() { 179 delete expr; 180 delete type; 181 } 182 166 183 void AlignofExpr::print( std::ostream &os, Indenter indent) const { 167 184 os << "Alignof Expression on: "; … … 179 196 UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) : 180 197 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {} 198 199 UntypedOffsetofExpr::~UntypedOffsetofExpr() { 200 delete type; 201 } 181 202 182 203 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const { … … 196 217 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {} 197 218 219 OffsetofExpr::~OffsetofExpr() { 220 delete type; 221 } 222 198 223 void OffsetofExpr::print( std::ostream &os, Indenter indent) const { 199 224 os << "Offsetof Expression on member " << member->name << " of "; … … 209 234 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {} 210 235 236 OffsetPackExpr::~OffsetPackExpr() { delete type; } 237 211 238 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const { 212 239 os << "Offset pack expression on "; … … 225 252 AttrExpr::AttrExpr( const AttrExpr &other ) : 226 253 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; 227 260 } 228 261 … … 247 280 248 281 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) { 282 } 283 284 CastExpr::~CastExpr() { 285 delete arg; 249 286 } 250 287 … … 268 305 } 269 306 307 KeywordCastExpr::~KeywordCastExpr() { 308 delete arg; 309 } 310 270 311 const std::string & KeywordCastExpr::targetString() const { 271 312 static const std::string targetStrs[] = { … … 292 333 293 334 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) { 335 } 336 337 VirtualCastExpr::~VirtualCastExpr() { 338 delete arg; 294 339 } 295 340 … … 316 361 } 317 362 363 UntypedMemberExpr::~UntypedMemberExpr() { 364 delete aggregate; 365 delete member; 366 } 367 318 368 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const { 319 369 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 342 392 } 343 393 394 MemberExpr::~MemberExpr() { 395 // don't delete the member declaration, since it points somewhere else in the tree 396 delete aggregate; 397 } 398 344 399 void MemberExpr::print( std::ostream &os, Indenter indent ) const { 345 400 os << "Member Expression, with field: " << std::endl; … … 357 412 Expression( other ), function( maybeClone( other.function ) ) { 358 413 cloneAll( other.args, args ); 414 } 415 416 UntypedExpr::~UntypedExpr() { 417 delete function; 418 deleteAll( args ); 359 419 } 360 420 … … 405 465 } 406 466 467 NameExpr::~NameExpr() {} 468 407 469 void NameExpr::print( std::ostream &os, Indenter indent ) const { 408 470 os << "Name: " << get_name(); … … 417 479 LogicalExpr::LogicalExpr( const LogicalExpr &other ) : 418 480 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) { 481 } 482 483 LogicalExpr::~LogicalExpr() { 484 delete arg1; 485 delete arg2; 419 486 } 420 487 … … 432 499 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) : 433 500 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) { 501 } 502 503 ConditionalExpr::~ConditionalExpr() { 504 delete arg1; 505 delete arg2; 506 delete arg3; 434 507 } 435 508 … … 469 542 ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() { 470 543 set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment 544 delete callExpr; 545 deleteAll( tempDecls ); 546 deleteAll( returnDecls ); 547 deleteAll( dtors ); 471 548 } 472 549 … … 493 570 } 494 571 572 ConstructorExpr::~ConstructorExpr() { 573 delete callExpr; 574 } 575 495 576 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const { 496 577 os << "Constructor Expression: " << std::endl << indent+1; … … 507 588 508 589 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {} 590 591 CompoundLiteralExpr::~CompoundLiteralExpr() { 592 delete initializer; 593 } 509 594 510 595 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const { … … 533 618 cloneAll( other.dtors, dtors ); 534 619 } 620 StmtExpr::~StmtExpr() { 621 delete statements; 622 deleteAll( dtors ); 623 deleteAll( returnDecls ); 624 } 535 625 void StmtExpr::computeResult() { 536 626 assert( statements ); 537 627 std::list< Statement * > & body = statements->kids; 628 delete result; 538 629 result = nullptr; 539 630 if ( ! returnDecls.empty() ) { … … 578 669 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) { 579 670 } 580 671 UniqueExpr::~UniqueExpr() { 672 delete expr; 673 delete object; 674 delete var; 675 } 581 676 void UniqueExpr::print( std::ostream &os, Indenter indent ) const { 582 677 os << "Unique Expression with id:" << id << std::endl << indent+1; … … 591 686 InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {} 592 687 InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {} 688 InitAlternative::~InitAlternative() { 689 delete type; 690 delete designation; 691 } 593 692 594 693 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {} 595 694 UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {} 695 UntypedInitExpr::~UntypedInitExpr() { 696 delete expr; 697 } 596 698 597 699 void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const { … … 611 713 } 612 714 InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {} 715 InitExpr::~InitExpr() { 716 delete expr; 717 delete designation; 718 } 613 719 614 720 void InitExpr::print( std::ostream & os, Indenter indent ) const { … … 624 730 } 625 731 DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {} 732 DeletedExpr::~DeletedExpr() { 733 delete expr; 734 } 626 735 627 736 void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
Note:
See TracChangeset
for help on using the changeset viewer.