0

I'm analyzing some large C++ projects. The only functionality I really need is finding function calls.

For this I'm using cscope right now, but I discovered one big problem - it seems, that cscope is not able to find methods, e.g. object.function().

So, is it possible to change somehow the settings of cscope? Or, if it's not possible to parse C++ in a realiable way with cscope, could you, please, recommend some other parser, which is "better-equipped"?


I'm using cscope as simply as possible, like this:

cscope -k -L3importantFunc path_to_some_file

I'm not creating the database separately, I think it should be sufficient this way for one specific file.


I've already tried Clang, but it wasn't much better, since it isn't possible to look for functions enclosed in conditional-compilation blocks.

Eenoku
  • 2,741
  • 4
  • 32
  • 64
  • https://github.com/Andersbakken/rtags – Nathaniel Johnson Mar 30 '16 at 15:15
  • 2
    As a wild guess, could the issue be that CScope is for parsing the C language and not C++? – Thomas Matthews Mar 30 '16 at 15:28
  • If you run the preprocessor over the source code before parsing it, you don't have an preprocessor conditional blocks to worry about. Do you want to find function calls inside disabled pp conditional blocks? What if the conditional block is wrapped around the function header line? What if it is wrapped around parts of the argument list? – Ira Baxter Mar 30 '16 at 16:26
  • The CScope web page clearly says it is for "C". http://cscope.sourceforge.net/ – Ira Baxter Mar 30 '16 at 16:28

1 Answers1

0

I recommend loading the project in (free community versions) Visual Studio 2013/2015. It's got so much better navigation/source-browsing. It's quite fast in building & indexing the source code.

https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/

And Wan
  • 314
  • 1
  • 3
  • 12
  • Does that work for GCC/Clang compatible code? I don't think so. [What dialect of C++ does OP have?] It also isn't clear that OP wants to *navigate* the code so much as to make a list. OP should tell us. – Ira Baxter Mar 30 '16 at 16:23
  • gcc? as long as it's standard C/C++ syntax then it'll be able to parse it all. – And Wan Mar 30 '16 at 16:34
  • Nobody I know writes "standard" C/C++ syntax. Somehow something specific to dialect always creeps in somewhere. – Ira Baxter Mar 30 '16 at 19:07
  • I meant just normal C/C++. http://www.theregister.co.uk/2015/10/21/microsoft_promises_clang_for_windows_in_november_visual_c_update/ I heard Visual Studio 2015 will have platform toolset to let us compile for linux? https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/ – And Wan Mar 31 '16 at 09:17
  • a) My point is that no real program contains what you call "just normal C/C++". So if you try to put a non MS C++ program into MSVS, it won't compile. b) Don't confuse compiling MSVS C++ in a Linux-compatible form, with compiling typical Linux C/C++ source code into a Linux-compatible form. – Ira Baxter Mar 31 '16 at 10:55
  • no no no. we are not compiling GNU/Clang C++ files in MSVC, ofcourse not. What I meant was that MSVC (Visual Studio 2013/15) will parse the files and generate a browsable source browser/database. You can press F12 to "go to definition" (or declaration) You can: - find usages - view caller graph/hierarchy - navigate to and more You said you wanted a parser... like if you typed an object, it will code-complete the object's properties/members, etc. This is what MSVS – And Wan Mar 31 '16 at 12:06
  • I use Visual Studio 2013/15 just for source browsing ... but I can only build the files on another compiler. Not sure if you can easily import/read the Clang/gnu projects into Visual Studio.. but am sure there's converters... or just create a new Visual Studio project and add all files in. (again, we are not wanting to compile/build the project... just load it to browse, navigate, etc.) – And Wan Mar 31 '16 at 12:13