[cfe-dev] Issues with clang_Cursor_getSpellingNameRange not reporting the correct range

Richard Smith richard at metafoo.co.uk
Tue Sep 23 16:25:39 PDT 2014


On Mon, Aug 4, 2014 at 8:49 AM, Kevin Funk <kfunk at kde.org> wrote:

> Hey,
>
> Context: We're using libclang as our C++ parser backend in KDevelop.
>
> We're having some difficulties in finding the correct range for some
> identifiers using libclang. Example:
>
> % cat test.cpp
> struct Foo
> {
>     void operator++() {}
> };
>
> % c-index-test -cursor-at=test.cpp:3:10 test.cpp
> 3:10 CXXMethod=operator++:3:10 (Definition) Extent=[3:5 - 3:25]
> Spelling=operator++ ([3:10 - 3:18])
> Completion string: {ResultType void}{TypedText operator++}{LeftParen (}
> {RightParen )}
>
> Here, the range is obviously wrong: [3:10 - 3:18] only points to
> 'operator',
> not 'operator++'. This is the fault of clang_Cursor_getSpellingNameRange.
> This happens for a C++ destructor declaration (only '~' is in the range),
> and
> all operator overloads (only 'operator' in the range).
>
> I guess that this is a bug, and not intended, and that
> clang_Cursor_getSpellingNameRange just needs special-casing for C.kind ==
> CXCursor_CXXMethod and friends. Am I right in that assumption and a patch
> would be accepted?


Yes =)

(Sorry if this has already been answered in another thread, I'm going
through my backlog of seemingly-unanswered mail.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140923/3b6f2725/attachment.html>


More information about the cfe-dev mailing list