[cfe-commits] [PATCH] ClangPlugin tutorial

Hans Wennborg hans at chromium.org
Mon May 14 09:25:08 PDT 2012


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 :)


> <!-- ======================================================================= -->
> <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?

> 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.

> <!-- ======================================================================= -->
> <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?

> <!-- ======================================================================= -->
> <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".

> 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"

> <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?


Thanks,
Hans



More information about the cfe-commits mailing list