[cfe-dev] How to add command-line arguments outside of Options.td?
Kim Gräsman
kim.grasman at gmail.com
Sat Oct 4 01:12:22 PDT 2014
Hello Mikael,
On Fri, Oct 3, 2014 at 5:41 AM, Mikael Persson
<mikael.s.persson at gmail.com> wrote:
>
> I'm working on the Templight template profiler / debugger. I'm trying to
> remove it from the main-line Clang code and make it a tool. So far, it looks
> like that will be fairly easy to do, except for one thing.
>
> The problem is that I need to invoke the full-blown Clang compiler, with all
> of its options (driver / frontend options), otherwise the profile readings
> will not be representative of the real compilation runs. All those options,
> it appears, are gathered up in this single global file "Driver/Options.td"
> (where the templight options have been placed for the moment). I don't want
> to pollute Options.td with the additional options I need for templight. I've
> hit a snag where I cannot find a reasonable way to integrate my additional
> options.
Not that it will immediately help with your question, but I wonder if
your tool should be a Clang Plugin instead?
See http://clang.llvm.org/docs/ClangPlugins.html.
I guess that means you can't package it separately, though...
In the IWYU tool, we catch the command-line before Clang sees it,
strips off any args that belong to us, and forward the rest.
Gritty code here:
https://code.google.com/p/include-what-you-use/source/browse/trunk/iwyu_globals.cc#111
- Kim
More information about the cfe-dev
mailing list