sequence of visiting declarations/statements in RecursiveASTVisitor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

sequence of visiting declarations/statements in RecursiveASTVisitor

variadic.template
Hi,

I try to transform some objective-c-code to Java. For this,
i subclassed the RecursiveASTVisitor, visit the decls/
statements and transform them.
To see the structure of the code as clang it sees, i first
print every declaration and statement with their
corresponding sourcerange. Thus, i can see that a "normal"
function-declaration (FunctionDecl), that is located somewhere
between the objective-c code, will be not visited until all
the other objective-c-method-declarations (ObjCMethodDecl)
have been visited - effectively it seems as clang jumps back
inside the sourcecode.
Is this the wanted behavior and when yes, why?



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: sequence of visiting declarations/statements in RecursiveASTVisitor

Douglas Gregor

On Jan 5, 2011, at 4:22 AM, variadic.template wrote:

Hi,

I try to transform some objective-c-code to Java. For this,
i subclassed the RecursiveASTVisitor, visit the decls/
statements and transform them.
To see the structure of the code as clang it sees, i first
print every declaration and statement with their
corresponding sourcerange. Thus, i can see that a "normal"
function-declaration (FunctionDecl), that is located somewhere
between the objective-c code, will be not visited until all
the other objective-c-method-declarations (ObjCMethodDecl)
have been visited - effectively it seems as clang jumps back
inside the sourcecode.
Is this the wanted behavior and when yes, why?

This is a bug. Objective-C's ASTs are still a bit messy w.r.t. the ordering of declarations. libclang has a few hacks to work around the issues, but in the long term, we want to fix the ASTs themselves rather than hack up the visitor.

- Doug

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev