[cfe-dev] Regarding clang-c and comments...

Doug douglas.linder at gmail.com
Mon Oct 31 18:41:28 PDT 2011


*cough* Alternatively, is there a different list for questions like this?

On Thu, Oct 27, 2011 at 11:59 AM, Doug <douglas.linder at gmail.com> wrote:

> Hi there,
>
> I'm writing a very simple c parser (dumps formatted symbols, something
> similar to ctags but actually working) using clang-c, which is working
> well, but I'm hoping to add some support for source comments in the code.
>
> At the moment I'm using the clang-c subset for this, but there doesn't
> seem to be any api for accessing comments; specifically CXCursorKind
> doesn't seem to have a type for 'comment', and I've ended up doing
> something similar to:
>
> for each cursor
>   get cursor info
>   save info (specifically, offset, filename, display name)
>
> for each saved symbol:
>   find the closest previous symbol
>   walk backwards through the file from position of symbol -> position of
> previous symbol looking for closest comment
>
> This is quite annoying to do, and has a few problems (example: symbols
> with no filename, unsaved files, large projects means loading every symbol
> into memory).
>
> Is there a to get comments as elements through to the visitor function?
>
> If no in clang-c, then perhaps in the full clang api?
>
> Finally, as a slightly better alternative, is there a way to query a
> cursor to get the previous lexical cursor? At the very least this would
> save me having to save the entire set of data in memory first..
>
> Help much appreciated!
>
> cheers,
> Doug.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111101/a7ade65e/attachment.html>


More information about the cfe-dev mailing list