Changeset e39aa0f for src/InitTweak/FixInit.cc
- Timestamp:
- Jun 28, 2016, 3:33:01 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 4dcea3f
- Parents:
- 888cbe4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r888cbe4 re39aa0f 35 35 bool ctorp = false; 36 36 bool cpctorp = false; 37 bool dtorp = true;37 bool dtorp = false; 38 38 #define PRINT( text ) if ( ctordtorp ) { text } 39 39 #define CP_CTOR_PRINT( text ) if ( ctordtorp || cpctorp ) { text } … … 499 499 curVars.insert( objDecl ); 500 500 } 501 returnParent::visit( stmt );501 Parent::visit( stmt ); 502 502 } 503 503 … … 563 563 } 564 564 565 // Handle break/continue/goto in the same manner as C++. 566 // Basic idea: any objects that are in scope at the BranchStmt 567 // but not at the labelled (target) statement must be destructed. 568 // If there are any objects in scope at the target location but 569 // not at the BranchStmt then those objects would be uninitialized 570 // so notify the user of the error. 571 // See C++ Reference 6.6 Jump Statements for details. 565 572 void InsertDtors::handleGoto( BranchStmt * stmt ) { 566 assert( stmt->get_t ype() == BranchStmt::Goto);573 assert( stmt->get_target() != "" && "BranchStmt missing a label" ); 567 574 // S_L = lvars = set of objects in scope at label definition 568 575 // S_G = curVars = set of objects in scope at goto statement … … 602 609 603 610 void InsertDtors::visit( BranchStmt * stmt ) { 604 // TODO: adding to the end of a block isn't sufficient, since605 // return/break/goto should trigger destructor when block is left.606 611 switch( stmt->get_type() ) { 607 612 case BranchStmt::Continue: 608 613 case BranchStmt::Break: 609 // xxx - easiest thing to do: generate a label for every break/continue 610 // this label is unused, so attach unused attribute to it 611 // finally, all of these cases can be the same (this is less efficient than it could be, 612 // because the S_L-S_G check is unnecessary [the set should always be empty], but this 613 // serves as a bit of a sanity check, so I'm okay with it.) 614 // xxx - this is insufficient, because multiple blocks can be opened in a switch or loop 615 insertDtors( reverseDeclOrder.front().begin(), reverseDeclOrder.front().end(), back_inserter( stmtsToAdd ) ); 616 break; 614 // could optimize the break/continue case, because the S_L-S_G check 615 // is unnecessary (this set should always be empty), but it serves 616 // as a small sanity check. 617 617 case BranchStmt::Goto: 618 618 handleGoto( stmt );
Note: See TracChangeset
for help on using the changeset viewer.