friend class ASTStmtWriter;
};
-class CXXExprWithTemporaries : public Expr {
+/// Represents an expression --- generally a full-expression --- which
+/// introduces cleanups to be run at the end of the sub-expression's
+/// evaluation. The most common source of expression-introduced
+/// cleanups is temporary objects in C++, but several other C++
+/// expressions can create cleanups.
+class ExprWithCleanups : public Expr {
Stmt *SubExpr;
CXXTemporary **Temps;
unsigned NumTemps;
- CXXExprWithTemporaries(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps,
- unsigned NumTemps);
-
+ ExprWithCleanups(ASTContext &C, Expr *SubExpr,
+ CXXTemporary **Temps, unsigned NumTemps);
+
public:
- CXXExprWithTemporaries(EmptyShell Empty)
- : Expr(CXXExprWithTemporariesClass, Empty),
+ ExprWithCleanups(EmptyShell Empty)
+ : Expr(ExprWithCleanupsClass, Empty),
SubExpr(0), Temps(0), NumTemps(0) {}
- static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
+ static ExprWithCleanups *Create(ASTContext &C, Expr *SubExpr,
CXXTemporary **Temps,
unsigned NumTemps);
return Temps[i];
}
const CXXTemporary *getTemporary(unsigned i) const {
- return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
+ return const_cast<ExprWithCleanups*>(this)->getTemporary(i);
}
void setTemporary(unsigned i, CXXTemporary *T) {
assert(i < NumTemps && "Index out of range");
// Implement isa/cast/dyncast/etc.
static bool classof(const Stmt *T) {
- return T->getStmtClass() == CXXExprWithTemporariesClass;
+ return T->getStmtClass() == ExprWithCleanupsClass;
}
- static bool classof(const CXXExprWithTemporaries *) { return true; }
+ static bool classof(const ExprWithCleanups *) { return true; }
// Iterators
virtual child_iterator child_begin();
DEF_TRAVERSE_STMT(CXXBoolLiteralExpr, { })
DEF_TRAVERSE_STMT(CXXDefaultArgExpr, { })
DEF_TRAVERSE_STMT(CXXDeleteExpr, { })
-DEF_TRAVERSE_STMT(CXXExprWithTemporaries, { })
+DEF_TRAVERSE_STMT(ExprWithCleanups, { })
DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, { })
DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, { })
DEF_TRAVERSE_STMT(CXXThisExpr, { })
def DependentScopeDeclRefExpr : DStmt<Expr>;
def CXXConstructExpr : DStmt<Expr>;
def CXXBindTemporaryExpr : DStmt<Expr>;
-def CXXExprWithTemporaries : DStmt<Expr>;
+def ExprWithCleanups : DStmt<Expr>;
def CXXTemporaryObjectExpr : DStmt<CXXConstructExpr>;
def CXXUnresolvedConstructExpr : DStmt<Expr>;
def CXXDependentScopeMemberExpr : DStmt<Expr>;
UnqualifiedId &SecondTypeName,
bool HasTrailingLParen);
- /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is
- /// non-empty, will create a new CXXExprWithTemporaries expression.
- /// Otherwise, just returs the passed in expression.
- Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr);
- Stmt *MaybeCreateCXXStmtWithTemporaries(Stmt *SubStmt);
- ExprResult MaybeCreateCXXExprWithTemporaries(ExprResult SubExpr);
+ /// MaybeCreateExprWithCleanups - If the current full-expression
+ /// requires any cleanups, surround it with a ExprWithCleanups node.
+ /// Otherwise, just returns the passed-in expression.
+ Expr *MaybeCreateExprWithCleanups(Expr *SubExpr);
+ Stmt *MaybeCreateStmtWithCleanups(Stmt *SubStmt);
+ ExprResult MaybeCreateExprWithCleanups(ExprResult SubExpr);
FullExpr CreateFullExpr(Expr *SubExpr);
ExprResult ActOnFinishFullExpr(Expr *Expr);
EXPR_CXX_DELETE, // CXXDeleteExpr
EXPR_CXX_PSEUDO_DESTRUCTOR, // CXXPseudoDestructorExpr
- EXPR_CXX_EXPR_WITH_TEMPORARIES, // CXXExprWithTemporaries
+ EXPR_EXPR_WITH_CLEANUPS, // ExprWithCleanups
EXPR_CXX_DEPENDENT_SCOPE_MEMBER, // CXXDependentScopeMemberExpr
EXPR_CXX_DEPENDENT_SCOPE_DECL_REF, // DependentScopeDeclRefExpr
"Default argument is not yet instantiated!");
Expr *Arg = getInit();
- if (CXXExprWithTemporaries *E = dyn_cast_or_null<CXXExprWithTemporaries>(Arg))
+ if (ExprWithCleanups *E = dyn_cast_or_null<ExprWithCleanups>(Arg))
return E->getSubExpr();
return Arg;
}
unsigned ParmVarDecl::getNumDefaultArgTemporaries() const {
- if (const CXXExprWithTemporaries *E =
- dyn_cast<CXXExprWithTemporaries>(getInit()))
+ if (const ExprWithCleanups *E = dyn_cast<ExprWithCleanups>(getInit()))
return E->getNumTemporaries();
return 0;
assert(getNumDefaultArgTemporaries() &&
"Default arguments does not have any temporaries!");
- CXXExprWithTemporaries *E = cast<CXXExprWithTemporaries>(getInit());
+ ExprWithCleanups *E = cast<ExprWithCleanups>(getInit());
return E->getTemporary(i);
}
// Nothing to print
} else {
Expr *Init = BMInitializer->getInit();
- if (CXXExprWithTemporaries *Tmp
- = dyn_cast<CXXExprWithTemporaries>(Init))
+ if (ExprWithCleanups *Tmp = dyn_cast<ExprWithCleanups>(Init))
Init = Tmp->getSubExpr();
Init = Init->IgnoreParens();
case CXXBindTemporaryExprClass:
return (cast<CXXBindTemporaryExpr>(this)
->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2, Ctx));
- case CXXExprWithTemporariesClass:
- return (cast<CXXExprWithTemporaries>(this)
+ case ExprWithCleanupsClass:
+ return (cast<ExprWithCleanups>(this)
->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2, Ctx));
}
}
case ParenListExprClass:
case VAArgExprClass:
case CXXDefaultArgExprClass:
- case CXXExprWithTemporariesClass:
+ case ExprWithCleanupsClass:
case ObjCIvarRefExprClass:
case ObjCIsaExprClass:
case ShuffleVectorExprClass:
}
}
-CXXExprWithTemporaries::CXXExprWithTemporaries(ASTContext &C,
- Expr *subexpr,
- CXXTemporary **temps,
- unsigned numtemps)
- : Expr(CXXExprWithTemporariesClass, subexpr->getType(),
+ExprWithCleanups::ExprWithCleanups(ASTContext &C,
+ Expr *subexpr,
+ CXXTemporary **temps,
+ unsigned numtemps)
+ : Expr(ExprWithCleanupsClass, subexpr->getType(),
subexpr->getValueKind(), subexpr->getObjectKind(),
subexpr->isTypeDependent(), subexpr->isValueDependent()),
SubExpr(subexpr), Temps(0), NumTemps(0) {
}
}
-void CXXExprWithTemporaries::setNumTemporaries(ASTContext &C, unsigned N) {
+void ExprWithCleanups::setNumTemporaries(ASTContext &C, unsigned N) {
assert(Temps == 0 && "Cannot resize with this");
NumTemps = N;
Temps = new (C) CXXTemporary*[NumTemps];
}
-CXXExprWithTemporaries *CXXExprWithTemporaries::Create(ASTContext &C,
- Expr *SubExpr,
- CXXTemporary **Temps,
- unsigned NumTemps) {
- return new (C) CXXExprWithTemporaries(C, SubExpr, Temps, NumTemps);
+ExprWithCleanups *ExprWithCleanups::Create(ASTContext &C,
+ Expr *SubExpr,
+ CXXTemporary **Temps,
+ unsigned NumTemps) {
+ return new (C) ExprWithCleanups(C, SubExpr, Temps, NumTemps);
}
// CXXBindTemporaryExpr
return &Args[0]+NumArgs;
}
-// CXXExprWithTemporaries
-Stmt::child_iterator CXXExprWithTemporaries::child_begin() {
+// ExprWithCleanups
+Stmt::child_iterator ExprWithCleanups::child_begin() {
return &SubExpr;
}
-Stmt::child_iterator CXXExprWithTemporaries::child_end() {
+Stmt::child_iterator ExprWithCleanups::child_end() {
return &SubExpr + 1;
}
case Expr::CXXBindTemporaryExprClass:
return ClassifyInternal(Ctx, cast<CXXBindTemporaryExpr>(E)->getSubExpr());
- // And the temporary lifetime guard.
- case Expr::CXXExprWithTemporariesClass:
- return ClassifyInternal(Ctx, cast<CXXExprWithTemporaries>(E)->getSubExpr());
+ // And the cleanups guard.
+ case Expr::ExprWithCleanupsClass:
+ return ClassifyInternal(Ctx, cast<ExprWithCleanups>(E)->getSubExpr());
// Casts depend completely on the target type. All casts work the same.
case Expr::CStyleCastExprClass:
case Expr::DependentScopeDeclRefExprClass:
case Expr::CXXConstructExprClass:
case Expr::CXXBindTemporaryExprClass:
- case Expr::CXXExprWithTemporariesClass:
+ case Expr::ExprWithCleanupsClass:
case Expr::CXXTemporaryObjectExprClass:
case Expr::CXXUnresolvedConstructExprClass:
case Expr::CXXDependentScopeMemberExprClass:
void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node);
void VisitCXXConstructExpr(CXXConstructExpr *Node);
void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node);
- void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *Node);
+ void VisitExprWithCleanups(ExprWithCleanups *Node);
void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node);
void DumpCXXTemporary(CXXTemporary *Temporary);
DumpCXXTemporary(Node->getTemporary());
}
-void StmtDumper::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *Node) {
+void StmtDumper::VisitExprWithCleanups(ExprWithCleanups *Node) {
DumpExpr(Node);
++IndentLevel;
for (unsigned i = 0, e = Node->getNumTemporaries(); i != e; ++i) {
// Nothing to print.
}
-void StmtPrinter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
+void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
// Just forward to the sub expression.
PrintExpr(E->getSubExpr());
}
VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
}
-void StmtProfiler::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *S) {
+void StmtProfiler::VisitExprWithCleanups(ExprWithCleanups *S) {
VisitExpr(S);
- for (unsigned I = 0, N = S->getNumTemporaries(); I != N; ++I)
- VisitDecl(
- const_cast<CXXDestructorDecl *>(S->getTemporary(I)->getDestructor()));
}
void
CFGBlock *VisitBlockExpr(BlockExpr* E, AddStmtChoice asc);
CFGBlock *VisitBreakStmt(BreakStmt *B);
CFGBlock *VisitCXXCatchStmt(CXXCatchStmt *S);
- CFGBlock *VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E,
+ CFGBlock *VisitExprWithCleanups(ExprWithCleanups *E,
AddStmtChoice asc);
CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
if (Init) {
if (FieldDecl *FD = I->getAnyMember())
IsReference = FD->getType()->isReferenceType();
- HasTemporaries = isa<CXXExprWithTemporaries>(Init);
+ HasTemporaries = isa<ExprWithCleanups>(Init);
if (BuildOpts.AddImplicitDtors && HasTemporaries) {
// Generate destructors for temporaries in initialization expression.
- VisitForTemporaryDtors(cast<CXXExprWithTemporaries>(Init)->getSubExpr(),
+ VisitForTemporaryDtors(cast<ExprWithCleanups>(Init)->getSubExpr(),
IsReference);
}
}
if (HasTemporaries)
// For expression with temporaries go directly to subexpression to omit
// generating destructors for the second time.
- return Visit(cast<CXXExprWithTemporaries>(Init)->getSubExpr(), asc);
+ return Visit(cast<ExprWithCleanups>(Init)->getSubExpr(), asc);
return Visit(Init, asc);
}
case Stmt::CXXCatchStmtClass:
return VisitCXXCatchStmt(cast<CXXCatchStmt>(S));
- case Stmt::CXXExprWithTemporariesClass:
- return VisitCXXExprWithTemporaries(cast<CXXExprWithTemporaries>(S), asc);
+ case Stmt::ExprWithCleanupsClass:
+ return VisitExprWithCleanups(cast<ExprWithCleanups>(S), asc);
case Stmt::CXXBindTemporaryExprClass:
return VisitCXXBindTemporaryExpr(cast<CXXBindTemporaryExpr>(S), asc);
Expr *Init = VD->getInit();
if (Init) {
IsReference = VD->getType()->isReferenceType();
- HasTemporaries = isa<CXXExprWithTemporaries>(Init);
+ HasTemporaries = isa<ExprWithCleanups>(Init);
if (BuildOpts.AddImplicitDtors && HasTemporaries) {
// Generate destructors for temporaries in initialization expression.
- VisitForTemporaryDtors(cast<CXXExprWithTemporaries>(Init)->getSubExpr(),
+ VisitForTemporaryDtors(cast<ExprWithCleanups>(Init)->getSubExpr(),
IsReference);
}
}
if (HasTemporaries)
// For expression with temporaries go directly to subexpression to omit
// generating destructors for the second time.
- Visit(cast<CXXExprWithTemporaries>(Init)->getSubExpr(), asc);
+ Visit(cast<ExprWithCleanups>(Init)->getSubExpr(), asc);
else
Visit(Init, asc);
}
return CatchBlock;
}
-CFGBlock *CFGBuilder::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E,
+CFGBlock *CFGBuilder::VisitExprWithCleanups(ExprWithCleanups *E,
AddStmtChoice asc) {
if (BuildOpts.AddImplicitDtors) {
// If adding implicit destructors visit the full expression for adding
if (isa<CXXConstructExpr>(E))
return;
- if (isa<CXXExprWithTemporaries>(E))
+ if (isa<ExprWithCleanups>(E))
return;
// A dead initialization is a variable that is dead after it
}
break;
}
- case Stmt::CXXExprWithTemporariesClass:
- E = cast<CXXExprWithTemporaries>(E)->getSubExpr();
+ case Stmt::ExprWithCleanupsClass:
+ E = cast<ExprWithCleanups>(E)->getSubExpr();
continue;
case Stmt::CXXBindTemporaryExprClass:
E = cast<CXXBindTemporaryExpr>(E)->getSubExpr();
case Stmt::CXXCatchStmtClass:
case Stmt::CXXDefaultArgExprClass:
case Stmt::CXXDependentScopeMemberExprClass:
- case Stmt::CXXExprWithTemporariesClass:
+ case Stmt::ExprWithCleanupsClass:
case Stmt::CXXNullPtrLiteralExprClass:
case Stmt::CXXPseudoDestructorExprClass:
case Stmt::CXXTemporaryObjectExprClass:
break;
}
- case Stmt::CXXExprWithTemporariesClass: {
- const CXXExprWithTemporaries *expr = cast<CXXExprWithTemporaries>(Ex);
+ case Stmt::ExprWithCleanupsClass: {
+ const ExprWithCleanups *expr = cast<ExprWithCleanups>(Ex);
VisitLValue(expr->getSubExpr(), Pred, Dst);
break;
}
// llvm::StringRef x = call() (where call returns std::string)
if (!IsLLVMStringRef(VD->getType()))
return;
- CXXExprWithTemporaries *Ex1 = dyn_cast<CXXExprWithTemporaries>(Init);
+ ExprWithCleanups *Ex1 = dyn_cast<ExprWithCleanups>(Init);
if (!Ex1)
return;
CXXConstructExpr *Ex2 = dyn_cast<CXXConstructExpr>(Ex1->getSubExpr());
// Technically, the exception object is like a temporary; it has to
// be cleaned up when its full-expression is complete.
// Unfortunately, the AST represents full-expressions by creating a
- // CXXExprWithTemporaries, which it only does when there are actually
+ // ExprWithCleanups, which it only does when there are actually
// temporaries.
//
// If any cleanups have been added since we pushed ours, they must
if (const CXXDefaultArgExpr *DAE = dyn_cast<CXXDefaultArgExpr>(E))
E = DAE->getExpr();
- if (const CXXExprWithTemporaries *TE = dyn_cast<CXXExprWithTemporaries>(E)) {
+ if (const ExprWithCleanups *TE = dyn_cast<ExprWithCleanups>(E)) {
CodeGenFunction::RunCleanupsScope Scope(CGF);
return EmitExprForReferenceBinding(CGF, TE->getSubExpr(),
return EmitCXXConstructLValue(cast<CXXConstructExpr>(E));
case Expr::CXXBindTemporaryExprClass:
return EmitCXXBindTemporaryLValue(cast<CXXBindTemporaryExpr>(E));
- case Expr::CXXExprWithTemporariesClass:
- return EmitCXXExprWithTemporariesLValue(cast<CXXExprWithTemporaries>(E));
+ case Expr::ExprWithCleanupsClass:
+ return EmitExprWithCleanupsLValue(cast<ExprWithCleanups>(E));
case Expr::CXXScalarValueInitExprClass:
return EmitNullInitializationLValue(cast<CXXScalarValueInitExpr>(E));
case Expr::CXXDefaultArgExprClass:
}
void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E);
void VisitCXXConstructExpr(const CXXConstructExpr *E);
- void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
+ void VisitExprWithCleanups(ExprWithCleanups *E);
void VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E);
void VisitCXXTypeidExpr(CXXTypeidExpr *E) { EmitAggLoadOfLValue(E); }
CGF.EmitCXXConstructExpr(E, Slot);
}
-void AggExprEmitter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
- CGF.EmitCXXExprWithTemporaries(E, Dest);
+void AggExprEmitter::VisitExprWithCleanups(ExprWithCleanups *E) {
+ CGF.EmitExprWithCleanups(E, Dest);
}
void AggExprEmitter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
CodeGenFunction::EmitSynthesizedCXXCopyCtor(llvm::Value *Dest,
llvm::Value *Src,
const Expr *Exp) {
- if (const CXXExprWithTemporaries *E = dyn_cast<CXXExprWithTemporaries>(Exp))
+ if (const ExprWithCleanups *E = dyn_cast<ExprWithCleanups>(Exp))
Exp = E->getSubExpr();
assert(isa<CXXConstructExpr>(Exp) &&
"EmitSynthesizedCXXCopyCtor - unknown copy ctor expr");
ComplexPairTy VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
return Visit(DAE->getExpr());
}
- ComplexPairTy VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
- return CGF.EmitCXXExprWithTemporaries(E).getComplexVal();
+ ComplexPairTy VisitExprWithCleanups(ExprWithCleanups *E) {
+ return CGF.EmitExprWithCleanups(E).getComplexVal();
}
ComplexPairTy VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
assert(E->getType()->isAnyComplexType() && "Expected complex type!");
return CGF.LoadCXXThis();
}
- Value *VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
- return CGF.EmitCXXExprWithTemporaries(E).getScalarVal();
+ Value *VisitExprWithCleanups(ExprWithCleanups *E) {
+ return CGF.EmitExprWithCleanups(E).getScalarVal();
}
Value *VisitCXXNewExpr(const CXXNewExpr *E) {
return CGF.EmitCXXNewExpr(E);
}
RValue
-CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
- AggValueSlot Slot) {
+CodeGenFunction::EmitExprWithCleanups(const ExprWithCleanups *E,
+ AggValueSlot Slot) {
RunCleanupsScope Scope(*this);
return EmitAnyExpr(E->getSubExpr(), Slot);
}
-LValue CodeGenFunction::EmitCXXExprWithTemporariesLValue(
- const CXXExprWithTemporaries *E) {
+LValue CodeGenFunction::EmitExprWithCleanupsLValue(const ExprWithCleanups *E) {
RunCleanupsScope Scope(*this);
return EmitLValue(E->getSubExpr());
}
LValue EmitCXXConstructLValue(const CXXConstructExpr *E);
LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E);
- LValue EmitCXXExprWithTemporariesLValue(const CXXExprWithTemporaries *E);
+ LValue EmitExprWithCleanupsLValue(const ExprWithCleanups *E);
LValue EmitCXXTypeidLValue(const CXXTypeidExpr *E);
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E);
void EmitSynthesizedCXXCopyCtor(llvm::Value *Dest, llvm::Value *Src,
const Expr *Exp);
- RValue EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
- AggValueSlot Slot =AggValueSlot::ignored());
+ RValue EmitExprWithCleanups(const ExprWithCleanups *E,
+ AggValueSlot Slot =AggValueSlot::ignored());
void EmitCXXThrowExpr(const CXXThrowExpr *E);
mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
break;
- case Expr::CXXExprWithTemporariesClass:
- mangleExpression(cast<CXXExprWithTemporaries>(E)->getSubExpr(), Arity);
+ case Expr::ExprWithCleanupsClass:
+ mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
break;
case Expr::FloatingLiteralClass: {
}
// FIXME: Remove this hack once temporaries and their destructors are
// modeled correctly by the CFG.
- if (CXXExprWithTemporaries *E = dyn_cast<CXXExprWithTemporaries>(S)) {
+ if (ExprWithCleanups *E = dyn_cast<ExprWithCleanups>(S)) {
for (unsigned I = 0, N = E->getNumTemporaries(); I != N; ++I) {
const FunctionDecl *FD = E->getTemporary(I)->getDestructor();
if (FD->hasAttr<NoReturnAttr>() ||
SourceLocation(),
Owned(E));
if (!Res.isInvalid()) {
- Res = MaybeCreateCXXExprWithTemporaries(Res.get());
+ Res = MaybeCreateExprWithCleanups(Res.get());
Expr *Init = Res.takeAs<Expr>();
Context.setBlockVarCopyInits(NewVD, Init);
}
// Check any implicit conversions within the expression.
CheckImplicitConversions(Init, VDecl->getLocation());
- Init = MaybeCreateCXXExprWithTemporaries(Init);
+ Init = MaybeCreateExprWithCleanups(Init);
// Attach the initializer to the decl.
VDecl->setInit(Init);
if (Init.isInvalid())
Var->setInvalidDecl();
else if (Init.get()) {
- Var->setInit(MaybeCreateCXXExprWithTemporaries(Init.takeAs<Expr>()));
+ Var->setInit(MaybeCreateExprWithCleanups(Init.takeAs<Expr>()));
if (getLangOptions().CPlusPlus && !Var->isInvalidDecl() &&
Var->hasGlobalStorage() && !Var->isStaticLocal() &&
Arg = Result.takeAs<Expr>();
CheckImplicitConversions(Arg, EqualLoc);
- Arg = MaybeCreateCXXExprWithTemporaries(Arg);
+ Arg = MaybeCreateExprWithCleanups(Arg);
// Okay: add the default argument to the parameter
Param->setDefaultArg(Arg);
} else if (OldParam->hasDefaultArg()) {
// Merge the old default argument into the new parameter.
// It's important to use getInit() here; getDefaultArg()
- // strips off any top-level CXXExprWithTemporaries.
+ // strips off any top-level ExprWithCleanups.
NewParam->setHasInheritedDefaultArg();
if (OldParam->hasUninstantiatedDefaultArg())
NewParam->setUninstantiatedDefaultArg(
// C++0x [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
- MemberInit = MaybeCreateCXXExprWithTemporaries(MemberInit.get());
+ MemberInit = MaybeCreateExprWithCleanups(MemberInit.get());
if (MemberInit.isInvalid())
return true;
// C++0x [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
- BaseInit = MaybeCreateCXXExprWithTemporaries(BaseInit.get());
+ BaseInit = MaybeCreateExprWithCleanups(BaseInit.get());
if (BaseInit.isInvalid())
return true;
if (BaseInit.isInvalid())
return true;
- BaseInit = SemaRef.MaybeCreateCXXExprWithTemporaries(BaseInit.get());
+ BaseInit = SemaRef.MaybeCreateExprWithCleanups(BaseInit.get());
if (BaseInit.isInvalid())
return true;
ExprResult MemberInit
= InitSeq.Perform(SemaRef, Entities.back(), InitKind,
MultiExprArg(&CopyCtorArgE, 1));
- MemberInit = SemaRef.MaybeCreateCXXExprWithTemporaries(MemberInit.get());
+ MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit.get());
if (MemberInit.isInvalid())
return true;
if (MemberInit.isInvalid())
return true;
- MemberInit = SemaRef.MaybeCreateCXXExprWithTemporaries(MemberInit.get());
+ MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit.get());
if (MemberInit.isInvalid())
return true;
Expr *Temp = TempResult.takeAs<Expr>();
CheckImplicitConversions(Temp, VD->getLocation());
MarkDeclarationReferenced(VD->getLocation(), Constructor);
- Temp = MaybeCreateCXXExprWithTemporaries(Temp);
+ Temp = MaybeCreateExprWithCleanups(Temp);
VD->setInit(Temp);
return false;
CheckImplicitConversions(Result.get(), LParenLoc);
- Result = MaybeCreateCXXExprWithTemporaries(Result.get());
+ Result = MaybeCreateExprWithCleanups(Result.get());
VDecl->setInit(Result.takeAs<Expr>());
VDecl->setCXXDirectInitializer(true);
InitializationSequence InitSeq(*this, InitEntity, InitKind, 0, 0);
ExprResult MemberInit =
InitSeq.Perform(*this, InitEntity, InitKind, MultiExprArg());
- MemberInit = MaybeCreateCXXExprWithTemporaries(MemberInit.get());
+ MemberInit = MaybeCreateExprWithCleanups(MemberInit.get());
// Note, MemberInit could actually come back empty if no initialization
// is required (e.g., because it would call a trivial default constructor)
if (!MemberInit.get() || MemberInit.isInvalid())
SourceLocation(),
Owned(E));
if (!Res.isInvalid()) {
- Res = MaybeCreateCXXExprWithTemporaries(Res.get());
+ Res = MaybeCreateExprWithCleanups(Res.get());
Expr *Init = Res.takeAs<Expr>();
BDRE->setCopyConstructorExpr(Init);
}
return Owned(CXXBindTemporaryExpr::Create(Context, Temp, E));
}
-Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr) {
+Expr *Sema::MaybeCreateExprWithCleanups(Expr *SubExpr) {
assert(SubExpr && "sub expression can't be null!");
unsigned FirstTemporary = ExprEvalContexts.back().NumTemporaries;
if (ExprTemporaries.size() == FirstTemporary)
return SubExpr;
- Expr *E = CXXExprWithTemporaries::Create(Context, SubExpr,
- &ExprTemporaries[FirstTemporary],
- ExprTemporaries.size() - FirstTemporary);
+ Expr *E = ExprWithCleanups::Create(Context, SubExpr,
+ &ExprTemporaries[FirstTemporary],
+ ExprTemporaries.size() - FirstTemporary);
ExprTemporaries.erase(ExprTemporaries.begin() + FirstTemporary,
ExprTemporaries.end());
}
ExprResult
-Sema::MaybeCreateCXXExprWithTemporaries(ExprResult SubExpr) {
+Sema::MaybeCreateExprWithCleanups(ExprResult SubExpr) {
if (SubExpr.isInvalid())
return ExprError();
- return Owned(MaybeCreateCXXExprWithTemporaries(SubExpr.takeAs<Expr>()));
+ return Owned(MaybeCreateExprWithCleanups(SubExpr.take()));
}
FullExpr Sema::CreateFullExpr(Expr *SubExpr) {
return E;
}
-Stmt *Sema::MaybeCreateCXXStmtWithTemporaries(Stmt *SubStmt) {
+Stmt *Sema::MaybeCreateStmtWithCleanups(Stmt *SubStmt) {
assert(SubStmt && "sub statement can't be null!");
unsigned FirstTemporary = ExprEvalContexts.back().NumTemporaries;
SourceLocation());
Expr *E = new (Context) StmtExpr(CompStmt, Context.VoidTy, SourceLocation(),
SourceLocation());
- return MaybeCreateCXXExprWithTemporaries(E);
+ return MaybeCreateExprWithCleanups(E);
}
ExprResult
IgnoredValueConversions(FullExpr);
CheckImplicitConversions(FullExpr);
- return MaybeCreateCXXExprWithTemporaries(FullExpr);
+ return MaybeCreateExprWithCleanups(FullExpr);
}
StmtResult Sema::ActOnFinishFullStmt(Stmt *FullStmt) {
if (!FullStmt) return StmtError();
- return MaybeCreateCXXStmtWithTemporaries(FullStmt);
+ return MaybeCreateStmtWithCleanups(FullStmt);
}
if (!Res.isInvalid()) {
Expr *ResExpr = Res.takeAs<Expr>();
if (ResExpr)
- ResExpr = MaybeCreateCXXExprWithTemporaries(ResExpr);
+ ResExpr = MaybeCreateExprWithCleanups(ResExpr);
PIDecl->setGetterCXXConstructor(ResExpr);
}
}
// we might want to make a more specific diagnostic. Check for one of these
// cases now.
unsigned DiagID = diag::warn_unused_expr;
- if (const CXXExprWithTemporaries *Temps = dyn_cast<CXXExprWithTemporaries>(E))
+ if (const ExprWithCleanups *Temps = dyn_cast<ExprWithCleanups>(E))
E = Temps->getSubExpr();
E = E->IgnoreParenImpCasts();
if (!CondVar) {
CheckImplicitConversions(Cond, SwitchLoc);
- CondResult = MaybeCreateCXXExprWithTemporaries(Cond);
+ CondResult = MaybeCreateExprWithCleanups(Cond);
if (CondResult.isInvalid())
return StmtError();
Cond = CondResult.take();
return StmtError();
CheckImplicitConversions(Cond, DoLoc);
- ExprResult CondResult = MaybeCreateCXXExprWithTemporaries(Cond);
+ ExprResult CondResult = MaybeCreateExprWithCleanups(Cond);
if (CondResult.isInvalid())
return StmtError();
Cond = CondResult.take();
/// full-expression.
StmtResult Sema::ActOnForEachLValueExpr(Expr *E) {
CheckImplicitConversions(E);
- ExprResult Result = MaybeCreateCXXExprWithTemporaries(E);
+ ExprResult Result = MaybeCreateExprWithCleanups(E);
if (Result.isInvalid()) return StmtError();
return Owned(static_cast<Stmt*>(Result.get()));
}
if (RetValExp) {
CheckImplicitConversions(RetValExp, ReturnLoc);
- RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp);
+ RetValExp = MaybeCreateExprWithCleanups(RetValExp);
}
RetValExp = Res.takeAs<Expr>();
}
CheckImplicitConversions(RetValExp, ReturnLoc);
- RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp);
+ RetValExp = MaybeCreateExprWithCleanups(RetValExp);
}
Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, 0);
if (RetValExp) {
CheckImplicitConversions(RetValExp, ReturnLoc);
- RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp);
+ RetValExp = MaybeCreateExprWithCleanups(RetValExp);
}
Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, NRVOCandidate);
}
if (!Init)
return false;
- if (CXXExprWithTemporaries *ExprTemp = dyn_cast<CXXExprWithTemporaries>(Init))
+ if (ExprWithCleanups *ExprTemp = dyn_cast<ExprWithCleanups>(Init))
Init = ExprTemp->getSubExpr();
while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
return getDerived().TransformExpr(E->getSubExpr());
}
-/// \brief Transform a C++ expression that contains temporaries that should
-/// be destroyed after the expression is evaluated.
+/// \brief Transform a C++ expression that contains cleanups that should
+/// be run after the expression is evaluated.
///
-/// Since CXXExprWithTemporaries nodes are implicitly generated, we
+/// Since ExprWithCleanups nodes are implicitly generated, we
/// just transform the subexpression and return that.
template<typename Derived>
ExprResult
-TreeTransform<Derived>::TransformCXXExprWithTemporaries(
- CXXExprWithTemporaries *E) {
+TreeTransform<Derived>::TransformExprWithCleanups(ExprWithCleanups *E) {
return getDerived().TransformExpr(E->getSubExpr());
}
void VisitCXXDeleteExpr(CXXDeleteExpr *E);
void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
- void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
+ void VisitExprWithCleanups(ExprWithCleanups *E);
void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
}
-void ASTStmtReader::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
+void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
VisitExpr(E);
unsigned NumTemps = Record[Idx++];
if (NumTemps) {
S = new (Context) CXXPseudoDestructorExpr(Empty);
break;
- case EXPR_CXX_EXPR_WITH_TEMPORARIES:
- S = new (Context) CXXExprWithTemporaries(Empty);
+ case EXPR_EXPR_WITH_CLEANUPS:
+ S = new (Context) ExprWithCleanups(Empty);
break;
case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
void VisitCXXDeleteExpr(CXXDeleteExpr *E);
void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
- void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
+ void VisitExprWithCleanups(ExprWithCleanups *E);
void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
void VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E);
Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR;
}
-void ASTStmtWriter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
+void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups *E) {
VisitExpr(E);
Record.push_back(E->getNumTemporaries());
for (unsigned i = 0, e = E->getNumTemporaries(); i != e; ++i)
Writer.AddCXXTemporary(E->getTemporary(i), Record);
Writer.AddStmt(E->getSubExpr());
- Code = serialization::EXPR_CXX_EXPR_WITH_TEMPORARIES;
+ Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
}
void
case Stmt::UnaryTypeTraitExprClass:
case Stmt::DependentScopeDeclRefExprClass:
case Stmt::CXXBindTemporaryExprClass:
- case Stmt::CXXExprWithTemporariesClass:
+ case Stmt::ExprWithCleanupsClass:
case Stmt::CXXUnresolvedConstructExprClass:
case Stmt::CXXDependentScopeMemberExprClass:
case Stmt::UnresolvedMemberExprClass: