[cfe-commits] r124313 - in /cfe/trunk: include/clang/Sema/Overload.h lib/Sema/SemaOverload.cpp test/CXX/over/over.match/over.match.funcs/p4-0x.cpp

Douglas Gregor dgregor at apple.com
Wed Jan 26 11:41:18 PST 2011


Author: dgregor
Date: Wed Jan 26 13:41:18 2011
New Revision: 124313

URL: http://llvm.org/viewvc/llvm-project?rev=124313&view=rev
Log:
Rvalue references for *this: explicitly keep track of whether a
reference binding is for the implicit object parameter of a member
function with a ref-qualifier. My previous comment, that we didn't
need to track this explicitly, was wrong: we do in fact get
rvalue-references-prefer-rvalues overloading with ref-qualifiers.

Modified:
    cfe/trunk/include/clang/Sema/Overload.h
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=124313&r1=124312&r2=124313&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Wed Jan 26 13:41:18 2011
@@ -157,6 +157,10 @@
     /// \brief Whether we're binding to an rvalue.
     unsigned BindsToRvalue : 1;
     
+    /// \brief Whether this binds an implicit object argument to a 
+    /// non-static member function without a ref-qualifier.
+    unsigned BindsImplicitObjectArgumentWithoutRefQualifier : 1;
+    
     /// FromType - The type that this conversion is converting
     /// from. This is an opaque pointer that can be translated into a
     /// QualType.

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=124313&r1=124312&r2=124313&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 26 13:41:18 2011
@@ -173,6 +173,7 @@
   IsLvalueReference = true;
   BindsToFunctionLvalue = false;
   BindsToRvalue = false;
+  BindsImplicitObjectArgumentWithoutRefQualifier = false;
   CopyConstructor = 0;
 }
 
@@ -2344,11 +2345,10 @@
   // time of this writing) break the standard definition of std::forward
   // and std::reference_wrapper when dealing with references to functions.
   // Proposed wording changes submitted to CWG for consideration.
-  //
-  // Note: neither of these conditions will evalute true for the implicit 
-  // object parameter, because we don't set either BindsToRvalue or
-  // BindsToFunctionLvalue when computing the conversion sequence for the
-  // implicit object parameter.
+  if (SCS1.BindsImplicitObjectArgumentWithoutRefQualifier ||
+      SCS2.BindsImplicitObjectArgumentWithoutRefQualifier)
+    return false;
+  
   return (!SCS1.IsLvalueReference && SCS1.BindsToRvalue &&
           SCS2.IsLvalueReference) ||
          (SCS1.IsLvalueReference && SCS1.BindsToFunctionLvalue &&
@@ -2994,6 +2994,7 @@
       ICS.Standard.IsLvalueReference = !isRValRef;
       ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType();
       ICS.Standard.BindsToRvalue = false;
+      ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false;
       ICS.Standard.CopyConstructor = 0;
 
       // Nothing more to do: the inaccessibility/ambiguity check for
@@ -3066,6 +3067,7 @@
     ICS.Standard.IsLvalueReference = !isRValRef;
     ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType();
     ICS.Standard.BindsToRvalue = InitCategory.isRValue();        
+    ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false;
     ICS.Standard.CopyConstructor = 0;
     return ICS; 
   }
@@ -3146,11 +3148,13 @@
     ICS.Standard.IsLvalueReference = !isRValRef;
     ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType();
     ICS.Standard.BindsToRvalue = true;
+    ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false;
   } else if (ICS.isUserDefined()) {
     ICS.UserDefined.After.ReferenceBinding = true;
     ICS.Standard.IsLvalueReference = !isRValRef;
     ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType();
     ICS.Standard.BindsToRvalue = true;
+    ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false;
   }
 
   return ICS;
@@ -3286,9 +3290,9 @@
   ICS.Standard.DirectBinding = true;
   ICS.Standard.IsLvalueReference = Method->getRefQualifier() != RQ_RValue; 
   ICS.Standard.BindsToFunctionLvalue = false;
-  
-  // Note: we intentionally don't set this; see isBetterReferenceBindingKind().
-  ICS.Standard.BindsToRvalue = false;
+  ICS.Standard.BindsToRvalue = FromClassification.isRValue();
+  ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier
+    = (Method->getRefQualifier() == RQ_None);
   return ICS;
 }
 

Modified: cfe/trunk/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp?rev=124313&r1=124312&r2=124313&view=diff
==============================================================================
--- cfe/trunk/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp (original)
+++ cfe/trunk/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp Wed Jan 26 13:41:18 2011
@@ -27,6 +27,8 @@
 
   int &h() const&;
   float &h() &&;
+  int &h2() const&;
+  float &h2() const&&;
 };
 
 void X0::g() {
@@ -62,4 +64,7 @@
   int &ir1 = lvalue<X0>().h();
   float &fr1 = xvalue<X0>().h();
   float &fr2 = prvalue<X0>().h();
+  int &ir2 = lvalue<X0>().h2();
+  float &fr3 = xvalue<X0>().h2();
+  float &fr4 = prvalue<X0>().h2();
 }





More information about the cfe-commits mailing list