libclang appears to be returning incorrect CXCursor in include statement.

Hello,

I think I may have hit a bug in libclang.

Given a source file, test.cpp, which contains only the following line

#include

If I parse it with clang_parseTranslationUnit() using the CXTranslationUnit_DetailedPreprocessingRecord option I find there is a single CXCursor located in my source file with kind CXCursor_InclusionDirective and extent of offset 0 to offset 17.

If I get a CXCursor via calls to clang_getLocationForOffset() and clang_getCursor() for offsets 0 to 9 I get this cursor. For offsets 10 to 17 I get a CXCursor with kind CXCursor_NoDeclFound.

I would expect to get the CXCursor_InclusionDirective CXCursor for all offsets 0 to 17. Can anyone explain why? (For include statements using “” rather than <> the problem does not seem to occur)

See attached sample code

cursor_test.cc (2.23 KB)