]> granicus.if.org Git - clang/commitdiff
Fixes a rewrite bug rewriting a block call argument which has a trvial
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 13 Jan 2010 21:41:11 +0000 (21:41 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 13 Jan 2010 21:41:11 +0000 (21:41 +0000)
constructor. Fixes radar 7537770.

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

lib/AST/StmtPrinter.cpp
test/Rewriter/rewrite-trivial-constructor.mm [new file with mode: 0644]

index 83d38f84524b555ba2ebc761b3905cc0a87fce53..bbb904de79b32b4ac40543f81cd76d8235bfc97e 100644 (file)
@@ -1121,6 +1121,13 @@ void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
 }
 
 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 (file)
index 0000000..81c7d9b
--- /dev/null
@@ -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--;
+        }
+    }
+}
+