Changeset 7f9968a
- Timestamp:
- Jun 24, 2020, 12:30:42 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8b58bae
- Parents:
- a8a3485
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ControlStruct/ExceptTranslate.cc ¶
ra8a3485 r7f9968a 10 10 // Created On : Wed Jun 14 16:49:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue May 26 10:56:00 202013 // Update Count : 1 612 // Last Modified On : Wed Jun 24 11:18:00 2020 13 // Update Count : 17 14 14 // 15 15 … … 72 72 ThrowStmt * throwStmt, const char * throwFunc ); 73 73 Statement * create_terminate_rethrow( ThrowStmt * throwStmt ); 74 Statement * create_resume_rethrow( ThrowStmt * throwStmt );75 74 76 75 public: … … 113 112 new UntypedExpr( new NameExpr( "__cfaehm_rethrow_terminate" ) ) 114 113 ) ); 115 delete throwStmt;116 return result;117 }118 119 Statement * ThrowMutatorCore::create_resume_rethrow(120 ThrowStmt *throwStmt ) {121 // return false;122 Statement * result = new ReturnStmt(123 new ConstantExpr( Constant::from_bool( false ) )124 );125 result->labels = throwStmt->labels;126 114 delete throwStmt; 127 115 return result; … … 167 155 return create_either_throw( throwStmt, "$throwResume" ); 168 156 } else if ( ResHandler == cur_context ) { 169 return create_resume_rethrow( throwStmt ); 157 // This has to be handled later. 158 return throwStmt; 170 159 } else { 171 160 abort("Invalid throwResume in %s at %i\n", … … 196 185 FunctionDecl * create_finally_wrapper( TryStmt * tryStmt ); 197 186 ObjectDecl * create_finally_hook( FunctionDecl * finally_wrapper ); 187 Statement * create_resume_rethrow( ThrowStmt * throwStmt ); 198 188 199 189 // Types used in translation, make sure to use clone. … … 227 217 void premutate( StructDecl *structDecl ); 228 218 Statement * postmutate( TryStmt *tryStmt ); 219 Statement * postmutate( ThrowStmt *throwStmt ); 229 220 }; 230 221 … … 594 585 attributes 595 586 ); 587 } 588 589 Statement * TryMutatorCore::create_resume_rethrow( ThrowStmt *throwStmt ) { 590 // return false; 591 Statement * result = new ReturnStmt( 592 new ConstantExpr( Constant::from_bool( false ) ) 593 ); 594 result->labels = throwStmt->labels; 595 delete throwStmt; 596 return result; 596 597 } 597 598 … … 668 669 } 669 670 671 Statement * TryMutatorCore::postmutate( ThrowStmt *throwStmt ) { 672 // Only valid `throwResume;` statements should remain. (2/3 checks) 673 assert( ThrowStmt::Resume == throwStmt->kind && ! throwStmt->expr ); 674 return create_resume_rethrow( throwStmt ); 675 } 676 670 677 void translateThrows( std::list< Declaration *> & translationUnit ) { 671 678 PassVisitor<ThrowMutatorCore> translator; -
TabularUnified tests/exceptions/.expect/resume.txt ¶
ra8a3485 r7f9968a 31 31 inner catch 32 32 outer catch 33 34 throw 35 rethrow 36 handle -
TabularUnified tests/exceptions/.expect/terminate.txt ¶
ra8a3485 r7f9968a 29 29 inner catch 30 30 outer catch 31 32 throw 33 rethrow 34 handle -
TabularUnified tests/exceptions/resume.cfa ¶
ra8a3485 r7f9968a 8 8 TRIVIAL_EXCEPTION(zen); 9 9 TRIVIAL_EXCEPTION(moment_of, zen); 10 11 void in_void(void); 10 12 11 13 int main(int argc, char * argv[]) { … … 121 123 printf("outer catch\n"); 122 124 } 125 printf("\n"); 126 127 in_void(); 123 128 } 129 130 // Do a throw and rethrow in a void function. 131 void in_void(void) { 132 try { 133 try { 134 printf("throw\n"); 135 throwResume (zen){}; 136 } catchResume (zen *) { 137 printf("rethrow\n"); 138 throwResume; 139 } 140 } catchResume (zen *) { 141 printf("handle\n"); 142 } 143 } -
TabularUnified tests/exceptions/terminate.cfa ¶
ra8a3485 r7f9968a 8 8 TRIVIAL_EXCEPTION(zen); 9 9 TRIVIAL_EXCEPTION(moment_of, zen); 10 11 void in_void(void); 10 12 11 13 int main(int argc, char * argv[]) { … … 121 123 printf("outer catch\n"); 122 124 } 125 printf("\n"); 126 127 in_void(); 123 128 } 129 130 // Do a throw and rethrow in a void function. 131 void in_void(void) { 132 try { 133 try { 134 printf("throw\n"); 135 throw (zen){}; 136 } catch (zen *) { 137 printf("rethrow\n"); 138 throw; 139 } 140 } catch (zen *) { 141 printf("handle\n"); 142 } 143 } 144
Note: See TracChangeset
for help on using the changeset viewer.