[cfe-commits] r135175 - in /cfe/trunk: include/clang/Sema/Initialization.h lib/Sema/SemaInit.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Thu Jul 14 12:07:56 PDT 2011


Author: cornedbee
Date: Thu Jul 14 14:07:55 2011
New Revision: 135175

URL: http://llvm.org/viewvc/llvm-project?rev=135175&view=rev
Log:
Remove InitializationSequence::ReferenceBinding, the last redundant sequence kind.

Modified:
    cfe/trunk/include/clang/Sema/Initialization.h
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=135175&r1=135174&r2=135175&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Thu Jul 14 14:07:55 2011
@@ -491,10 +491,7 @@
     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

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=135175&r1=135174&r2=135175&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Jul 14 14:07:55 2011
@@ -2155,7 +2155,7 @@
 }
 
 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 @@
                                        const InitializationKind &Kind,
                                        Expr *Initializer,
                                        InitializationSequence &Sequence) {
-  Sequence.setSequenceKind(InitializationSequence::ReferenceBinding);
-
   QualType DestType = Entity.getType();
   QualType cv1T1 = DestType->getAs<ReferenceType>()->getPointeeType();
   Qualifiers T1Quals;
@@ -3892,6 +3890,11 @@
   }
 }
 
+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 @@
         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<Expr>());
       else if (CreatedObject && shouldDestroyTemporary(Entity)) {
@@ -4866,10 +4868,6 @@
   case NormalSequence:
     OS << "Normal sequence: ";
     break;
-
-  case ReferenceBinding:
-    OS << "Reference binding: ";
-    break;
   }
 
   for (step_iterator S = step_begin(), SEnd = step_end(); S != SEnd; ++S) {





More information about the cfe-commits mailing list