Use Sema::MaybeCreateExprWithCleanups() only after we've checked for a NULL/invalid expression
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121081 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index aa2e2a5..88512af 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3037,7 +3037,7 @@
SourceLocation(),
Owned(E));
if (!Res.isInvalid()) {
- Res = MaybeCreateExprWithCleanups(Res.get());
+ Res = MaybeCreateExprWithCleanups(Res);
Expr *Init = Res.takeAs<Expr>();
Context.setBlockVarCopyInits(NewVD, Init);
}
@@ -4805,7 +4805,7 @@
if (Init.isInvalid())
Var->setInvalidDecl();
else if (Init.get()) {
- Var->setInit(MaybeCreateExprWithCleanups(Init.takeAs<Expr>()));
+ Var->setInit(MaybeCreateExprWithCleanups(Init.get()));
if (getLangOptions().CPlusPlus && !Var->isInvalidDecl() &&
Var->hasGlobalStorage() && !Var->isStaticLocal() &&
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 02688b8..781d2b8 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1327,7 +1327,7 @@
// C++0x [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
- MemberInit = MaybeCreateExprWithCleanups(MemberInit.get());
+ MemberInit = MaybeCreateExprWithCleanups(MemberInit);
if (MemberInit.isInvalid())
return true;
@@ -1459,7 +1459,7 @@
// C++0x [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
- BaseInit = MaybeCreateExprWithCleanups(BaseInit.get());
+ BaseInit = MaybeCreateExprWithCleanups(BaseInit);
if (BaseInit.isInvalid())
return true;
@@ -1552,10 +1552,7 @@
assert(false && "Unhandled initializer kind!");
}
- if (BaseInit.isInvalid())
- return true;
-
- BaseInit = SemaRef.MaybeCreateExprWithCleanups(BaseInit.get());
+ BaseInit = SemaRef.MaybeCreateExprWithCleanups(BaseInit);
if (BaseInit.isInvalid())
return true;
@@ -1669,7 +1666,7 @@
ExprResult MemberInit
= InitSeq.Perform(SemaRef, Entities.back(), InitKind,
MultiExprArg(&CopyCtorArgE, 1));
- MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit.get());
+ MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit);
if (MemberInit.isInvalid())
return true;
@@ -1694,10 +1691,8 @@
InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, 0, 0);
ExprResult MemberInit =
InitSeq.Perform(SemaRef, InitEntity, InitKind, MultiExprArg());
- if (MemberInit.isInvalid())
- return true;
- MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit.get());
+ MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit);
if (MemberInit.isInvalid())
return true;
@@ -5547,7 +5542,7 @@
CheckImplicitConversions(Result.get(), LParenLoc);
- Result = MaybeCreateExprWithCleanups(Result.get());
+ Result = MaybeCreateExprWithCleanups(Result);
VDecl->setInit(Result.takeAs<Expr>());
VDecl->setCXXDirectInitializer(true);
@@ -7037,7 +7032,7 @@
InitializationSequence InitSeq(*this, InitEntity, InitKind, 0, 0);
ExprResult MemberInit =
InitSeq.Perform(*this, InitEntity, InitKind, MultiExprArg());
- MemberInit = MaybeCreateExprWithCleanups(MemberInit.get());
+ MemberInit = MaybeCreateExprWithCleanups(MemberInit);
// 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())
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index a1ea57e..9038750 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2278,7 +2278,7 @@
SourceLocation(),
Owned(E));
if (!Res.isInvalid()) {
- Res = MaybeCreateExprWithCleanups(Res.get());
+ Res = MaybeCreateExprWithCleanups(Res);
Expr *Init = Res.takeAs<Expr>();
BDRE->setCopyConstructorExpr(Init);
}