Search for C ++ code parser to view all signatures

I am looking for a C ++ parser that can extract all functions and methods using its signatures. Is there something like this?

I looked at gccxml, there I had a problem that it cannot use namespaces, and this is not normal if only the header file is present.

+5
source share
4 answers

The Clang compiler obviously has all the possibilities for this, if I correctly remember even the API for accessing the code generated by the parser.

+1
source

The most obvious options are:

  • Ctags
  • Cscope

Just a sample GCC man page:

-fdump-noaddr -fdump-unnumbered -fdump-translation-unit[-n] -fdump-class-hierarchy[-n] -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
           -fdump-statistics -fdump-tree-all -fdump-tree-original[-n] -fdump-tree-optimized[-n] -fdump-tree-cfg -fdump-tree-vcg -fdump-tree-alias -fdump-tree-ch -fdump-tree-ssa[-n] -fdump-tree-pre[-n] -fdump-tree-ccp[-n] -fdump-tree-dce[-n]
           -fdump-tree-gimple[-raw] -fdump-tree-mudflap[-n] -fdump-tree-dom[-n] -fdump-tree-dse[-n] -fdump-tree-phiopt[-n] -fdump-tree-forwprop[-n] -fdump-tree-copyrename[-n] -fdump-tree-nrv -fdump-tree-vect -fdump-tree-sink -fdump-tree-sra[-n]
           -fdump-tree-fre[-n] -fdump-tree-vrp

gccxml backend

+4

-dump abi-compliance-checker ,

abi-compliance-checker -lib NAME -dump DESC.xml -headers-only -stdout > api.dump

XML- (DESC.xml) :

<version>
    VERSION
</version>

<headers>
    /path(s)/to/headers/
</headers>

:

  • GCC -fdump-translation-unit -I... , XML-;
  • AST, GCC;
  • Data:: Dumper XML ( -xml).

int BZ2_bzRead ( int *bzerror, BZFILE *b, void *buf, int len ) bzlib.h :

'228' => {
   'Header' => 'bzlib.h',
   'Line' => '160',
   'Param' => {
                '0' => {
                         'algn' => '4',
                         'name' => 'bzerror',
                         'type' => '30'
                       },
                '1' => {
                         'algn' => '4',
                         'name' => 'b',
                         'type' => '16'
                       },
                '2' => {
                         'algn' => '4',
                         'name' => 'buf',
                         'type' => '68'
                       },
                '3' => {
                         'algn' => '4',
                         'name' => 'len',
                         'type' => '41'
                       }
              },
   'Return' => '41',
   'ShortName' => 'BZ2_bzRead'
 },
+1
source

you can try compiling your code with the flag save-tempsset to gcc, this makes gcc output files with macro scans and full signatures. These are .ii files.

0
source

All Articles