Passing arguments to a custom clang pass

Hi all,

I am writing a source to source translator for C using clang. I want
to pass extra arguments to my source to source translator.
What are the steps I need to follow to pass extra arguments to the pass?
I have added an option in Options.td. How does my source to source
translator check whether the option is specified.
I thought it is not necessary to define an option in CC1Option.td and
a FrontEndAction as this argument is just passed to my pass.

It will helpful if someone can point me to an existing example in
Clang or describe the steps needed.

Thanks,
Santosh

Hi,

all but the last 4 files in this changelist show how to plumb a
parameter from the driver though to cc1
http://codereview.appspot.com/2826041/ . It might be easier to have a
self-contained binary for your rewriter instead of putting your pass
into clang proper – this will look something like
https://github.com/nico/clangtut/blob/master/tut_rewrite.cpp , but I
haven't figured out how to deal with flags parsing best (currently,
this binary only accepts cc1 options, not all driver options, which is
a bit of a bummer.)

Nico

Thanks, thats helpful.

Also, I want to pass an extra argument to my pass as shown below.
clang -my_rewriter -my_rewriter_option foo.c

I think I don't need to do most of the modifications you suggested for
-my_rewriter_option and those are required only for -my_rewriter.

Any suggestions, Am I wrong?

Thanks,
Santosh