When I have an expression of the form:
struct blah {
struct {
struct {
int b;
};
};
};
int foo(const struct blah *b) {
return b->b;
}
The expression 'b->b' has the following (correct) AST:
(ImplicitCastExpr 0x44bc968 'int' <LValueToRValue>
(MemberExpr 0x44bc8f0 'int' lvalue .b 0x44899b0
(MemberExpr 0x44bc8c0 'struct blah::<anonymous at foo.c:3:9>' lvalue .
0x4489a50
(MemberExpr 0x44bc890 'struct blah::<anonymous at foo.c:2:5>' lvalue ->
0x44bc2f0
(ImplicitCastExpr 0x44bc878 'union blah *' <LValueToRValue>
(DeclRefExpr 0x44bc850 'union blah *' lvalue ParmVar 0x44bc440 'b'
'union blah *'))))))
But the pretty printer (and as a consequence clang -cc1 -ast-print foo.c) badly
print this as 'b.b' because all the MemberExpr targeting anonymous types are
simply ignored. The patch fix that behavior: the arrow/dot notation is printed
if the base of the expression is not anonymous.
---
lib/AST/StmtPrinter.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
0001-Fix-pretty-print-when-dealing-with-anonymous-structu.patch
Description: Binary data
-- Florent Bruneau
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
