diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-10-28 23:46:58 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-10-28 23:46:58 +0000 |
commit | 937224777a3fdcd73b065523274eb1d2273f1af2 (patch) | |
tree | 5fa2cec6a994eb470ac3a03f48d7ff6753662e37 | |
parent | 04bf6931cc94e399b4da63bdee248104bb2fc03a (diff) | |
download | llvm-937224777a3fdcd73b065523274eb1d2273f1af2.zip llvm-937224777a3fdcd73b065523274eb1d2273f1af2.tar.gz llvm-937224777a3fdcd73b065523274eb1d2273f1af2.tar.bz2 |
Objective-C modern rewriter. Patch to fix a rewriting bug
rewriting an Objective-C block. Patch by Ryan Govostes.
rdar://18799145
llvm-svn: 220834
4 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index 3c48de2..bcfba22 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -5526,6 +5526,10 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, VK_RValue, OK_Ordinary, SourceLocation()); NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CK_BitCast, NewRep); + // Put Paren around the call. + NewRep = new (Context) ParenExpr(SourceLocation(), SourceLocation(), + NewRep); + BlockDeclRefs.clear(); BlockByRefDecls.clear(); BlockByRefDeclsPtrSet.clear(); diff --git a/clang/test/Rewriter/rewrite-block-literal.mm b/clang/test/Rewriter/rewrite-block-literal.mm index 43f5811..cde6efc 100644 --- a/clang/test/Rewriter/rewrite-block-literal.mm +++ b/clang/test/Rewriter/rewrite-block-literal.mm @@ -70,7 +70,7 @@ static int global_x = 10; void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); }; // CHECK: static __global_block_block_impl_0 __global_global_block_block_impl_0((void *)__global_block_block_func_0, &__global_block_block_desc_0_DATA); -// CHECK: void (*global_block)(void) = (void (*)())&__global_global_block_block_impl_0; +// CHECK: void (*global_block)(void) = ((void (*)())&__global_global_block_block_impl_0); typedef void (^void_block_t)(void); diff --git a/clang/test/Rewriter/rewrite-modern-block.mm b/clang/test/Rewriter/rewrite-modern-block.mm index 2302965..926ee36 100644 --- a/clang/test/Rewriter/rewrite-modern-block.mm +++ b/clang/test/Rewriter/rewrite-modern-block.mm @@ -63,3 +63,6 @@ z w(int loc, int len); options &= ~(1 | 2); } @end + +// rdar://18799145 +int Test18799145() { return ^(){return 0;}(); } diff --git a/clang/test/Rewriter/rewrite-modern-captured-nested-bvar.mm b/clang/test/Rewriter/rewrite-modern-captured-nested-bvar.mm index a8fd180..be7548c 100644 --- a/clang/test/Rewriter/rewrite-modern-captured-nested-bvar.mm +++ b/clang/test/Rewriter/rewrite-modern-captured-nested-bvar.mm @@ -32,4 +32,4 @@ int main() { // CHECK 2: (__Block_byref_BYREF_VAR_CHECK_0 *)BYREF_VAR_CHECK // CHECK: {(void*)0,(__Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, 0, sizeof(__Block_byref_BYREF_VAR_CHECK_0), 'a'} -// CHECK: __Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, (__Block_byref_d_1 *)&d, 570425344)); +// CHECK: __Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, (__Block_byref_d_1 *)&d, 570425344))); |