[flang] Avoid crashing from recursion on very tall expression parse trees
In the parse tree visitation framework (Parser/parse-tree-visitor.h) and in the semantic analyzer for expressions (Semantics/expression.cpp) avoid crashing due to stack size limitations by using an iterative traversal algorithm rather than straightforward recursive tree walking. The iterative approach is the obvious one of building a work queue and using it to (in the case of the parse tree visitor) call the visitor object's Pre() and Post() routines on subexpressions in the same order as they would have been called during a recursive traversal. This change helps the compiler survive some artificial stress tests and perhaps with future exposure to machine-generated source code. Differential Revision: https://reviews.llvm.org/D142771
Loading
Please sign in to comment