eclipse-cdt / cdt

Eclipse CDT™ C/C++ Development Tools
http://eclipse.org/cdt
Eclipse Public License 2.0
309 stars 201 forks source link

What are all the languages supported by Eclipse CDT AST Parser. #756

Open VenoVeno opened 7 months ago

VenoVeno commented 7 months ago

Hi, Eclipse CDT parsed source code by constructing AST. What are all the languages supported like C, C++, Clang.

Thanks, Veno.

MarkZ3 commented 6 months ago

C and C++. For c++, up to C++17 partially. The parser can detect some compiler variations in order to support different "built-in" functions, etc. The main compiler variations supported are GCC and Clang, with some basic support for MSVC and ClangCl. One thing to note is that the parser does not distinguish c++ version. For example, if a new C++17 specification/behavior is implemented that is not simultaneously compatible with parsing c++14 code, the parser will only handle the c++17 way.

VenoVeno commented 6 months ago

The main compiler variations supported are GCC and Clang.

Does it support Clang? But i could see only parser available for GCC and GPP standards?

some basic support for MSVC and ClangCl

Do we have to set any additional flags to recognise and parse for MSVC and ClangCl?

MarkZ3 commented 6 months ago

The GPP parser supports GCC, Clang, MSVC, ClangCl variants by checking the macros __GNUC__, __GNUC_MINOR__, __clang__, _MSC_VER. The GPP parser could be split into multiple parsers to isolate each but it has not been done.

VenoVeno commented 6 months ago

Means, currently the parser couldn't recognise different version of __GNUC__ and __GNUC_MINOR__?

MarkZ3 commented 6 months ago

The parser can recognize different versions of __GNUC__ and __GNUC_MINOR__ and adjust some things like which built-in functions can be parsed. What I meant is that you might run into some cases that the parser will be more permissive than it should because for both Clang (__clang__) and MSVC (_MSC_VER) compiler support, it uses much of the same parser code under the hood. So for example, when parsing in MSVC mode, it might wrongly accept GCC-specific syntax. Sorry for being unclear.