[PATCH] D45835: Add new driver mode for dumping compiler options
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 19 12:20:04 PDT 2018
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
Herald added a subscriber: cryptoad.
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).
https://reviews.llvm.org/D45835
Files:
include/clang/Basic/Features.def
include/clang/Driver/CC1Options.td
include/clang/Frontend/FrontendActions.h
include/clang/Frontend/FrontendOptions.h
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/FrontendActions.cpp
lib/FrontendTool/ExecuteCompilerInvocation.cpp
lib/Lex/PPMacroExpansion.cpp
test/Frontend/compiler-options-dump.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45835.143144.patch
Type: text/x-patch
Size: 32982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180419/f39fae10/attachment-0001.bin>
More information about the cfe-commits
mailing list