Fixes a rewrite bug rewriting a block call argument which has a trvial
constructor. Fixes radar 7537770.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93358 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 83d38f8..bbb904d 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -1121,6 +1121,13 @@
 }
 
 void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
+  // FIXME. For now we just print a trivial constructor call expression,
+  // constructing its first argument object.
+  if (E->getNumArgs() == 1) {
+    CXXConstructorDecl *CD = E->getConstructor();
+    if (CD->isTrivial())
+      PrintExpr(E->getArg(0));
+  }
   // Nothing to print.
 }
 
diff --git a/test/Rewriter/rewrite-trivial-constructor.mm b/test/Rewriter/rewrite-trivial-constructor.mm
new file mode 100644
index 0000000..81c7d9b
--- /dev/null
+++ b/test/Rewriter/rewrite-trivial-constructor.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks -o - %s
+// radar 7537770
+
+typedef struct {
+        int a;
+        int b;
+} s;
+
+extern void CFBasicHashApply(int (^block)(s)) {
+        int used, cnt;
+    for (int idx = 0; 0 < used && idx < cnt; idx++) {
+                s bkt;
+        if (0 < bkt.a) {
+            if (!block(bkt)) {
+                return;
+            }
+            used--;
+        }
+    }
+}
+