This patch extracts the eof/stop token pattern used in late-parsing to a re-usable RAII class. This simplifies a lot of the late-parsing code.
A few related bugs were fixed in the process:
- Late-parsing a method with default arguments but without an exception specification would result in an invalid union access. It was mostly harmless but it's technically undefined behaviour.
- When an inherited late-parsed parameter is encountered, the associated declaration is force-casted to FunctionDecl. This caused a crash when the declaration is a template.
Can you pass ownership of the cached tokens into here instead of passing a mutable reference? It makes me uncomfortable for this object to be modifying a list of tokens that it doesn't own (by adding an EOF token) -- that's not something I'd ever expect a utility with this name to do!