Changes in / [34c32f0:7b2c8c3c]
- Location:
- src
- Files:
-
- 2 edited
-
AST/Pass.impl.hpp (modified) (2 diffs)
-
ControlStruct/MultiLevelExit.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r34c32f0 r7b2c8c3c 1050 1050 VISIT_START( node ); 1051 1051 1052 <<<<<<< HEAD1053 VISIT(1054 maybe_accept( node, &MutexStmt::mutexObjs );1055 {1056 // mutex statements introduce a level of scope (for the initialization)1057 guard_symtab guard { *this };1058 maybe_accept( node, &MutexStmt::stmt );1059 1060 }1061 )1062 =======1063 1052 if ( __visit_children() ) { 1064 1053 // mutex statements introduce a level of scope (for the initialization) … … 1067 1056 maybe_accept( node, &MutexStmt::mutexObjs ); 1068 1057 } 1069 >>>>>>> e21f2536b7495654ded040259b42b7e2325b83601070 1058 1071 1059 VISIT_END( Stmt, node ); -
src/ControlStruct/MultiLevelExit.cpp
r34c32f0 r7b2c8c3c 71 71 bool isFallDefaultTarget() const { return kind == SwitchStmtK; } 72 72 73 // These routines set a target as being "used" by a BranchStmt74 73 Label useContExit() { assert( kind <= WhileStmtK ); return useTarget(secondTarget); } 75 74 Label useBreakExit() { assert( kind != CaseStmtK ); return useTarget(firstTarget); } … … 77 76 Label useFallDefaultExit() { assert( kind == SwitchStmtK ); return useTarget(secondTarget); } 78 77 79 // These routines check if a specific label for a statement is used by a BranchStmt80 78 bool isContUsed() const { assert( kind <= WhileStmtK ); return secondTarget.used; } 81 79 bool isBreakUsed() const { assert( kind != CaseStmtK ); return firstTarget.used; } … … 166 164 const CompoundStmt * stmt ) { 167 165 visit_children = false; 168 169 // if the stmt is labelled then generate a label to check in postvisit if the label is used170 166 bool isLabeled = !stmt->labels.empty(); 171 167 if ( isLabeled ) { … … 221 217 } 222 218 223 // This routine updates targets on enclosing control structures to indicate which224 // label is used by the BranchStmt that is passed225 219 const BranchStmt * MultiLevelExitCore::postvisit( const BranchStmt * stmt ) { 226 220 vector<Entry>::reverse_iterator targetEntry = 227 221 enclosing_control_structures.rend(); 228 229 // Labels on different stmts require different approaches to access230 222 switch ( stmt->kind ) { 231 223 case BranchStmt::Goto: … … 261 253 break; 262 254 } 263 // handle fallthrough in case/switch stmts264 255 case BranchStmt::FallThrough: { 265 256 targetEntry = findEnclosingControlStructure( isFallthroughTarget ); … … 539 530 } 540 531 541 // if continue is used insert a continue label into the back of the body of the loop542 532 if ( entry.isContUsed() ) { 543 533 CompoundStmt * new_body = new CompoundStmt( body->location ); 544 // {}545 534 new_body->kids.push_back( body ); 546 // {547 // body548 // }549 535 new_body->kids.push_back( 550 536 labelledNullStmt( body->location, entry.useContExit() ) ); 551 // {552 // body553 // ContinueLabel: {}554 // }555 537 return new_body; 556 538 } … … 566 548 Label contLabel = newLabel( "loopContinue", loopStmt ); 567 549 enclosing_control_structures.emplace_back( loopStmt, breakLabel, contLabel ); 568 // labels are added temporarily to see if they are used and then added permanently in postvisit if ther are used569 // children will tag labels as being used during their traversal which occurs before postvisit570 571 // GuardAction calls the lambda after the node is done being visited572 550 GuardAction( [this](){ enclosing_control_structures.pop_back(); } ); 573 551 } … … 582 560 return mutate_field( 583 561 loopStmt, &LoopNode::body, mutateLoop( loopStmt->body, entry ) ); 584 // this call to mutate_field compares loopStmt->body and the result of mutateLoop585 // if they are the same the node isn't mutated, if they differ then the new mutated node is returned586 // the stmts will only differ if a label is used587 562 } 588 563
Note:
See TracChangeset
for help on using the changeset viewer.