There are situations where an out-of-tree user may need to know information about what compiler options are used and what features/extensions may be available for a given invocation of the compiler. For instance, a tool may want to interrogate Clang so that it can emulate settings specific to the compilation without having to reverse engineer the Clang command line options or keep a custom mapping of language modes to features or extensions available in that mode.
This patch adds the ability to dump compiler option-related information to a JSON file. Specifically, it dumps the language options, codegen options, diagnostic options, and features/extensions lists -- however, this output could be extended to other information should it be useful (like target options, available attributes, etc). In order to support features and extensions, I moved them into a .def file so that we could build the various lists we care about from them without a significant increase in maintenance burden.
I selected JSON as the output because the data being output is serialized (as opposed to something human-writable like a config file), it's what our tool already groks, and it was simple to output to. If/when we get a JSON support library, I expect this code to be converted over to use that.
Our expectation is that the list of features and extensions will only ever be added to (because these are user-facing and removing one could break code), but that the other options may be added to, renamed, or removed between major releases (as opposed to point releases).