[cfe-dev] Range for CXFile

Jacob Carlborg doob at me.com
Fri Jan 9 09:18:47 PST 2015


On 2015-01-09 16:48, Milian Wolff wrote:
> Hello all,
>
> in the clang-c API, one can find the range for the top-level file of a
> translation unit via
>
> auto cursor = clang_getTranslationUnitCursor(unit);
> auto range = clang_getCursorExtent(cursor);
>
> Cool. But, now, I have a CXFile representing a file that was included at some
> point within the TU. How do I get its range?
>
> Or maybe there is a different way: I want to access all comments in any CXFile
> encountered in a translation unit. Currently, we tokenize the top-level
> document and then look for the CXToken_Comment tokens and get their spelling
> and range.
>
> I cannot find a way to do the same for included files. Help would be
> appreciated.

There's a comment introspection API that might be of help: 
http://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html

-- 
/Jacob Carlborg




More information about the cfe-dev mailing list