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
This commit is contained in:
Douglas Gregor 2010-12-07 00:41:46 +00:00
Родитель 7ee90d0d9e
Коммит 53c374f1ac
3 изменённых файлов: 10 добавлений и 15 удалений

Просмотреть файл

@ -3037,7 +3037,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
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 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl,
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() &&

Просмотреть файл

@ -1327,7 +1327,7 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr **Args,
// 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 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo,
// 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 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
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 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
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 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
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 @@ void Sema::AddCXXDirectInitializerToDecl(Decl *RealDecl,
CheckImplicitConversions(Result.get(), LParenLoc);
Result = MaybeCreateExprWithCleanups(Result.get());
Result = MaybeCreateExprWithCleanups(Result);
VDecl->setInit(Result.takeAs<Expr>());
VDecl->setCXXDirectInitializer(true);
@ -7037,7 +7032,7 @@ void Sema::SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation) {
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())

Просмотреть файл

@ -2278,7 +2278,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
SourceLocation(),
Owned(E));
if (!Res.isInvalid()) {
Res = MaybeCreateExprWithCleanups(Res.get());
Res = MaybeCreateExprWithCleanups(Res);
Expr *Init = Res.takeAs<Expr>();
BDRE->setCopyConstructorExpr(Init);
}