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