r225684 - reverting due to build bot failure

Nathan Sidwell nathan at acm.org
Mon Jan 12 12:13:20 PST 2015


Author: nathan
Date: Mon Jan 12 14:13:20 2015
New Revision: 225684

URL: http://llvm.org/viewvc/llvm-project?rev=225684&view=rev
Log:
reverting due to build bot failure

Modified:
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=225684&r1=225683&r2=225684&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Jan 12 14:13:20 2015
@@ -3136,16 +3136,34 @@ static bool AdjustFunctionParmAndArgType
   //   are ignored for type deduction.
   if (ParamType.hasQualifiers())
     ParamType = ParamType.getUnqualifiedType();
-
-  //   [...] If P is a reference type, the type referred to by P is
-  //   used for type deduction.
   const ReferenceType *ParamRefType = ParamType->getAs<ReferenceType>();
-  if (ParamRefType)
-    ParamType = ParamRefType->getPointeeType();
+  if (ParamRefType) {
+    QualType PointeeType = ParamRefType->getPointeeType();
+
+    // If the argument has incomplete array type, try to complete its type.
+    if (ArgType->isIncompleteArrayType() && !S.RequireCompleteExprType(Arg, 0))
+      ArgType = Arg->getType();
+
+    //   [C++0x] If P is an rvalue reference to a cv-unqualified
+    //   template parameter and the argument is an lvalue, the type
+    //   "lvalue reference to A" is used in place of A for type
+    //   deduction.
+    if (isa<RValueReferenceType>(ParamType)) {
+      if (!PointeeType.getQualifiers() &&
+          isa<TemplateTypeParmType>(PointeeType) &&
+          Arg->Classify(S.Context).isLValue() &&
+          Arg->getType() != S.Context.OverloadTy &&
+          Arg->getType() != S.Context.BoundMemberTy)
+        ArgType = S.Context.getLValueReferenceType(ArgType);
+    }
 
-  // Overload sets usually make this parameter an undeduced context,
-  // but there are sometimes special circumstances.  Typically
-  // involving a template-id-expr.
+    //   [...] If P is a reference type, the type referred to by P is used
+    //   for type deduction.
+    ParamType = PointeeType;
+  }
+
+  // Overload sets usually make this parameter an undeduced
+  // context, but there are sometimes special circumstances.
   if (ArgType == S.Context.OverloadTy) {
     ArgType = ResolveOverloadForDeduction(S, TemplateParams,
                                           Arg, ParamType,
@@ -3155,17 +3173,12 @@ static bool AdjustFunctionParmAndArgType
   }
 
   if (ParamRefType) {
-    // If the argument has incomplete array type, try to complete its type.
-    if (ArgType->isIncompleteArrayType() && !S.RequireCompleteExprType(Arg, 0))
-      ArgType = Arg->getType();
-
     // C++0x [temp.deduct.call]p3:
-    //   If P is an rvalue reference to a cv-unqualified template
-    //   parameter and the argument is an lvalue, the type "lvalue
-    //   reference to A" is used in place of A for type deduction.
+    //   [...] If P is of the form T&&, where T is a template parameter, and
+    //   the argument is an lvalue, the type A& is used in place of A for
+    //   type deduction.
     if (ParamRefType->isRValueReferenceType() &&
-        !ParamType.getQualifiers() &&
-        isa<TemplateTypeParmType>(ParamType) &&
+        ParamRefType->getAs<TemplateTypeParmType>() &&
         Arg->isLValue())
       ArgType = S.Context.getLValueReferenceType(ArgType);
   } else {

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=225684&r1=225683&r2=225684&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Mon Jan 12 14:13:20 2015
@@ -202,8 +202,3 @@ namespace PR19372 {
     using T = S<int, int>;
   }
 }
-
-namespace PR18645 {
-  template<typename F> F Quux(F &&f);
-  auto Baz = Quux(Quux<float>);
-}





More information about the cfe-commits mailing list