Best strategies

Hello List,

I'm looking at developing a FOSS tool for GNU/Emacs, written in C++, that makes use of clang's powerful features. In particular I'm interested in contextual/semantic aware code-completion and extraction of information (ie. list of methods, attributes, etc). IOW, something similar to what CEDET [0] does, only much faster, reliable and useful.

I've created a simple program that accesses all of a C/C++ source file's symbols using the AST-consumer approach, but I'm not quite sure I'm pursuing the right approach, given the requirements above.

What would be the right approach for:

  * implementing code-completion? Should I be looking at using the clang::CodeComplete* [1] set of classes? If so, how would one go about implementing the CodeCompleteConsumer class?

  * extracting contextual aware information? For instance, extracting the list of methods of an arbitrary class.

  * caching of parsed source file data? For instance, if one is editing file A and it includes B, C and D headers, it would be great if clang could be instructed to only reload/reparse file A and not the others for obvious performance reasons.

Many thanks!

Miguel

[0] http://cedet.sourceforge.net
[1] http://clang.llvm.org/doxygen/classclang_1_1CodeCompleteConsumer.html

Hello Miguel,

libclang is usually used for accomplishing typical IDE tasks. These
is a (generally) stable C interface to Clang. [1, 2] While it is also
possible to use internal Clang interfaces that are more powerful,
these are not stable.

There was a relevant proposal which describes an interesting approach
to provide a new kind of interface for IDE-like tools. [3] There was
almost no discussions on cfe-dev about clangd since then, but it does
not mean that the proposal is inactive -- someone might be working on
that in a branch.

Dmitri

[1] http://clang.llvm.org/doxygen/group__CINDEX.html
[2] http://llvm.org/devmtg/2010-11/ libclang: Thinking Beyond the Compiler
[3] http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022028.html