From 3b80232b50c29b245e674f5aa02047b408e41018 Mon Sep 17 00:00:00 2001 From: Sebastian Redl Date: Thu, 14 Jul 2011 19:07:55 +0000 Subject: [PATCH] Remove InitializationSequence::ReferenceBinding, the last redundant sequence kind. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135175 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Initialization.h | 5 +---- lib/Sema/SemaInit.cpp | 16 +++++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/include/clang/Sema/Initialization.h b/include/clang/Sema/Initialization.h index b86dbf0196..df6138c7f0 100644 --- a/include/clang/Sema/Initialization.h +++ b/include/clang/Sema/Initialization.h @@ -491,10 +491,7 @@ public: DependentSequence, /// \brief A normal sequence. - NormalSequence, - - /// \brief A reference binding. - ReferenceBinding // FIXME: Still looks redundant, but complicated. + NormalSequence }; /// \brief Describes the kind of a particular step in an initialization diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 58565af9ce..835d837e4c 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -2155,7 +2155,7 @@ void InitializationSequence::Step::Destroy() { } bool InitializationSequence::isDirectReferenceBinding() const { - return getKind() == ReferenceBinding && Steps.back().Kind == SK_BindReference; + return !Steps.empty() && Steps.back().Kind == SK_BindReference; } bool InitializationSequence::isAmbiguous() const { @@ -2622,8 +2622,6 @@ static void TryReferenceInitialization(Sema &S, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence) { - Sequence.setSequenceKind(InitializationSequence::ReferenceBinding); - QualType DestType = Entity.getType(); QualType cv1T1 = DestType->getAs()->getPointeeType(); Qualifiers T1Quals; @@ -3892,6 +3890,11 @@ void InitializationSequence::PrintInitLocationNote(Sema &S, } } +static bool isReferenceBinding(const InitializationSequence::Step &s) { + return s.Kind == InitializationSequence::SK_BindReference || + s.Kind == InitializationSequence::SK_BindReferenceToTemporary; +} + ExprResult InitializationSequence::Perform(Sema &S, const InitializedEntity &Entity, @@ -4187,8 +4190,7 @@ InitializationSequence::Perform(Sema &S, CreatedObject = Conversion->getResultType()->isRecordType(); } - bool RequiresCopy = !IsCopy && - getKind() != InitializationSequence::ReferenceBinding; + bool RequiresCopy = !IsCopy && !isReferenceBinding(Steps.back()); if (RequiresCopy || shouldBindAsTemporary(Entity)) CurInit = S.MaybeBindToTemporary(CurInit.takeAs()); else if (CreatedObject && shouldDestroyTemporary(Entity)) { @@ -4866,10 +4868,6 @@ void InitializationSequence::dump(llvm::raw_ostream &OS) const { case NormalSequence: OS << "Normal sequence: "; break; - - case ReferenceBinding: - OS << "Reference binding: "; - break; } for (step_iterator S = step_begin(), SEnd = step_end(); S != SEnd; ++S) { -- 2.40.0