BuildCXXConstructExpr now takes a MultiExprArg.

llvm-svn: 81160
This commit is contained in:
Anders Carlsson 2009-09-07 22:23:31 +00:00
parent e48704b8da
commit 5995a3e8fa
6 changed files with 24 additions and 20 deletions

View File

@ -1810,14 +1810,14 @@ public:
bool InitializeVarWithConstructor(VarDecl *VD,
CXXConstructorDecl *Constructor,
QualType DeclInitType,
Expr **Exprs, unsigned NumExprs);
MultiExprArg Exprs);
/// BuildCXXConstructExpr - Creates a complete call to a constructor,
/// including handling of its default argument expressions.
OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc,
QualType DeclInitType,
CXXConstructorDecl *Constructor,
Expr **Exprs, unsigned NumExprs);
MultiExprArg Exprs);
// FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
// the constructor can be elidable?
@ -1825,7 +1825,7 @@ public:
QualType DeclInitType,
CXXConstructorDecl *Constructor,
bool Elidable,
Expr **Exprs, unsigned NumExprs);
MultiExprArg Exprs);
OwningExprResult BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Cons,
QualType writtenTy,

View File

@ -3284,7 +3284,8 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
Var->setInvalidDecl();
else {
if (!RD->hasTrivialConstructor() || !RD->hasTrivialDestructor()) {
if (InitializeVarWithConstructor(Var, Constructor, InitType, 0, 0))
if (InitializeVarWithConstructor(Var, Constructor, InitType,
MultiExprArg(*this)))
Var->setInvalidDecl();
}

View File

@ -2809,8 +2809,8 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
Sema::OwningExprResult
Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
CXXConstructorDecl *Constructor,
Expr **Exprs, unsigned NumExprs) {
CXXConstructorDecl *Constructor,
MultiExprArg ExprArgs) {
bool Elidable = false;
// [class.copy]p15:
@ -2821,8 +2821,8 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
//all, even if the class copy constructor or destructor have side effects.
// FIXME: Is this enough?
if (Constructor->isCopyConstructor(Context) && NumExprs == 1) {
Expr *E = Exprs[0];
if (Constructor->isCopyConstructor(Context) && ExprArgs.size() == 1) {
Expr *E = ((Expr **)ExprArgs.get())[0];
while (CXXBindTemporaryExpr *BE = dyn_cast<CXXBindTemporaryExpr>(E))
E = BE->getSubExpr();
@ -2831,7 +2831,7 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
}
return BuildCXXConstructExpr(ConstructLoc, DeclInitType, Constructor,
Elidable, Exprs, NumExprs);
Elidable, move(ExprArgs));
}
/// BuildCXXConstructExpr - Creates a complete call to a constructor,
@ -2839,7 +2839,10 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
Sema::OwningExprResult
Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
CXXConstructorDecl *Constructor, bool Elidable,
Expr **Exprs, unsigned NumExprs) {
MultiExprArg ExprArgs) {
unsigned NumExprs = ExprArgs.size();
Expr **Exprs = (Expr **)ExprArgs.release();
ExprOwningPtr<CXXConstructExpr> Temp(this,
CXXConstructExpr::Create(Context,
DeclInitType,
@ -2897,10 +2900,10 @@ Sema::BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Constructor,
bool Sema::InitializeVarWithConstructor(VarDecl *VD,
CXXConstructorDecl *Constructor,
QualType DeclInitType,
Expr **Exprs, unsigned NumExprs) {
MultiExprArg Exprs) {
OwningExprResult TempResult =
BuildCXXConstructExpr(VD->getLocation(), DeclInitType, Constructor,
Exprs, NumExprs);
move(Exprs));
if (TempResult.isInvalid())
return true;
@ -3003,7 +3006,7 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
else {
VDecl->setCXXDirectInitializer(true);
if (InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
(Expr**)Exprs.release(), NumExprs))
move(Exprs)))
RealDecl->setInvalidDecl();
FinalizeVarWithDestructor(VDecl, DeclInitType);
}

View File

@ -942,8 +942,8 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
DefaultFunctionArrayConversion(From);
OwningExprResult InitResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
ToType.getNonReferenceType(),
CD, &From, 1);
ToType.getNonReferenceType(), CD,
MultiExprArg(*this, (void**)&From, 1));
// Take ownership of this expression.
From = InitResult.takeAs<Expr>();
CastKind = CastExpr::CK_ConstructorConversion ;
@ -988,7 +988,8 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
OwningExprResult FromResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
ToType, SCS.CopyConstructor, &From, 1);
ToType, SCS.CopyConstructor,
MultiExprArg(*this, (void**)&From, 1));
if (FromResult.isInvalid())
return true;

View File

@ -182,7 +182,8 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
OwningExprResult InitResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
DeclType, Constructor, &Init, 1);
DeclType, Constructor,
MultiExprArg(*this, (void**)&Init, 1));
if (InitResult.isInvalid())
return true;

View File

@ -1448,12 +1448,10 @@ public:
CXXConstructorDecl *Constructor,
bool IsElidable,
MultiExprArg Args) {
unsigned NumArgs = Args.size();
Expr **ArgsExprs = (Expr **)Args.release();
return getSema().BuildCXXConstructExpr(/*FIXME:ConstructLoc*/
SourceLocation(),
T, Constructor, IsElidable,
ArgsExprs, NumArgs);
move(Args));
}
/// \brief Build a new object-construction expression.