forked from OSchip/llvm-project
parent
b228818554
commit
4b2434da54
|
@ -458,7 +458,6 @@ public:
|
|||
|
||||
/// CXXConstructExpr - Represents a call to a C++ constructor.
|
||||
class CXXConstructExpr : public Expr {
|
||||
VarDecl *VD;
|
||||
CXXConstructorDecl *Constructor;
|
||||
|
||||
bool Elidable;
|
||||
|
@ -468,19 +467,18 @@ class CXXConstructExpr : public Expr {
|
|||
|
||||
|
||||
protected:
|
||||
CXXConstructExpr(ASTContext &C, StmtClass SC, VarDecl *vd, QualType T,
|
||||
CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
|
||||
CXXConstructorDecl *d, bool elidable,
|
||||
Expr **args, unsigned numargs);
|
||||
~CXXConstructExpr() { }
|
||||
|
||||
public:
|
||||
static CXXConstructExpr *Create(ASTContext &C, VarDecl *VD, QualType T,
|
||||
static CXXConstructExpr *Create(ASTContext &C, QualType T,
|
||||
CXXConstructorDecl *D, bool Elidable,
|
||||
Expr **Args, unsigned NumArgs);
|
||||
|
||||
void Destroy(ASTContext &C);
|
||||
|
||||
VarDecl* getVarDecl() const { return VD; }
|
||||
CXXConstructorDecl* getConstructor() const { return Constructor; }
|
||||
|
||||
/// \brief Whether this construction is elidable.
|
||||
|
@ -558,10 +556,10 @@ class CXXTemporaryObjectExpr : public CXXConstructExpr {
|
|||
SourceLocation RParenLoc;
|
||||
|
||||
public:
|
||||
CXXTemporaryObjectExpr(ASTContext &C, VarDecl *vd,
|
||||
CXXConstructorDecl *Cons, QualType writtenTy,
|
||||
SourceLocation tyBeginLoc, Expr **Args,
|
||||
unsigned NumArgs, SourceLocation rParenLoc);
|
||||
CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
|
||||
QualType writtenTy, SourceLocation tyBeginLoc,
|
||||
Expr **Args,unsigned NumArgs,
|
||||
SourceLocation rParenLoc);
|
||||
|
||||
~CXXTemporaryObjectExpr() { }
|
||||
|
||||
|
|
|
@ -251,35 +251,33 @@ CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
|
|||
return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
|
||||
}
|
||||
|
||||
CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C, VarDecl *vd,
|
||||
CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
|
||||
CXXConstructorDecl *Cons,
|
||||
QualType writtenTy,
|
||||
SourceLocation tyBeginLoc,
|
||||
Expr **Args,
|
||||
unsigned NumArgs,
|
||||
SourceLocation rParenLoc)
|
||||
: CXXConstructExpr(C, CXXTemporaryObjectExprClass, vd, writtenTy, Cons,
|
||||
: CXXConstructExpr(C, CXXTemporaryObjectExprClass, writtenTy, Cons,
|
||||
false, Args, NumArgs),
|
||||
TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {
|
||||
}
|
||||
|
||||
CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, VarDecl *VD,
|
||||
QualType T, CXXConstructorDecl *D,
|
||||
bool Elidable,
|
||||
CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T,
|
||||
CXXConstructorDecl *D, bool Elidable,
|
||||
Expr **Args, unsigned NumArgs) {
|
||||
return new (C) CXXConstructExpr(C, CXXConstructExprClass, VD, T, D, Elidable,
|
||||
return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, D, Elidable,
|
||||
Args, NumArgs);
|
||||
}
|
||||
|
||||
CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, VarDecl *vd,
|
||||
QualType T, CXXConstructorDecl *D,
|
||||
bool elidable,
|
||||
CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
|
||||
CXXConstructorDecl *D, bool elidable,
|
||||
Expr **args, unsigned numargs)
|
||||
: Expr(SC, T,
|
||||
T->isDependentType(),
|
||||
(T->isDependentType() ||
|
||||
CallExpr::hasAnyValueDependentArguments(args, numargs))),
|
||||
VD(vd), Constructor(D), Elidable(elidable), Args(0), NumArgs(numargs) {
|
||||
Constructor(D), Elidable(elidable), Args(0), NumArgs(numargs) {
|
||||
if (NumArgs > 0) {
|
||||
Args = new (C) Stmt*[NumArgs];
|
||||
for (unsigned i = 0; i < NumArgs; ++i)
|
||||
|
|
|
@ -292,17 +292,9 @@ void AggExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
|
|||
|
||||
void
|
||||
AggExprEmitter::VisitCXXConstructExpr(const CXXConstructExpr *E) {
|
||||
llvm::Value *V = DestPtr;
|
||||
|
||||
if (!V) {
|
||||
assert(isa<CXXTempVarDecl>(E->getVarDecl()) &&
|
||||
"Must have a temp var decl when there's no destination!");
|
||||
|
||||
V = CGF.CreateTempAlloca(CGF.ConvertType(E->getVarDecl()->getType()),
|
||||
"tmpvar");
|
||||
}
|
||||
|
||||
CGF.EmitCXXConstructExpr(V, E);
|
||||
assert(DestPtr && "Must have somewhere to emit into!");
|
||||
|
||||
CGF.EmitCXXConstructExpr(DestPtr, E);
|
||||
}
|
||||
|
||||
void AggExprEmitter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
|
||||
|
|
|
@ -1800,7 +1800,7 @@ void Sema::InitializeVarWithConstructor(VarDecl *VD,
|
|||
CXXConstructorDecl *Constructor,
|
||||
QualType DeclInitType,
|
||||
Expr **Exprs, unsigned NumExprs) {
|
||||
Expr *Temp = CXXConstructExpr::Create(Context, VD, DeclInitType, Constructor,
|
||||
Expr *Temp = CXXConstructExpr::Create(Context, DeclInitType, Constructor,
|
||||
false, Exprs, NumExprs);
|
||||
VD->setInit(Context, Temp);
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
|
|||
|
||||
exprs.release();
|
||||
|
||||
Expr *E = new (Context) CXXTemporaryObjectExpr(Context, Temp, Constructor,
|
||||
Expr *E = new (Context) CXXTemporaryObjectExpr(Context, Constructor,
|
||||
Ty, TyBeginLoc, Exprs,
|
||||
NumExprs, RParenLoc);
|
||||
return MaybeBindToTemporary(E);
|
||||
|
@ -883,9 +883,8 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
|
|||
// FIXME: When can ToType be a reference type?
|
||||
assert(!ToType->isReferenceType());
|
||||
|
||||
CXXTempVarDecl *Temp = CXXTempVarDecl::Create(Context, CurContext, ToType);
|
||||
// FIXME: Keep track of whether the copy constructor is elidable or not.
|
||||
From = CXXConstructExpr::Create(Context, Temp, ToType,
|
||||
From = CXXConstructExpr::Create(Context, ToType,
|
||||
SCS.CopyConstructor, false, &From, 1);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -174,8 +174,8 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
|
|||
if (!Constructor)
|
||||
return true;
|
||||
|
||||
Init = CXXConstructExpr::Create(Context, 0, DeclType, Constructor,
|
||||
false, &Init, 1);
|
||||
Init = CXXConstructExpr::Create(Context, DeclType, Constructor, false,
|
||||
&Init, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1007,15 +1007,7 @@ TemplateExprInstantiator::VisitCXXConstructExpr(CXXConstructExpr *E) {
|
|||
Args.push_back(ArgInst.takeAs<Expr>());
|
||||
}
|
||||
|
||||
|
||||
VarDecl *Var = cast_or_null<VarDecl>(SemaRef.InstantiateDecl(E->getVarDecl(),
|
||||
SemaRef.CurContext,
|
||||
TemplateArgs));
|
||||
if (!Var)
|
||||
return SemaRef.ExprError();
|
||||
|
||||
SemaRef.CurrentInstantiationScope->InstantiatedLocal(E->getVarDecl(), Var);
|
||||
return SemaRef.Owned(CXXConstructExpr::Create(SemaRef.Context, Var, T,
|
||||
return SemaRef.Owned(CXXConstructExpr::Create(SemaRef.Context, T,
|
||||
E->getConstructor(),
|
||||
E->isElidable(),
|
||||
Args.takeAs<Expr>(),
|
||||
|
|
Loading…
Reference in New Issue