Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending homework testing platform to include code analysis (C/C++)

I'm maintaining/developing a platform for homework testing. It's mostly automatic. What I need to add now is code analysis. I need to check the code for specific constructs.

For example:

Does the file main.cpp contain a class named user with a const method get_name()?

Is there some tool out there that would allow me to do such stuff (ideal would be something that can be scripted). Linux only.

like image 323
Šimon Tóth Avatar asked Sep 14 '10 15:09

Šimon Tóth


2 Answers

One possibility might be to run the code through GCC and use the GCC-XML extension to produce XML descriptions of the program's internal structure. You could then use your favourite XML library to parse the document, or apply an XSLT to it if all you need to do is display it as HTML or whatever.

like image 179
Phil Booth Avatar answered Oct 01 '22 21:10

Phil Booth


You could probably hack together something that used the GCC-XML framework without too much difficulty.

like image 25
Omnifarious Avatar answered Oct 01 '22 22:10

Omnifarious