diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-12-23 19:22:33 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-12-23 19:22:33 +0000 |
commit | ec878f2726e00e6dc0c432f462dab099e3f4a717 (patch) | |
tree | 2ee37c5d37f7411ae4973963ce59e4c65c2dd7d6 | |
parent | 6633522aaea663ebb18044a997b963bf92cd1a74 (diff) |
More rewriting of __block variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92027 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Frontend/RewriteObjC.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index 656d61b133..2a3dd7ab03 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -4166,11 +4166,25 @@ Stmt *RewriteObjC::RewriteBlockDeclRefExpr(BlockDeclRefExpr *BDRE) { // FIXME: Add more elaborate code generation required by the ABI. // That is, must generate BYREFVAR->__forwarding->BYREFVAR for each // BDRE where BYREFVAR is name of the variable. - Expr *DerefExpr = new (Context) UnaryOperator(BDRE, UnaryOperator::Deref, - Context->getPointerType(BDRE->getType()), - SourceLocation()); + FieldDecl *FD = FieldDecl::Create(*Context, 0, SourceLocation(), + &Context->Idents.get("__forwarding"), + Context->VoidPtrTy, 0, + /*BitWidth=*/0, /*Mutable=*/true); + MemberExpr *ME = new (Context) MemberExpr(BDRE, true, FD, SourceLocation(), + FD->getType()); + const char *Name = BDRE->getDecl()->getNameAsCString(); + FD = FieldDecl::Create(*Context, 0, SourceLocation(), + &Context->Idents.get(Name), + Context->VoidPtrTy, 0, + /*BitWidth=*/0, /*Mutable=*/true); + ME = new (Context) MemberExpr(ME, true, FD, SourceLocation(), + BDRE->getType()); + + + // Need parens to enforce precedence. - ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), DerefExpr); + ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), + ME); ReplaceStmt(BDRE, PE); return PE; } |