[cfe-dev] libclang - how to find an implementation using CXCursor
Eran Ifrah
eran.ifrah at gmail.com
Fri May 11 04:22:10 PDT 2012
Hi List,
I have implemented the functionality of 'Goto Declaration' using the
following pseudo code:
First, we obtain the cursor using 'location' and TU:
------------
CXTranslationUnit tu = cache.GetTU()
CXCursor c = clang_getCursor(tu, location)
if(clang_isInvalid(c.kind)))
return
if(is_reference_cursor(c))
c = clang_getCursorReferenced(c);
clang_getCursorLocation(c)
------------
This works like a charm, however, with my old code completion engine (an
in-house flex/yacc grammar) I was able to distinguish between the
'declaration' and the 'implementation' of a function and offer it to the
user.
For example:
a.h
------
class A {
void foo(); // declaration
};
a.cpp
--------
// Implementation
void A::foo() {}
I was not able to implement this functionality using libclang
It seems that the cursor is always pointing to the 'Declaration' of a
function
Is there something that I am missing that will give me the location of the
implementation?
Any advise?
--
Eran Ifrah
Author of the cross platform, open source C++ IDE: http://www.codelite.org
YTubePlayer http://www.ytubeplayer.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120511/dd7f10e8/attachment.html>
More information about the cfe-dev
mailing list