This patch introduces additional infrastructure necessary to accommodate DiagnosticOptions.
DiagnosticOptions are unique in that they are parsed by the same function in cc1 AND in the Clang driver. The call to the parsing function from the driver occurs early on in the compilation process, where no proper DiagnosticEngine exists, because the diagnostic options (passed through command line) are not known yet.
To preserve the current behavior, we need to be able to selectively parse:
- all options (for -cc1),
- only diagnostic options (for driver).
This patch achieves that in the following way:
- new MacroPrefix field is added to the Option TableGen class,
- new IsDiag TableGen mixin sets MacroPrefix to "DIAG_",
- TableGen backend serializes option records into a macro with the prefix,
- CompilerInvocation parse/generate methods define the [DIAG_]OPTION_WITH_MARSHALLING macros to handle diagnostic options separately.
There was one thing in the original patch that was a bit of sanity check for whether IsDiag was added to the wrong option: the DiagnosticOpts-> part of the keypath was implicit. What do you think of adding that back? That would make the keypath here ShowCarets.
It highlights that diagnostics are special (since DiagnosticOpts is never mentioned in the file, and any mistakes could be found with a grep).