RecursiveASTVisitor: VisitTypeOfExprType doesn't get called

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

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?

Gut feeling would be that this is a bug in RAV, but I think that needs
some more investigation. Please open a bug so we track it.

Thanks for reporting,
/Manuel

Done: http://llvm.org/bugs/show_bug.cgi?id=13618