[cfe-dev] RecursiveASTVisitor: VisitTypeOfExprType doesn't get called
Sergejs Belajevs
sergejs.belajevs at gmail.com
Thu Aug 16 06:34:20 PDT 2012
Hi,
I am using clang for a source-to-source transformation tool and as a
part of the whole process, I am using RecursiveASTVisitor for variable
renaming, specifically, VisitVarDecl and VisitDeclRefExpr. While
testing it on open-source project, found the following code:
test.c:
int status = 0;
...
status = ((((__extension__ (((union { __typeof(status) __in; int __i;
}) { .__in = (status) }).__i))) & 0xff00) >> 8);
Original code is compiled without errors (by C compiler), but not my
transformed code. The problem is that all occurrences of "status" are
renamed. All but one, which is inside "__typeof()" inside anonymous
union inside __extension__. I added also "VisitTypeOfExprType" to my
resursive AST visitor and it never got called on this code. However,
when I tried it on the following code:
status = ({ union { __typeof(status) __in; int __i; } a; a.__in =
status; (a.__i & 0xff00) >> 8; });
I got a call to VisitTypeOfExprType. All occurrences of status are
also correctly renamed by my transformation tool for this piece of
code.
Can somebody help me to get my renaming working also for the first
case with "__extension__"? Am I doing something wrong or is this a
bug?
Thanks,
Sergejs
More information about the cfe-dev
mailing list