[cfe-commits] [PATCH] ClangPlugin tutorial

Manuel Klimek klimek at google.com
Mon May 14 09:43:39 PDT 2012


On Mon, May 14, 2012 at 6:25 PM, Hans Wennborg <hans at chromium.org> wrote:

> On Mon, May 14, 2012 at 4:16 PM, Manuel Klimek <klimek at google.com> wrote:
> > Find a proposal for a short ClangPlugin tutorial attached.
>
> Nice! Some nits inline:
>
> > <!--
> ======================================================================= -->
> > <h2 id="pluginactions">Writing a PluginASTAction</h2>
> > <!--
> ======================================================================= -->
> >
> > <p>The main difference when writing PluginASTActions is that you can
> handle
>
> Main difference compared to what?
> Maybe make PluginASTAction a link to the doxygen? In fact, the more
> links to the doxygen, the better :)
>

Changed the sentence. I'm planning to add the doxygen links for all
documentation later. I want to get content in first, and iterate on it.

> <!--
> ======================================================================= -->
> > <h2 id="registerplugin">Registering a plugin</h2>
> > <!--
> ======================================================================= -->
> >
> > <p>A plugin is loaded as dynamic library at runtime by the compiler. To
> register
>
> As *a* dynamic library?
>

Changed to  "from a dynamic library".


> > a plugin in a library, use FrontendPluginRegistry::Add:</p>
> > <pre>
> >   static FrontendPluginRegistry::Add<MyPlugin> X("my-plugin-name", "my
> plugin description");
>
> The < and > around MyPlugin need to be escaped.
>

Escaped the <. (> doesn't need to be escaped, right?)


> > <!--
> ======================================================================= -->
> > <h2 id="example">Putting it all together</h2>
> > <!--
> ======================================================================= -->
> >
> > <p>Let's look at an example plugin that prints top-level function names.
> > This example is also checked into the clang repository; please also take
> a look
> > at the latest <a href="
> http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp?revision=155629&view=markup">checked
> in version of PrintFunctionNames.cpp</a>.</p>
>
> Remove the "revision=..." part from the URL?
>

Done.


> > <!--
> ======================================================================= -->
> > <h2 id="running">Running the plugin</h2>
> > <!--
> ======================================================================= -->
> >
> > <p>To run a plugin the dynamic library containing the plugin registry
> must be
>
> I'd put a comma after "To run a plugin".
>

Done.


> > loaded via the -load command line option. This will load all plugins
> that are
> > registered, and you can select the plugins to run by specifying the
> -plugin
> > option. Additional parameters for the plugins can be passed with
> -plugin-arg-<plugin-name>.</p>
> >
> > <p>Note that those options must be reach clang's cc1 process. There are
> two
>
> "must be reach"
>

Done.


> > <p>Also see the print-function-name plugin example's
> > <a href="
> http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/README.txt?revision=146845&view=markup
> ">README</a></p>
>
> Again, the URL should probably point to the HEAD revision?
>

Done.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120514/453fa1c9/attachment.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120514/453fa1c9/attachment-0001.html>


More information about the cfe-commits mailing list