Over the past couple of days I've been exploring moving Swift diagnostic definitions from our current macro-based approach over to TableGen. This should make it significantly easier to define diagnostics with more complex metadata. However, it requires adding a new TableGen backend to generate headers from the definition files.
Initially, I followed clang's approach to adding custom backends by creating a new
swift-tblgen tool in the swift repo. This wouldn't replace
llvm-tblgen entirely, as we'd still use it for option parsing. It would support any other new swift-specific backends which don't make sense to upstream to LLVM. The main issue with this approach is that it potentially adds quite a bit of complexity to the swift build, especially when cross-compiling.
The other alternative I see at the moment is just contributing new swift-specific backends to the downstream
apple/llvm-project. This would require very few changes to the build, but I'm not sure it's a great idea from an organizational standpoint.
I figured this was worth bringing up for discussion since others who have more experience with the build system might have different opinions on the tradeoffs involved! I don't plan on making any of these changes (if we agree they're a good idea) until after the holidays, so there's no rush.