[cfe-dev] using libclang to obtain a decorated AST

miryam.gsm miryam.gsm at gmail.com
Mon Nov 11 09:29:18 PST 2013


Hi,

I'm using libclang to parse C and C++ code and I have a few questions.

Our goal is to obtain a decorated AST (with positions for each element, like
where each method or function starts and ends and so on).

We use clang_parseTranslationUnit. In the API docu we see there is a
"-fsyntax-only" flag that is enabled by default. As far as I understand it
is able to skip the compilation process while still getting the structure.
The problem is that even with this flag it is still doing some sort of
unwanted processing.

/Example 1:/

#pragma clang __debug crash

It is crashing the program but I'd like to get the text of the pragma
instead of a crash. Is it possible?

/Example 2:/

#include <string.h>
#include "mylib.h"

void tsb_init(struct tsb *tsb)
{
  memset(tsb, 0, sizeof(tsb));
}

It is telling that it needs to know the size of the structure which is again
an unwanted behavior for my goals.

Help will be welcome,
Míryam



--
View this message in context: http://clang-developers.42468.n3.nabble.com/using-libclang-to-obtain-a-decorated-AST-tp4035866.html
Sent from the Clang Developers mailing list archive at Nabble.com.




More information about the cfe-dev mailing list