473,326 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Extracting all functions from C++ source code

I'm trying to find a way to extract all the function definitions AND
function uses from thousands of C++ files. For example, if foo.cpp
contains:

int func(char b)
{
return 0;

}

func('d'); func('e');
print("bar");

Then I want to get something that tells me "int func(char b) is on
line 1, pos 0 ; func(char) is on line 5, pos 0 ; func(char) is on
line
5, pos 11 ; print(char*) is on line 6, pos 0"

Is there any tool that can do this? I've looked into ctags, but it can
only get the function definitions. I've also tried g++ to see if there
are command line options for this but it doesn't look like it. I've
also tried rolling me own but the amount of grammar that can be used
overwhelmed me.

Thanks in advance!

- Eliss
Jun 27 '08 #1
3 2211
eliss wrote:
I'm trying to find a way to extract all the function definitions AND
function uses from thousands of C++ files. For example, if foo.cpp
contains:

int func(char b)
{
return 0;

}

func('d'); func('e');
print("bar");

Then I want to get something that tells me "int func(char b) is on
line 1, pos 0 ; func(char) is on line 5, pos 0 ; func(char) is on
line
5, pos 11 ; print(char*) is on line 6, pos 0"

Is there any tool that can do this? I've looked into ctags, but it can
only get the function definitions. I've also tried g++ to see if there
are command line options for this but it doesn't look like it. I've
also tried rolling me own but the amount of grammar that can be used
overwhelmed me.
You might want to look into documentation-producing tools, they
usually have pretty decent parsers. See Doxygen or some such.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
On May 9, 5:30*pm, eliss <eliss.carm...@gmail.comwrote:
I'm trying to find a way to extract all the function definitions AND
function uses from thousands of C++ files. For example, if foo.cpp
contains:

int func(char b)
{
* * return 0;

}

func('d'); func('e');
print("bar");

Then I want to get something that tells me "int func(char b) is on
line 1, pos 0 ; func(char) is on line 5, pos 0 ; func(char) is on
line
5, pos 11 ; print(char*) is on line 6, pos 0"

Is there any tool that can do this? I've looked into ctags, but it can
only get the function definitions. I've also tried g++ to see if there
are command line options for this but it doesn't look like it. I've
also tried rolling me own but the amount of grammar that can be used
overwhelmed me.

Thanks in advance!

- Eliss
It isn't just the grammar that's the problem unless
you're OK with sloppy answers. And if you want to do
this reasonably across thousands of files, I can't
imagine that sloppy answers would be helpful.
You also need to handle the preprocessor, command line switches,
include files, include paths the name resolution problem, too.
In short, you need a full parser for your particular
dialect.

Our DMS Software Reengineering Toolkit has a full C++ parser
for a variety of C++ dialects.
It handles all the above issues,
and collects all this name and type information. What you
want could be pretty easily extracted.

See http://www.semanticdesigns.com/Produ...pFrontEnd.html

Ira Baxter, CTO
Semantic Designs
Jun 27 '08 #3
On May 9, 6:30*pm, eliss <eliss.carm...@gmail.comwrote:
I'm trying to find a way to extract all the function definitions AND
function uses from thousands of C++ files. For example, if foo.cpp
contains:

int func(char b)
{
* * return 0;

}

func('d'); func('e');
print("bar");

Then I want to get something that tells me "int func(char b) is on
line 1, pos 0 ; func(char) is on line 5, pos 0 ; func(char) is on
line
5, pos 11 ; print(char*) is on line 6, pos 0"

Is there any tool that can do this? I've looked into ctags, but it can
only get the function definitions. I've also tried g++ to see if there
are command line options for this but it doesn't look like it. I've
also tried rolling me own but the amount of grammar that can be used
overwhelmed me.

Thanks in advance!

- Eliss
doxygen can give you all functions. And I'm pretty sure it can give
you call graphs, but I don't think it can give you line and column
numbers. It's worth checking out.

HTH
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Calvin FONG | last post by:
Dear all, Are there any utility that can be call by python to create self extracting zip file. I'm now using the powerarchiever. But the command line options aren't flexible enough. Basically, I...
1
by: Philippe C. Martin | last post by:
Hi, How would one go about extracting the pickle module from Python (ex: to make a .a or a .dll) ? Thanks Philippe
0
by: Gnaneshwar Babu | last post by:
Hi I am facing a problem with extracting event logs of win32 to a file. Am using the following code to extract eventlogs to file use Win32::EventLog; $handle=Win32::EventLog->new("System",...
1
by: Cognizance | last post by:
Hi gang, I'm an ASP developer by trade, but I've had to create client side scripts with JavaScript many times in the past. Simple things, like validating form elements and such. Now I've been...
2
by: Chris Belcher | last post by:
First some background... The database tracks Action Items assigned to a group of 20 or so managers. Once the assignment is created it is then emailed to each of the managers that are included in...
4
by: Tony Clarke | last post by:
Hi All, I have been trying to extract data from a text file using the fscanf() functions and sscanf() functions. The file is of various characters and integers separated by semicolons, the...
2
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to...
0
by: sgsiaokia | last post by:
I need help in extracting data from another source file using VBA. I have problems copying the extracted data and format into the required data format. And also, how do i delete the row that is not...
2
by: VictorTan | last post by:
Hello. I'm new to this forum. Hope that I don't make mistakes in here but if I do, please correct me if there is. Thanks. I also wanted to ask you guys regarding about the following following...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.