Page MenuHomePhabricator

[Parser] Refactor and fix bugs in late-parsing
Needs ReviewPublic

Authored by hamzasood on Aug 15 2018, 4:12 AM.



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.

Diff Detail

Event Timeline

hamzasood created this revision.Aug 15 2018, 4:12 AM
rsmith added inline comments.Jul 9 2019, 4:27 PM

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!

Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2019, 4:27 PM
malcolm.parsons resigned from this revision.Jan 13 2020, 9:14 AM