Created by: eafer
As requested, I'm splitting the first three patches from #14379 into a new pull request to make them easier to review. These fix a few compilation errors for the generated code, but they are not enough by themselves to get it to build.