From: Sebastian Redl Date: Sun, 5 Jun 2011 12:23:28 +0000 (+0000) Subject: Remove all references to InitializationSequence::FailedSequence from outside SemaInit... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=383616cd2e61131a534afd9364ef53f643e1f834;p=clang Remove all references to InitializationSequence::FailedSequence from outside SemaInit.cpp. Replace them with the boolean conversion or the new Failed() function. This is a first step towards removing InitializationSequence::SequenceKind. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132664 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Initialization.h b/include/clang/Sema/Initialization.h index b64a63fb69..3aee66c89f 100644 --- a/include/clang/Sema/Initialization.h +++ b/include/clang/Sema/Initialization.h @@ -699,6 +699,9 @@ public: /// \brief Determine whether the initialization sequence is valid. operator bool() const { return SequenceKind != FailedSequence; } + + /// \brief Determine whether the initialization sequence is invalid. + bool Failed() const { return SequenceKind == FailedSequence; } typedef llvm::SmallVector::const_iterator step_iterator; step_iterator step_begin() const { return Steps.begin(); } diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 32fd0be375..e46ad5bcfe 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -252,8 +252,7 @@ static bool tryDiagnoseOverloadedCast(Sema &S, CastType CT, (CT == CT_CStyle || CT == CT_Functional)); InitializationSequence sequence(S, entity, initKind, &src, 1); - assert(sequence.getKind() == InitializationSequence::FailedSequence && - "initialization succeeded on second try?"); + assert(sequence.Failed() && "initialization succeeded on second try?"); switch (sequence.getFailureKind()) { default: return false; @@ -1195,8 +1194,7 @@ TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, // On the other hand, if we're checking a C-style cast, we've still got // the reinterpret_cast way. - if (InitSeq.getKind() == InitializationSequence::FailedSequence && - (CStyle || !DestType->isReferenceType())) + if (InitSeq.Failed() && (CStyle || !DestType->isReferenceType())) return TC_NotApplicable; ExprResult Result diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 2fd4cf58ca..18a73666b3 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3350,7 +3350,7 @@ bool Sema::ShouldDeleteDefaultConstructor(CXXConstructorDecl *CD) { InitializationSequence InitSeq(*this, BaseEntity, Kind, 0, 0); - if (InitSeq.getKind() == InitializationSequence::FailedSequence) + if (InitSeq.Failed()) return true; } @@ -3380,7 +3380,7 @@ bool Sema::ShouldDeleteDefaultConstructor(CXXConstructorDecl *CD) { InitializationSequence InitSeq(*this, BaseEntity, Kind, 0, 0); - if (InitSeq.getKind() == InitializationSequence::FailedSequence) + if (InitSeq.Failed()) return true; } @@ -3462,7 +3462,7 @@ bool Sema::ShouldDeleteDefaultConstructor(CXXConstructorDecl *CD) { InitializationSequence InitSeq(*this, MemberEntity, Kind, 0, 0); - if (InitSeq.getKind() == InitializationSequence::FailedSequence) + if (InitSeq.Failed()) return true; } @@ -3537,7 +3537,7 @@ bool Sema::ShouldDeleteCopyConstructor(CXXConstructorDecl *CD) { InitializationSequence InitSeq(*this, BaseEntity, Kind, &Arg, 1); - if (InitSeq.getKind() == InitializationSequence::FailedSequence) + if (InitSeq.Failed()) return true; } @@ -3574,7 +3574,7 @@ bool Sema::ShouldDeleteCopyConstructor(CXXConstructorDecl *CD) { InitializationSequence InitSeq(*this, BaseEntity, Kind, &Arg, 1); - if (InitSeq.getKind() == InitializationSequence::FailedSequence) + if (InitSeq.Failed()) return true; } @@ -3651,7 +3651,7 @@ bool Sema::ShouldDeleteCopyConstructor(CXXConstructorDecl *CD) { InitializationSequence InitSeq(*this, Entities.back(), Kind, &Arg, 1); - if (InitSeq.getKind() == InitializationSequence::FailedSequence) + if (InitSeq.Failed()) return true; } diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 3631fcff53..af30061e28 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2889,7 +2889,7 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT, Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true); Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl()); InitializationSequence Init(Self, To, Kind, &FromPtr, 1); - if (Init.getKind() == InitializationSequence::FailedSequence) + if (Init.Failed()) return false; ExprResult Result = Init.Perform(Self, To, Kind, MultiExprArg(&FromPtr, 1)); @@ -3250,7 +3250,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, if (TTy.isAtLeastAsQualifiedAs(FTy)) { InitializedEntity Entity = InitializedEntity::InitializeTemporary(TTy); InitializationSequence InitSeq(Self, Entity, Kind, &From, 1); - if (InitSeq.getKind() != InitializationSequence::FailedSequence) { + if (InitSeq) { HaveConversion = true; return false; } @@ -3275,7 +3275,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, InitializedEntity Entity = InitializedEntity::InitializeTemporary(TTy); InitializationSequence InitSeq(Self, Entity, Kind, &From, 1); - HaveConversion = InitSeq.getKind() != InitializationSequence::FailedSequence; + HaveConversion = !InitSeq.Failed(); ToType = TTy; if (InitSeq.isAmbiguous()) return InitSeq.Diagnose(Self, Entity, Kind, &From, 1); diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index cfa8f33fad..d9ceb352b7 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -4735,7 +4735,7 @@ Sema::CanPerformCopyInitialization(const InitializedEntity &Entity, InitializationKind Kind = InitializationKind::CreateCopy(SourceLocation(), SourceLocation()); InitializationSequence Seq(*this, Entity, Kind, &InitE, 1); - return Seq.getKind() != InitializationSequence::FailedSequence; + return !Seq.Failed(); } ExprResult diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index d3a22cdbb9..d4fc980e22 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -1531,12 +1531,11 @@ Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity, // parameter of the selected constructor is not an rvalue reference // to the object's type (possibly cv-qualified), overload resolution // is performed again, considering the object as an lvalue. - if (Seq.getKind() != InitializationSequence::FailedSequence) { + if (Seq) { for (InitializationSequence::step_iterator Step = Seq.step_begin(), StepEnd = Seq.step_end(); Step != StepEnd; ++Step) { - if (Step->Kind - != InitializationSequence::SK_ConstructorInitialization) + if (Step->Kind != InitializationSequence::SK_ConstructorInitialization) continue; CXXConstructorDecl *Constructor