From c75da518fde1f3b93643ac4e376ff2acd260facd Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 13 Jan 2010 21:41:11 +0000 Subject: [PATCH] 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 --- lib/AST/StmtPrinter.cpp | 7 +++++++ test/Rewriter/rewrite-trivial-constructor.mm | 21 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/Rewriter/rewrite-trivial-constructor.mm diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 83d38f8452..bbb904de79 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -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 index 0000000000..81c7d9b8a7 --- /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--; + } + } +} + -- 2.40.0