diff options
author | Anders Carlsson <andersca@mac.com> | 2009-05-17 18:41:29 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-05-17 18:41:29 +0000 |
commit | 165a0a07c0a91f8d61ee3737b62e7f376bb7e1c7 (patch) | |
tree | 6e696905f92c485ef758f8bfbd5163f48560e6b2 /lib/Sema/SemaExprCXX.cpp | |
parent | a99fad8ff134273fe85f2970c7d89133d1218900 (diff) |
Implement Sema::ActOnFinishFullExpr and create a CXXExprWithTemporaries node if necessary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71983 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index f6ee0927da..142f713254 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -164,8 +164,11 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, CallExpr::hasAnyTypeDependentArguments(Exprs, NumExprs)) { exprs.release(); - // FIXME: Is this correct? + // FIXME: Is this correct (I don't think so). Instead, we should have an + // CXXUnresolvedTemporaryObjectExpr node for this. CXXTempVarDecl *Temp = CXXTempVarDecl::Create(Context, CurContext, Ty); + ExprTemporaries.push_back(Temp); + return Owned(new (Context) CXXTemporaryObjectExpr(Context, Temp, 0, Ty, TyBeginLoc, Exprs, NumExprs, @@ -190,6 +193,8 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, if (const RecordType *RT = Ty->getAsRecordType()) { CXXRecordDecl *Record = cast<CXXRecordDecl>(RT->getDecl()); + // FIXME: We should always create a CXXTemporaryObjectExpr here unless + // both the ctor and dtor are trivial. if (NumExprs > 1 || Record->hasUserDeclaredConstructor()) { CXXConstructorDecl *Constructor = PerformInitializationByConstructor(Ty, Exprs, NumExprs, @@ -203,7 +208,8 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, return ExprError(); CXXTempVarDecl *Temp = CXXTempVarDecl::Create(Context, CurContext, Ty); - + ExprTemporaries.push_back(Temp); + exprs.release(); return Owned(new (Context) CXXTemporaryObjectExpr(Context, Temp, Constructor, Ty, @@ -1494,3 +1500,18 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) { } return QualType(); } + +Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) { + Expr *FullExpr = Arg.takeAs<Expr>(); + assert(FullExpr && "Null full expr!"); + + if (!ExprTemporaries.empty()) { + // Create a cleanup expr. + FullExpr = + new (Context) CXXExprWithTemporaries(FullExpr, &ExprTemporaries[0], + ExprTemporaries.size()); + ExprTemporaries.clear(); + } + + return Owned(FullExpr); +} |