Minor rewriter cleanup and a test for a block rewriting bug.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96361 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2010-02-16 17:26:03 +00:00
Родитель 6418825fb8
Коммит 210c248449
2 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -3918,7 +3918,6 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
for (llvm::SmallVector<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(), for (llvm::SmallVector<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) { E = BlockByCopyDecls.end(); I != E; ++I) {
S += " "; S += " ";
std::string Name = (*I)->getNameAsString();
// Handle nested closure invocation. For example: // Handle nested closure invocation. For example:
// //
// void (^myImportedClosure)(void); // void (^myImportedClosure)(void);
@ -3937,6 +3936,7 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
S += "__cself->" + (*I)->getNameAsString() + "; // bound by copy\n"; S += "__cself->" + (*I)->getNameAsString() + "; // bound by copy\n";
} }
else { else {
std::string Name = (*I)->getNameAsString();
(*I)->getType().getAsStringInternal(Name, Context->PrintingPolicy); (*I)->getType().getAsStringInternal(Name, Context->PrintingPolicy);
S += Name + " = __cself->" + S += Name + " = __cself->" +
(*I)->getNameAsString() + "; // bound by copy\n"; (*I)->getNameAsString() + "; // bound by copy\n";

Просмотреть файл

@ -2,6 +2,7 @@
// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
// radar 7638400 // radar 7638400
// FIXME. Arrange this test's rewritten source to compile with clang
@interface X @interface X
@end @end
@ -14,3 +15,16 @@ static void enumerateIt(void (^block)(id, id, char *)) {
@end @end
// CHECK-LP: static void enumerateIt(void (*)(id, id, char *)); // CHECK-LP: static void enumerateIt(void (*)(id, id, char *));
// radar 7651312
void apply(void (^block)(int));
static void x(int (^cmp)(int, int)) {
x(cmp);
}
static void y(int (^cmp)(int, int)) {
apply(^(int sect) {
x(cmp);
});
}