[cfe-dev] get calls to methods/functions from a source code extent, with libclang.

Juan Jose Lopez Villarejo jj.lopezvillarejo at cern.ch
Fri Oct 4 02:45:36 PDT 2013




Hello,

These are two sample lines of C++ code:

helSum[0] = antUsrPtr->antennaFunction(y12ant,y23ant,mu1ant,mu2ant,mu3ant, //$
        9,9,9,9,9);

The first line has a special-format comment '//$' that indicates to me that in that code line there is a relevant call:  antennaFunction( , , , , , , , , ...). I want to pick it up usign libclang (the node / cursor of that precise call). This is the task!

======
I have the information on the extent of the source code where my call is being done:
(line, start_column) --> (line, end_column)
In the example, start_column corresponds to the starting 'h' and end_column corresponds to the ending ','

I know that I can get a Cursor from a given location in libclang with
clang_getCursor(tu, location)
I am actually using the python bindings (so there is an extra point if you can reply in the pythonic language :-)

Is that cursor a good starting point? What algorithm would you use next to identify the call? parent nodes? childs? siblings?

======

Thank you for reading,

Juan J. Lopez-Villarejo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131004/16bcd043/attachment.html>


More information about the cfe-dev mailing list