Writing new Clang plugins (Re: replacing OUString::valueOf(static_cast<sal_Int32>) ??)

Jean-Noël Rouvignac jn.rouvignac at gmail.com
Fri Jan 11 06:45:04 PST 2013


2013/1/11 Lubos Lunak <l.lunak at suse.cz>

> On Friday 11 of January 2013, Jean-Noël Rouvignac wrote:
> > 2013/1/10 Lubos Lunak <l.lunak at suse.cz>
> >
> > >  > > Unless all you want to convert is only places which do the
> explicit
> > > > >
> > > > > cast, this will need a (fairly simple) Clang plugin.
> > > >
> > > > Sure, if you feel like writing one.
> > >
> > >  Actually, I'd prefer to write a howto about that first, whenever I get
> > > to doing that, so that I don't have to write every single plugin. Such
> a
> > > plugin
> > > will be still much simpler than a regexp or any other way.
> >
> > Please do, I would be interested in that.
> > Maybe you already have some URLs to share on this subject?
>
> That API is documented at http://clang.llvm.org/doxygen/ , but I
> understand
> that throwing that at somebody unfamiliar with it must be scaring (hint:
> the
> most commonly needed is the class hiearchy starting from clang::Stmt, as
> those are classes representing the program in the AST). I myself actually
> find it easier to read directly doxygen docs in the includes, mostly
> Decl*.h
> Expr*.h Stmt*.h in include/clang/AST/ . The API is however rather intuitive
> and straightforward, once one gets into it. And finding out how a
> particular
> piece of code is represented in the AST is a matter of compiling it
> with 'clang++ -Xclang -ast-dump' and matching the output to Clang classes.
>
>  If you want to give it a try now, look under compilerplugins/ in the LO
> sources.


I don't find this more intimidating than Eclipse's documentation for
"org.eclipse.cdt.core.dom.ast.cpp" (Eclipse CDT's AST parser for C++) or
"org.eclipse.jdt.core.dom" (Eclipse JDT's AST parser for Java). Only clang
doc is harder to go through but it has nice graphics :).

I might take a look at this.
Thanks for sharing this info.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20130111/5769703e/attachment.html>


More information about the LibreOffice mailing list