Changes in src/SynTree/Expression.cc [68f9c43:9a705dc8]
- File:
-
- 1 edited
-
src/SynTree/Expression.cc (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r68f9c43 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 … … 238 271 } 239 272 240 CastExpr::CastExpr( Expression *arg _, Type *toType ) : Expression(), arg(arg_) {273 CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) { 241 274 set_result(toType); 242 275 } 243 276 244 CastExpr::CastExpr( Expression *arg _ ) : Expression(), arg(arg_) {277 CastExpr::CastExpr( Expression *arg, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) { 245 278 set_result( new VoidType( Type::Qualifiers() ) ); 246 279 } 247 280 248 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) { 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 … … 262 299 } 263 300 301 KeywordCastExpr::KeywordCastExpr( Expression *arg, Target target ) : Expression(), arg(arg), target( target ) { 302 } 303 304 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) { 305 } 306 307 KeywordCastExpr::~KeywordCastExpr() { 308 delete arg; 309 } 310 311 const std::string & KeywordCastExpr::targetString() const { 312 static const std::string targetStrs[] = { 313 "coroutine", "thread", "monitor" 314 }; 315 static_assert( 316 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS), 317 "Each KeywordCastExpr::Target should have a corresponding string representation" 318 ); 319 return targetStrs[(unsigned long)target]; 320 } 321 322 void KeywordCastExpr::print( std::ostream &os, Indenter indent ) const { 323 os << "Keyword Cast of:" << std::endl << indent+1; 324 arg->print(os, indent+1); 325 os << std::endl << indent << "... to: "; 326 os << targetString(); 327 Expression::print( os, indent ); 328 } 329 264 330 VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) { 265 331 set_result(toType); … … 267 333 268 334 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) { 335 } 336 337 VirtualCastExpr::~VirtualCastExpr() { 338 delete arg; 269 339 } 270 340 … … 291 361 } 292 362 363 UntypedMemberExpr::~UntypedMemberExpr() { 364 delete aggregate; 365 delete member; 366 } 367 293 368 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const { 294 369 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 317 392 } 318 393 394 MemberExpr::~MemberExpr() { 395 // don't delete the member declaration, since it points somewhere else in the tree 396 delete aggregate; 397 } 398 319 399 void MemberExpr::print( std::ostream &os, Indenter indent ) const { 320 400 os << "Member Expression, with field: " << std::endl; … … 332 412 Expression( other ), function( maybeClone( other.function ) ) { 333 413 cloneAll( other.args, args ); 414 } 415 416 UntypedExpr::~UntypedExpr() { 417 delete function; 418 deleteAll( args ); 334 419 } 335 420 … … 380 465 } 381 466 467 NameExpr::~NameExpr() {} 468 382 469 void NameExpr::print( std::ostream &os, Indenter indent ) const { 383 470 os << "Name: " << get_name(); … … 392 479 LogicalExpr::LogicalExpr( const LogicalExpr &other ) : 393 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; 394 486 } 395 487 … … 407 499 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) : 408 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; 409 507 } 410 508 … … 444 542 ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() { 445 543 set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment 544 delete callExpr; 545 deleteAll( tempDecls ); 546 deleteAll( returnDecls ); 547 deleteAll( dtors ); 446 548 } 447 549 … … 468 570 } 469 571 572 ConstructorExpr::~ConstructorExpr() { 573 delete callExpr; 574 } 575 470 576 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const { 471 577 os << "Constructor Expression: " << std::endl << indent+1; … … 482 588 483 589 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {} 590 591 CompoundLiteralExpr::~CompoundLiteralExpr() { 592 delete initializer; 593 } 484 594 485 595 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const { … … 508 618 cloneAll( other.dtors, dtors ); 509 619 } 620 StmtExpr::~StmtExpr() { 621 delete statements; 622 deleteAll( dtors ); 623 deleteAll( returnDecls ); 624 } 510 625 void StmtExpr::computeResult() { 511 626 assert( statements ); 512 627 std::list< Statement * > & body = statements->kids; 628 delete result; 513 629 result = nullptr; 514 630 if ( ! returnDecls.empty() ) { … … 553 669 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) { 554 670 } 555 671 UniqueExpr::~UniqueExpr() { 672 delete expr; 673 delete object; 674 delete var; 675 } 556 676 void UniqueExpr::print( std::ostream &os, Indenter indent ) const { 557 677 os << "Unique Expression with id:" << id << std::endl << indent+1; … … 566 686 InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {} 567 687 InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {} 688 InitAlternative::~InitAlternative() { 689 delete type; 690 delete designation; 691 } 568 692 569 693 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {} 570 694 UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {} 695 UntypedInitExpr::~UntypedInitExpr() { 696 delete expr; 697 } 571 698 572 699 void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const { … … 586 713 } 587 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 } 588 719 589 720 void InitExpr::print( std::ostream & os, Indenter indent ) const { … … 599 730 } 600 731 DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {} 732 DeletedExpr::~DeletedExpr() { 733 delete expr; 734 } 601 735 602 736 void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
Note:
See TracChangeset
for help on using the changeset viewer.