I need to write simple tool that returns some simple analysis over existing c++ code.

And so I'm looking for C++ parser, that would give me info about at least headers:

  • list of user types,
  • list of functions,
  • list of methods of user types.

For first step that would be enough.

I found perfect tool: gcc-xml, that does this thing, but it fails with C++11 code and younger. Does there exist any solution for that task? I guess it has to, because compilers, supporting C++11, somehow understand code :-)

  • There's no such thing as a "simple" tool when it comes to processing C++ because of its inherent complexity. There are such things as complex tools that can enable apparantly simple tasks.
    – Ira Baxter
    Nov 11, 2014 at 10:52

3 Answers 3


I would recommend doxygen - while the C++11 support does seem to have a few bugs outstanding it should give you a very good start.

  • Free
  • list of types - yes
  • list of functions - yes
  • list of methods of user types - yes


  • UML Diagrams (with the graghviz dot tool).
  • Links to the code
  • Allow you to document your code and generate the final documentation from the code.
  • Custom Parsers for other languages are available.
  • Cross platform - Mac, Linux, Unix & Windows
  • Multiple output formats
  • widely used.
  • Yes, that is great tool, but I doubt it is possible use it here. I can't find C++ API for using it... I guess it is possible to use it as console tool, will look at that.
    – Arkady
    Oct 30, 2014 at 12:06
  • 1
    IIRC the wxPython project phoenix was planning to use doxygen to generate xml for the C++ libraries and then parse that to produce the python interface files. Oct 30, 2014 at 19:02
  • 1
    @Arkady: A C++ API? I don't think the "perfect tool: gcc-xml" has a C++ API, and you didn't list that in your requirements in your question. Are you changing the requirements on the fly?
    – Ira Baxter
    Nov 24, 2014 at 3:47

The gccxml site now states that it has been superseded by CastXML, based on LLVM >= 3.6, which supports C++ 11.


Our DMS Software Reengineering Toolkit with its C++ Front End is likely to be a good candidate for your task.

DMS is designed to be the foundation for custom program analysis and transformation tools. It provides an ecosystem of parsing machinery, tree builders, attribute grammar computations, symbol table management, flow analysis, source-level pattern matches, source-level transformation engines and development tools. One uses DMS by plugging-in parsers (and extended analyzers) for one or more languages of interest. In the case that there is no off-the-shelf parser, DMS provides strong parser generation machinery for building such a parser. (We recently built an Erlang parser [only] as a challenge task in one day).

The C++ front end was built using DMS's support. It handles virtually all (and we are completing) of C++14 in ANSI, GCC and Microsoft flavors. Using DMS, it parses C++ source text using its own full preprocessor, builds precise abstract syntax trees, and accurate symbol tables. It provides control and data flow analysis at the method level. All of this information is available to a DMS user for his custom tool.

If you want to apply source-to-source transformations to the code, DMS provides that capability directly by using the front end to support the pattern description machinery; the transformations can be conditioned on arbitrary facts drawn from the symbol tables or flow analysis machinery. Or you could just generate XML for facts that you want to export using DMS's XML package.

For example, to get a list of user types, one would visit the symbol tables (built in DMS machinery supports a front-end provided visitor) and inspect entries for types. One can do more exotic things; for instance you might navigate to an arbitrary expression tree, and ask the type of the expression.

For OP's question:

  • List of user types: Yes
  • List of functions: Yes
  • List of methods of user types: Yes

DMS and the C++ front end have been used to build a wide variety of C++ tools (also at the website) as well as carrying out massive architectural changes to large C++ codes (see technical papers at website).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.