mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:42:43 +00:00 
			
		
		
		
	 b4a9fde756
			
		
	
	
		b4a9fde756
		
	
	
	
	
		
			
			RecursiveASTVisitor was recursing into the subtrees of an old root if it was changed in on_entry callback. Fix that by querying root pointer just after on_entry callback returns. While on it, also use `AK::TemporaryChange` instead of setting `m_current_subtree_pointer` manually. As it turns out, `FunctionCallCanonicalizationPass` was relying on being able to replace tree on entry, and the bug in RecursiveASTVisitor made the pass to not fully canonicalize nested function calls. The changes to GenericASTPass.cpp alone are enough to fix the problem but it is canonical (for some definition of canonicity) to only change trees in on_leave. Therefore, the commit also switches FunctionCallCanonicalizationPass to on_leave callback. A test for this fix and one from the previous commit is also included.
		
			
				
	
	
		
			21 lines
		
	
	
	
		
			524 B
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
	
		
			524 B
		
	
	
	
		
			Text
		
	
	
	
	
	
| ===== AST after reference-resolving =====
 | ||
| SystemUTCEpochMilliseconds():
 | ||
| TreeList
 | ||
|   BinaryOperation Assignment
 | ||
|     Var global
 | ||
|     FunctionCall
 | ||
|       UnresolvedReference GetGlobalObject
 | ||
|   BinaryOperation Assignment
 | ||
|     Var nowNs
 | ||
|     FunctionCall
 | ||
|       UnresolvedReference HostSystemUTCEpochNanoseconds
 | ||
|       Var global
 | ||
|   ReturnNode
 | ||
|     FunctionCall
 | ||
|       UnresolvedReference 𝔽
 | ||
|       FunctionCall
 | ||
|         UnresolvedReference floor
 | ||
|         BinaryOperation Division
 | ||
|           Var nowNs
 | ||
|           MathematicalConstant 1000000
 | ||
| 
 |