This mostly uses the code from oldcpp. Which I cleaned up a bit and removed a lot of unused functionality. Still I had to introduce a couple of changes to the code due to e.g. inconsistencies in internal vs. function contexts with oldcpp.
Also while working on it I discovered a couple of related bugs in our codebase, which are included in this review, but will be landed in separated commits.
BUG: 358480
BUG: 355148