[cfe-dev] clang plugins
Alp Toker
alp at nuanti.com
Wed Jan 29 12:14:19 PST 2014
On 29/01/2014 13:05, Francois de Ferriere wrote:
> Hi,
>
> I am using clang as a front-end to llvm to generate code for a
> target processor.
> I would like to use the clang plugin mechanism to pass some
> information to the compiler during the front-end pass, and then
> continue the flow down to the code generation.
>
> As I saw in several examples, a plugin must derive from the class
> "PluginASTAction", and the function CreateASTConsumer has to be
> defined to produce a consumer. However, this consumer replaces the
> consumer that the front-end uses to call the backend, thus canceling
> the code generation when a plugin is used.
Hi Francois,
It's unfortunate but frontend actions aren't chainable at the moment.
Adding support for such a feature would benefit not only plugins but
also the integrated pipeline itself.
However there's not much active work in the area these days -- it's not
a technical limitation but purely class hierarchy problem with the
*Action facilities that nobody's looked at fixing yet.
>
> I finally managed to do what I want by recreating the
> BackendConsumer in the CreateASTConsumer function of my plugin, but
> this requires duplicating some code from the front-end, and it looks
> like a hack.
>
> Is there a cleaner way to do what I need, or is there another
> mechanism than the plugins to do this ?
The current "can do" solution is to either use Tooling, which provides
some primitives to build custom pipelines, or alternatively to write
your own tiny frontend or driver using simplified wrappers like
BuildCompilation() or createInvocationFromCommandLine().
Alp.
>
>
> Best regards,
>
> - François.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
--
http://www.nuanti.com
the browser experts
More information about the cfe-dev
mailing list