[cfe-dev] source code database

Manuel Klimek klimek at google.com
Wed Feb 29 08:26:28 PST 2012

On Wed, Feb 29, 2012 at 3:13 AM, Bruce Stephens
<bruce.r.stephens at gmail.com> wrote:
> Nico Weber <thakis-F7+t8E8rja9g9hUCZPvPmw at public.gmane.org> writes:
>> clang should support much of what you ask for.
>> DXR ( https://wiki.mozilla.org/DXR ) is an existing attempt to use
>> clang to build a program database. https://github.com/nico/complete is
>> some old hack from me that does the same in worse - but since there's
>> a lot less code, maybe it's easier for a first look (relevant file:
>> https://github.com/nico/complete/blob/master/server/complete_plugin.cc).
> dxr-index.cpp is ~600 lines, so it's not enormous. It seems non-trivial
> to get everything set up. Easy enough to build, though.
> (Interestingly it's a clang plugin rather than a standalone using
> libclang. (As is include-what-you-use.)
> I wonder if that's a trend: that while it seems attractive to build a
> standalone against a library with a reasonably stable and documented C
> API, in practice it's easier to build a plugin because that lets you use
> a richer set of classes and (likely more interesting?) makes it easier
> to plug in to existing build systems, so it'll be easier for people to
> use in their own projects.)

Currently running as a plugin is the easiest way to run a tool over code.
I have a patch out under review which makes it simpler to write a
standalone tool; whether you want a standalone tool or a plugin
depends on the use cases you have - the nice thing about standlone
tools is that they're orthogonal to the build system, and you can run
them over files that normally would not be rebuilt selectively.
For CMake there's already support to output the compile commands in a
parseable form so that standalone tools can run over arbitrary files.

See http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/Tooling/Tooling.h?view=markup
for more info.


More information about the cfe-dev mailing list