Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] AST for a C++ project

Hi Simos

An AST represents a compilation unit in C++. Therefore, you cannot get an AST for a whole project. However, in CDT you can get an AST for every file instead of only for source files (which usually represent a compilation unit), i.e. for header files as well. An AST can contain the whole compilation unit including all files added by include directives. It depends on how (what flags) the TU is parsed. The static analysis in CDT provides links for between the names used in different translation units in the index though. Bindings group names that represent the same element in the source code semantically. For every project you can get that index and resolve the names on inter translation unit level.

In short: The answer to your question is Yes and no, you need to navigate the TUs yourself if you want to get ASTs for other compilation units but not if you just care about any declarations included in your compilation unit by include directives.

I hope this helps!
Regards
Thomas

-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of sim0s
Sent: Donnerstag, 1. Dezember 2016 11:52
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] AST for a C++ project

Hi,

The ITranslationUnit and IASTTranslationUnit interfaces represent the translation unit and AST of a single C/C++ source file, respectively.

Is there any way to get the AST of an entire C++ project or do I need to start from the AST of the main file and navigate through the include directives?


Thanks,
Simos



--
View this message in context: http://eclipse.1072660.n5.nabble.com/AST-for-a-C-project-tp186484.html
Sent from the Eclipse CDT - Development mailing list archive at Nabble.com.
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top