[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Finding function declarations
From: |
s g |
Subject: |
Finding function declarations |
Date: |
Sun, 14 Jan 2007 09:42:02 +0200 |
Hi,
Currently, when running 'gtags' over C source files, it collects function
definitions and references. The references also include the declarations of the
functions (which are normally in header files).
Is there a way to use 'global' to tell the difference between the declaration
and the other references to a function? (or perhaps a way for 'gtags' to make
this separation while collecting the data)
If you're interested to know the background behind the question, here it is:
I'm currently developing a small module that provides sort-of a static
'function call tree' - i.e. once you select a function, it shows you a tree,
whose root is the selected function, and the children of each node in the tree
are the functions calling the function represented by that node. To generate
the call tree, I use global in the following way: (I make some assumptions
along the way)
1. Use 'global -x -r <function-name>' to get the list of references. Here, I'd
like to get all the references to the function but not the declaration of the
function, or alternatively. Currently, this lists also the function declaration
itself. Can I exclude the declaration or tell the difference between a true
reference and a declaration?
2. For each of the references, I use "global -f <file-name>" with the file
containing the reference, and find which function contains the reference line.
Assuming every reference is actually a call to the selected function from
another function, the last function whose definition line is above the
reference is considered to be the caller.
(The resulting tree is more like a 'reference tree' rather than a 'call tree',
but the later is a more common name for this.)
In most cases, the above algorithm works fine and provides me with very useful
information that helps me quickly navigate through the code. The main problem I
have with it is that I cannot tell the difference between a function
declaration and a reference, so it also lists 'false' callers which just happen
to be the tag that's defined above the declaration (returned by 'global -f
<file>').
Thanks,
Shlomy
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Finding function declarations,
s g <=