Changes in src/SynTree/Expression.cc [42107b4:cdb990a]
- File:
-
- 1 edited
-
src/SynTree/Expression.cc (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r42107b4 rcdb990a 50 50 } 51 51 52 void Expression::spliceInferParams( Expression * other ) { 53 if ( ! other ) return; 54 for ( auto p : other->inferParams ) { 55 inferParams[p.first] = std::move( p.second ); 56 } 57 } 58 52 59 Expression::~Expression() { 53 60 delete env; 61 delete result; 54 62 } 55 63 … … 73 81 ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) { 74 82 } 83 84 ConstantExpr::~ConstantExpr() {} 75 85 76 86 void ConstantExpr::print( std::ostream &os, Indenter indent ) const { … … 117 127 } 118 128 129 VariableExpr::~VariableExpr() { 130 // don't delete the declaration, since it points somewhere else in the tree 131 } 132 119 133 VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) { 120 134 VariableExpr * funcExpr = new VariableExpr( func ); … … 143 157 } 144 158 159 SizeofExpr::~SizeofExpr() { 160 delete expr; 161 delete type; 162 } 163 145 164 void SizeofExpr::print( std::ostream &os, Indenter indent) const { 146 165 os << "Sizeof Expression on: "; … … 164 183 } 165 184 185 AlignofExpr::~AlignofExpr() { 186 delete expr; 187 delete type; 188 } 189 166 190 void AlignofExpr::print( std::ostream &os, Indenter indent) const { 167 191 os << "Alignof Expression on: "; … … 179 203 UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) : 180 204 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {} 205 206 UntypedOffsetofExpr::~UntypedOffsetofExpr() { 207 delete type; 208 } 181 209 182 210 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const { … … 196 224 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {} 197 225 226 OffsetofExpr::~OffsetofExpr() { 227 delete type; 228 } 229 198 230 void OffsetofExpr::print( std::ostream &os, Indenter indent) const { 199 231 os << "Offsetof Expression on member " << member->name << " of "; … … 209 241 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {} 210 242 243 OffsetPackExpr::~OffsetPackExpr() { delete type; } 244 211 245 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const { 212 246 os << "Offset pack expression on "; … … 225 259 AttrExpr::AttrExpr( const AttrExpr &other ) : 226 260 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) { 261 } 262 263 AttrExpr::~AttrExpr() { 264 delete attr; 265 delete expr; 266 delete type; 227 267 } 228 268 … … 247 287 248 288 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) { 289 } 290 291 CastExpr::~CastExpr() { 292 delete arg; 249 293 } 250 294 … … 268 312 } 269 313 314 KeywordCastExpr::~KeywordCastExpr() { 315 delete arg; 316 } 317 270 318 const std::string & KeywordCastExpr::targetString() const { 271 319 static const std::string targetStrs[] = { … … 292 340 293 341 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) { 342 } 343 344 VirtualCastExpr::~VirtualCastExpr() { 345 delete arg; 294 346 } 295 347 … … 316 368 } 317 369 370 UntypedMemberExpr::~UntypedMemberExpr() { 371 delete aggregate; 372 delete member; 373 } 374 318 375 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const { 319 376 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 342 399 } 343 400 401 MemberExpr::~MemberExpr() { 402 // don't delete the member declaration, since it points somewhere else in the tree 403 delete aggregate; 404 } 405 344 406 void MemberExpr::print( std::ostream &os, Indenter indent ) const { 345 407 os << "Member Expression, with field: " << std::endl; … … 357 419 Expression( other ), function( maybeClone( other.function ) ) { 358 420 cloneAll( other.args, args ); 421 } 422 423 UntypedExpr::~UntypedExpr() { 424 delete function; 425 deleteAll( args ); 359 426 } 360 427 … … 405 472 } 406 473 474 NameExpr::~NameExpr() {} 475 407 476 void NameExpr::print( std::ostream &os, Indenter indent ) const { 408 477 os << "Name: " << get_name(); … … 417 486 LogicalExpr::LogicalExpr( const LogicalExpr &other ) : 418 487 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) { 488 } 489 490 LogicalExpr::~LogicalExpr() { 491 delete arg1; 492 delete arg2; 419 493 } 420 494 … … 432 506 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) : 433 507 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) { 508 } 509 510 ConditionalExpr::~ConditionalExpr() { 511 delete arg1; 512 delete arg2; 513 delete arg3; 434 514 } 435 515 … … 469 549 ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() { 470 550 set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment 551 delete callExpr; 552 deleteAll( tempDecls ); 553 deleteAll( returnDecls ); 554 deleteAll( dtors ); 471 555 } 472 556 … … 493 577 } 494 578 579 ConstructorExpr::~ConstructorExpr() { 580 delete callExpr; 581 } 582 495 583 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const { 496 584 os << "Constructor Expression: " << std::endl << indent+1; … … 507 595 508 596 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {} 597 598 CompoundLiteralExpr::~CompoundLiteralExpr() { 599 delete initializer; 600 } 509 601 510 602 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const { … … 533 625 cloneAll( other.dtors, dtors ); 534 626 } 627 StmtExpr::~StmtExpr() { 628 delete statements; 629 deleteAll( dtors ); 630 deleteAll( returnDecls ); 631 } 535 632 void StmtExpr::computeResult() { 536 633 assert( statements ); 537 634 std::list< Statement * > & body = statements->kids; 635 delete result; 538 636 result = nullptr; 539 637 if ( ! returnDecls.empty() ) { … … 578 676 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) { 579 677 } 580 678 UniqueExpr::~UniqueExpr() { 679 delete expr; 680 delete object; 681 delete var; 682 } 581 683 void UniqueExpr::print( std::ostream &os, Indenter indent ) const { 582 684 os << "Unique Expression with id:" << id << std::endl << indent+1; … … 591 693 InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {} 592 694 InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {} 695 InitAlternative::~InitAlternative() { 696 delete type; 697 delete designation; 698 } 593 699 594 700 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {} 595 701 UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {} 702 UntypedInitExpr::~UntypedInitExpr() { 703 delete expr; 704 } 596 705 597 706 void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const { … … 611 720 } 612 721 InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {} 722 InitExpr::~InitExpr() { 723 delete expr; 724 delete designation; 725 } 613 726 614 727 void InitExpr::print( std::ostream & os, Indenter indent ) const { … … 624 737 } 625 738 DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {} 739 DeletedExpr::~DeletedExpr() { 740 delete expr; 741 } 626 742 627 743 void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
Note:
See TracChangeset
for help on using the changeset viewer.