Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Visiting IASTNodes inside preprocessor blocks

Hi,
In general, there is not AST for inactive code branches. There is limited support for creating AST for  declarations in inactive code branches, see ITranslationUnit. AST_PARSE_INACTIVE_CODE.
Markus.

-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Otávio Pontes
Sent: Donnerstag, 12. Mai 2011 20:44
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] Visiting IASTNodes inside preprocessor blocks
Importance: Low

Hi folks,
I'm writting a plugin based in cdt/codan and i need to visit all IASTNodes in a C code. To do that I'm using the IASTTranslationUnit.accept method and it is working fine. But I also need to visit nodes inside a block excluded by the preprocessor (#ifdef,
#ifndef) and the IASTTranslationUnit.accept is not doing this. In the example bellow bar() is visited, but foo() is not.

void main() {
     #ifdef VAR
         foo();
     #endif
     bar();
}

Is there a way to get the nodes from code inside this block? It seems to me that codan checkers do not work inside this block too, so looking at the code won't help me. I realize that I can get the preprocessor statements using IASTTranslationUnit.getAllPreprocessorStatements, but I cannot get the content.

Thanks,
Otavio Pontes
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top