void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
// FIXME: Suppress printing implicit bases (like "this")
PrintExpr(Node->getBase());
+
+ MemberExpr *ParentMember = dyn_cast<MemberExpr>(Node->getBase());
+ FieldDecl *ParentDecl = ParentMember ? dyn_cast<FieldDecl>(ParentMember->getMemberDecl()): NULL;
+
+ if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion()) {
+ OS << (Node->isArrow() ? "->" : ".");
+ }
+
if (FieldDecl *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
if (FD->isAnonymousStructOrUnion())
return;
- OS << (Node->isArrow() ? "->" : ".");
+
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
Qualifier->print(OS, Policy);
if (Node->hasTemplateKeyword())
-// RUN: %clang_cc1 %s -ast-print
+// RUN: %clang_cc1 %s -ast-print | FileCheck %s
typedef void func_typedef();
func_typedef xxx;
typedef void func_t(int x);
func_t a;
+struct blah {
+ struct {
+ struct {
+ int b;
+ };
+ };
+};
+
+int foo(const struct blah *b) {
+ // CHECK: return b->b;
+ return b->b;
+}