This patch provides a way for dialect parsers to have access to struct
parsing context. This allows, for example, dialects that support
recursive structs (like LLVM, SPIR-V) to properly handle those structs.
This is an attempt to address a comment on this review: https://reviews.llvm.org/D87206 to provide a common mechanism for maintaining the struct parsing stack.
I hope this is more or less addresses the issue. Since it touches quite a bit of the infrastructure I am not sure if this is a good direction or not. If not, apologies for the extra noise.
Another approach would be to maintain a stack of Type objects instead of StringRefs. This might provide a more general mechanism and enable other uses in addition to recursive structs (don't have a specific use-case in mind though). However, doing this will need different dialects to construct containing/enclosing types before their sub-types and then mutate the enclosing types after parsing is completed. Not sure that will be a good direction.
TODO: if this is agreed upon as a good approach, add docs here and elsewhere to describe the new bits.
Shouldn't we swap this and the above if conditions? At it is right now, we might not properly clean-up the struct stack if parsing the element type fails.