[cfe-commits] r91450 - in /cfe/trunk: include/clang/AST/ExprCXX.h lib/AST/ExprCXX.cpp lib/AST/StmtProfile.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGTemporaries.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaStmt.cpp lib/Sema/TreeTransform.h
Anders Carlsson
andersca at mac.com
Tue Dec 15 12:51:39 PST 2009
Author: andersca
Date: Tue Dec 15 14:51:39 2009
New Revision: 91450
URL: http://llvm.org/viewvc/llvm-project?rev=91450&view=rev
Log:
ShouldDestroyTemporaries? I don't think so.
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGTemporaries.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Dec 15 14:51:39 2009
@@ -1264,10 +1264,8 @@
CXXTemporary **Temps;
unsigned NumTemps;
- bool ShouldDestroyTemps;
-
CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
- unsigned NumTemps, bool ShouldDestroyTemps);
+ unsigned NumTemps);
~CXXExprWithTemporaries();
protected:
@@ -1275,8 +1273,8 @@
public:
static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
- CXXTemporary **Temps, unsigned NumTemps,
- bool ShouldDestroyTemporaries);
+ CXXTemporary **Temps,
+ unsigned NumTemps);
unsigned getNumTemporaries() const { return NumTemps; }
CXXTemporary *getTemporary(unsigned i) {
@@ -1284,14 +1282,9 @@
return Temps[i];
}
const CXXTemporary *getTemporary(unsigned i) const {
- assert(i < NumTemps && "Index out of range");
- return Temps[i];
+ return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
}
- bool shouldDestroyTemporaries() const { return ShouldDestroyTemps; }
-
- void removeLastTemporary() { NumTemps--; }
-
Expr *getSubExpr() { return cast<Expr>(SubExpr); }
const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
void setSubExpr(Expr *E) { SubExpr = E; }
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Dec 15 14:51:39 2009
@@ -420,12 +420,10 @@
CXXExprWithTemporaries::CXXExprWithTemporaries(Expr *subexpr,
CXXTemporary **temps,
- unsigned numtemps,
- bool shoulddestroytemps)
+ unsigned numtemps)
: Expr(CXXExprWithTemporariesClass, subexpr->getType(),
subexpr->isTypeDependent(), subexpr->isValueDependent()),
- SubExpr(subexpr), Temps(0), NumTemps(numtemps),
- ShouldDestroyTemps(shoulddestroytemps) {
+ SubExpr(subexpr), Temps(0), NumTemps(numtemps) {
if (NumTemps > 0) {
Temps = new CXXTemporary*[NumTemps];
for (unsigned i = 0; i < NumTemps; ++i)
@@ -436,10 +434,8 @@
CXXExprWithTemporaries *CXXExprWithTemporaries::Create(ASTContext &C,
Expr *SubExpr,
CXXTemporary **Temps,
- unsigned NumTemps,
- bool ShouldDestroyTemps){
- return new (C) CXXExprWithTemporaries(SubExpr, Temps, NumTemps,
- ShouldDestroyTemps);
+ unsigned NumTemps) {
+ return new (C) CXXExprWithTemporaries(SubExpr, Temps, NumTemps);
}
void CXXExprWithTemporaries::DoDestroy(ASTContext &C) {
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Tue Dec 15 14:51:39 2009
@@ -540,7 +540,6 @@
void StmtProfiler::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *S) {
VisitExpr(S);
- ID.AddBoolean(S->shouldDestroyTemporaries());
for (unsigned I = 0, N = S->getNumTemporaries(); I != N; ++I)
VisitDecl(
const_cast<CXXDestructorDecl *>(S->getTemporary(I)->getDestructor()));
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Dec 15 14:51:39 2009
@@ -99,11 +99,10 @@
unsigned OldNumLiveTemporaries = 0;
if (const CXXExprWithTemporaries *TE = dyn_cast<CXXExprWithTemporaries>(E)) {
- ShouldDestroyTemporaries = TE->shouldDestroyTemporaries();
-
+ ShouldDestroyTemporaries = true;
+
// Keep track of the current cleanup stack depth.
- if (ShouldDestroyTemporaries)
- OldNumLiveTemporaries = LiveTemporaries.size();
+ OldNumLiveTemporaries = LiveTemporaries.size();
E = TE->getSubExpr();
}
Modified: cfe/trunk/lib/CodeGen/CGTemporaries.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGTemporaries.cpp?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGTemporaries.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGTemporaries.cpp Tue Dec 15 14:51:39 2009
@@ -92,12 +92,6 @@
llvm::Value *AggLoc,
bool IsAggLocVolatile,
bool IsInitializer) {
- // If we shouldn't destroy the temporaries, just emit the
- // child expression.
- if (!E->shouldDestroyTemporaries())
- return EmitAnyExpr(E->getSubExpr(), AggLoc, IsAggLocVolatile,
- /*IgnoreResult=*/false, IsInitializer);
-
// Keep track of the current cleanup stack depth.
size_t CleanupStackDepth = CleanupEntries.size();
(void) CleanupStackDepth;
@@ -119,11 +113,6 @@
LValue CodeGenFunction::EmitCXXExprWithTemporariesLValue(
const CXXExprWithTemporaries *E) {
- // If we shouldn't destroy the temporaries, just emit the
- // child expression.
- if (!E->shouldDestroyTemporaries())
- return EmitLValue(E->getSubExpr());
-
// Keep track of the current cleanup stack depth.
size_t CleanupStackDepth = CleanupEntries.size();
(void) CleanupStackDepth;
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Dec 15 14:51:39 2009
@@ -2003,8 +2003,7 @@
/// 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,
- bool ShouldDestroyTemporaries);
+ Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr);
virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr);
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec 15 14:51:39 2009
@@ -3622,8 +3622,7 @@
Init->setType(DclT);
}
- Init = MaybeCreateCXXExprWithTemporaries(Init,
- /*ShouldDestroyTemporaries=*/true);
+ Init = MaybeCreateCXXExprWithTemporaries(Init);
// Attach the initializer to the decl.
VDecl->setInit(Context, Init);
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Dec 15 14:51:39 2009
@@ -129,7 +129,7 @@
Param->getDeclName(), /*DirectInit=*/false))
return true;
- Arg = MaybeCreateCXXExprWithTemporaries(Arg, /*DestroyTemps=*/false);
+ Arg = MaybeCreateCXXExprWithTemporaries(Arg);
// Okay: add the default argument to the parameter
Param->setDefaultArg(Arg);
@@ -3806,7 +3806,7 @@
Expr *Temp = TempResult.takeAs<Expr>();
MarkDeclarationReferenced(VD->getLocation(), Constructor);
- Temp = MaybeCreateCXXExprWithTemporaries(Temp, /*DestroyTemps=*/true);
+ Temp = MaybeCreateCXXExprWithTemporaries(Temp);
VD->setInit(Context, Temp);
return false;
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Dec 15 14:51:39 2009
@@ -2089,8 +2089,7 @@
return Owned(CXXBindTemporaryExpr::Create(Context, Temp, E));
}
-Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr,
- bool ShouldDestroyTemps) {
+Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr) {
assert(SubExpr && "sub expression can't be null!");
unsigned FirstTemporary = ExprEvalContexts.back().NumTemporaries;
@@ -2100,8 +2099,7 @@
Expr *E = CXXExprWithTemporaries::Create(Context, SubExpr,
&ExprTemporaries[FirstTemporary],
- ExprTemporaries.size() - FirstTemporary,
- ShouldDestroyTemps);
+ ExprTemporaries.size() - FirstTemporary);
ExprTemporaries.erase(ExprTemporaries.begin() + FirstTemporary,
ExprTemporaries.end());
@@ -2243,9 +2241,7 @@
Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) {
Expr *FullExpr = Arg.takeAs<Expr>();
if (FullExpr)
- FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr,
- /*ShouldDestroyTemps=*/true);
-
+ FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr);
return Owned(FullExpr);
}
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Dec 15 14:51:39 2009
@@ -1053,7 +1053,7 @@
<< RetValExp->getSourceRange();
}
- RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp, true);
+ RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp);
}
return Owned(new (Context) ReturnStmt(ReturnLoc, RetValExp));
}
@@ -1098,7 +1098,7 @@
// FIXME: Leaks RetValExp on error.
if (PerformCopyInitialization(RetValExp, FnRetType, "returning", Elidable)){
// We should still clean up our temporaries, even when we're failing!
- RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp, true);
+ RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp);
return StmtError();
}
@@ -1106,7 +1106,7 @@
}
if (RetValExp)
- RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp, true);
+ RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp);
return Owned(new (Context) ReturnStmt(ReturnLoc, RetValExp));
}
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=91450&r1=91449&r2=91450&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Dec 15 14:51:39 2009
@@ -4755,8 +4755,7 @@
return SemaRef.ExprError();
return SemaRef.Owned(
- SemaRef.MaybeCreateCXXExprWithTemporaries(SubExpr.takeAs<Expr>(),
- E->shouldDestroyTemporaries()));
+ SemaRef.MaybeCreateCXXExprWithTemporaries(SubExpr.takeAs<Expr>()));
}
template<typename Derived>
More information about the cfe-commits
mailing list