[cfe-dev] Adding a command-line option that takes a string?

Daniel Dunbar daniel at zuster.org
Mon Aug 17 23:09:14 PDT 2009


Hi David,

Can you give me a hint where you are stuck?

The basic steps:
1. Add the option, which is presumably a Joined option.

2. Add a clang-cc option this should map to (perhaps with the same name).

3. Add a translation so that clang will forward this to clang-cc
(around Tools.cpp:485). Something like:
--
  if (Arg *A = Args.getLastArg(options::OPT_fconstant_string_class_EQ)) {
    CmdArgs.push_back("-fconstant-string-class");
    CmdArgs.push_back(A->getValue(Args));
  }
--

4. Do whatever you want with the option inside clang-cc (stick it in
LanguageOptions, generally, and go from there).

See the handling of OPT_ftemplate_depth_, for example.

 - Daniel

On Sun, Aug 16, 2009 at 9:38 AM, David Chisnall<csdavec at swansea.ac.uk> wrote:
> Hi,
>
> I'm looking at adding the -fconstant-string-class= command-line
> argument (I hoped to avoid it, but apparently lots of things expect it
> to work).  I've added simple flags before, but I am having trouble
> working out how to add an option to the driver that accepts a string
> that can be retrieved by the back end.  Can someone give me some hints?
>
> David
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list