Adding a Command-Line Option to Clang

Dear All,

I'm trying to add a command line option to Clang/Clang++ that will tell it to run some additional LLVM passes that I've written. From what I've read from the source code, it looks like I have to add an option to both clang (the frontend driver) and CC1 (the actual compiler that performs optimization on the LLVM IR) and somehow get the frontend driver to propagate the command-line option to CC1.

Is my above conclusion correct, and if so, how do I most easily propagate the command-line option from the front end to the cc1 compiler?

Thanks in advance,

-- John T.

Yes, your conclusion is correct. The easiest way to figure out how to add a new option is to pick an existing option that gets passed down to the -cc1 level (using -### to show the -cc1 command line associated with a given clang command line), and find the places in the source where that option shows up.

  - Doug