mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Remove `leave` at end of function.
				
					
				
			This commit is contained in:
		
							parent
							
								
									ceb8ee9124
								
							
						
					
					
						commit
						f98925d8b6
					
				| @ -136,6 +136,13 @@ void ControlFlowSimplifier::operator()(Block& _block) | ||||
| 	simplify(_block.statements); | ||||
| } | ||||
| 
 | ||||
| void ControlFlowSimplifier::operator()(FunctionDefinition& _funDef) | ||||
| { | ||||
| 	ASTModifier::operator()(_funDef); | ||||
| 	if (!_funDef.body.statements.empty() && _funDef.body.statements.back().type() == typeid(Leave)) | ||||
| 		_funDef.body.statements.pop_back(); | ||||
| } | ||||
| 
 | ||||
| void ControlFlowSimplifier::visit(Statement& _st) | ||||
| { | ||||
| 	if (_st.type() == typeid(ForLoop)) | ||||
|  | ||||
| @ -34,6 +34,7 @@ struct OptimiserStepContext; | ||||
|  * - replace switch with only default case with pop(expression) and body | ||||
|  * - replace switch with const expr with matching case body | ||||
|  * - replace ``for`` with terminating control flow and without other break/continue by ``if`` | ||||
|  * - remove ``leave`` at the end of a function. | ||||
|  * | ||||
|  * None of these operations depend on the data flow. The StructuralSimplifier | ||||
|  * performs similar tasks that do depend on data flow. | ||||
| @ -55,6 +56,7 @@ public: | ||||
| 	void operator()(Break&) override { ++m_numBreakStatements; } | ||||
| 	void operator()(Continue&) override { ++m_numContinueStatements; } | ||||
| 	void operator()(Block& _block) override; | ||||
| 	void operator()(FunctionDefinition& _funDef) override; | ||||
| 
 | ||||
| 	void visit(Statement& _st) override; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user