]> granicus.if.org Git - clang/commitdiff
Fix -ast-print for uses of operator->.
authorEli Friedman <eli.friedman@gmail.com>
Fri, 12 Oct 2012 22:45:14 +0000 (22:45 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 12 Oct 2012 22:45:14 +0000 (22:45 +0000)
Patch by Grzegorz Jablonski.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165832 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/StmtPrinter.cpp
test/CXX/ast-print.cpp [new file with mode: 0644]

index 3a9f236f316f8c2088fb7af9ed6000763ab091d6..93d10f7aafe0e8672109c1e44d4792ef546aa5ea 100644 (file)
@@ -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 (file)
index 0000000..fb8588d
--- /dev/null
@@ -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());
+}
+