[cfe-dev] Loading plugins into libclang

Kevin Funk via cfe-dev cfe-dev at lists.llvm.org
Tue Mar 1 07:37:47 PST 2016

On Tuesday, March 01, 2016 02:16:52 PM Benjamin Kramer via cfe-dev wrote:
> Hi everyone,
> in my quest to get clang-tidy integrated into your favorite editor
> (via ycm) I'm hitting one major roadblock. I'm piggybacking on the
> existing plugin mechanism which gives me both a way to add extra
> Actions to the parse process and hand flags to the plugin for
> configuration. This works well for (most of) clang-tidy as it really
> just emits diagnostics and FixIts.


did you see my patch here?

This makes it possible to load Clang plugins in libclang by simply passing 
additional compiler arguments to libclang's clang_parseTranslation function.

> However, loading a plugin into libclang isn't easily possible because
> there it doesn't export all the clang symbols.

I'm not sure I understand this issue. Could you elaborate?

A Clang plugin is supposed to be linked against all necessary Clang/LLVM 
libraries already, isn't it? So it should be possible to dlopen the plugin 
just fine.


> Putting all the clang
> symbols into the plugin doesn't work either because you'll get
> duplicate command line flag registration and everything. My current
> hack is to statically link clang-tidy into libclang. This works but
> creates an ugly (optional) dependency from libclang into
> clang-tools-extra.
> Is there any other way to extend libclang without actually modifying
> libclang itself?
> - Ben
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

Kevin Funk | kfunk at kde.org | http://kfunk.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160301/3ffe5700/attachment.sig>

More information about the cfe-dev mailing list