diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2010-06-04 21:35:44 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-06-04 21:35:44 +0000 |
| commit | ea882cd92ee91803143632f4b597f1317113f80f (patch) | |
| tree | 9d627700f62ca8f4edfa593ad6549e2ae34da5c7 /clang/lib/Sema | |
| parent | 065d6fd5372a9b0018ab878fc5466181f71079c3 (diff) | |
| download | bcm5719-llvm-ea882cd92ee91803143632f4b597f1317113f80f.tar.gz bcm5719-llvm-ea882cd92ee91803143632f4b597f1317113f80f.zip | |
Build AST for copy-construction of copied-in
class object in blocks and carry it to IRGen.
llvm-svn: 105487
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index e1a6a04bfd4..5655a25b1fd 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1746,8 +1746,28 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, // Variable will be bound by-copy, make it const within the closure. ExprTy.addConst(); - return Owned(new (Context) BlockDeclRefExpr(VD, ExprTy, Loc, false, - constAdded)); + BlockDeclRefExpr *BDRE = new (Context) BlockDeclRefExpr(VD, + ExprTy, Loc, false, + constAdded); + QualType T = VD->getType(); + if (getLangOptions().CPlusPlus && !T->isDependentType() && + !T->isReferenceType()) { + Expr *E = new (Context) + DeclRefExpr(const_cast<ValueDecl*>(BDRE->getDecl()), T, + SourceLocation()); + + OwningExprResult Res = PerformCopyInitialization( + InitializedEntity::InitializeResult(SourceLocation(), + T, false), + SourceLocation(), + Owned(E)); + if (!Res.isInvalid()) { + Expr *Init = Res.takeAs<Expr>(); + if (isa<CXXConstructExpr>(Init)) + BDRE->setCopyConstructorExpr(Init); + } + } + return Owned(BDRE); } // If this reference is not in a block or if the referenced variable is // within the block, create a normal DeclRefExpr. |

