From: Eli Friedman Date: Fri, 12 Oct 2012 22:45:14 +0000 (+0000) Subject: Fix -ast-print for uses of operator->. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a143a9dcebea2ade67a2e9de1a939fbb70964015;p=clang Fix -ast-print for uses of operator->. Patch by Grzegorz Jablonski. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165832 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 3a9f236f31..93d10f7aaf 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -1130,6 +1130,8 @@ void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) { PrintExpr(Node->getArg(0)); OS << ' ' << OpStrings[Kind]; } + } else if (Kind == OO_Arrow) { + PrintExpr(Node->getArg(0)); } else if (Kind == OO_Call) { PrintExpr(Node->getArg(0)); OS << '('; diff --git a/test/CXX/ast-print.cpp b/test/CXX/ast-print.cpp new file mode 100644 index 0000000000..fb8588d4b1 --- /dev/null +++ b/test/CXX/ast-print.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -ast-print %s | FileCheck %s + +// CHECK: r; +// CHECK-NEXT: (r->method()); +struct MyClass +{ + void method() {} +}; + +struct Reference +{ + MyClass* object; + MyClass* operator ->() { return object; } +}; + +int main() +{ + Reference r; + (r->method()); +} +