Open Source Options for C ++

I am looking for options for an open source C ++ compiler (source parser / analyzer) that I could customize for my requirements. I don't need an implementation at the back end, as this will help me find a fast and relatively error-free C ++ interface that supports most of the standard functions. Any suggestions?

[I made google, clang seems to be an option, but I would have preferred feedback before starting with it.]

Arpan

+4
source share
5 answers

Clang and GCC are two main options. GCC is very complex (or so I heard), and Clang is very promising, but immature.

GCC-XML uses the GCC front-end to highlight XML source descriptions. The output of GCC-XML is not a complete abstract source tree (it does not contain a function body), but it will be much easier to work with than with GCC itself. (The latest release on the GCC-XML page is terribly outdated; if you don't want to bother tracking its CVS yourself, you can try downloading tarball, for example, from the Debian gccxml page .)

Depending on your exact requirements, other options may work:

  • CINT is a C / C ++ interpreter. I was told that it is not very strict according to C ++ standards.
  • ROSE can use the source of C and C ++ and allows you to perform various conversions in it. The C and C ++ ROSE interface is licensed from EDG, so it is not open source, but it is freely distributed.
  • Projects such as Doxygen and SWIG include their own limited C ++ parsers. Although they are intended only to extract documentation and create interfaces, they may suit your needs.

Edit: For further reading, see "C ++ Parsing," by Andrew Birkett.

+6
source

Have you watched LLVM clang ?

+1
source

For one of the refactoring attempts I made, we used Elsa:

http://scottmcpeak.com/elkhound/sources/elsa/

with mixed results. Some parts of our code were too complex or non-standard for Elsa's solution, and they had to be preprocessed for refactoring.

You can use this with Oink:

http://danielwilkerson.com/oink/

if the initial analysis is what you are tuned for.

Hope this helps!

+1
source

The Digital Mars C ++ compiler is not open source, but the source code is available for purchase (see http://www.digitalmars.com/shop.html ) and you can configure it.

+1
source

CLang is probably the way to go these days for a complete solution, but if you are looking for something standalone that you can understand, then check out this project on github:

https://github.com/robertoraggi/cplusplus

A small command line utility is included in the package for resetting AST, characters, and IR code.

This is the C ++ interface used in QTCreator . It does a decent job analyzing the most modern C ++ code, and although the cplusplus interface has not been updated for some time, QTCreator is very actively used and developed. This code has quite a lot of mileage on it.

0
source

Source: https://habr.com/ru/post/1312575/


All Articles