[llvm-branch-commits] [cfe-branch] r119262 - in /cfe/branches/Apple/whitney: lib/Sema/SemaTemplateDeduction.cpp test/CXX/over/over.match/over.match.funcs/p4.cpp
Daniel Dunbar
daniel at zuster.org
Mon Nov 15 13:46:51 PST 2010
Author: ddunbar
Date: Mon Nov 15 15:46:51 2010
New Revision: 119262
URL: http://llvm.org/viewvc/llvm-project?rev=119262&view=rev
Log:
Merge r118944:
--
Author: Douglas Gregor <dgregor at apple.com>
Date: Fri Nov 12 23:44:13 2010 +0000
Implement C++ [over.match.funcs]p4 as it concerns partial ordering of
function templates. Fixes PR8130.
Added:
cfe/branches/Apple/whitney/test/CXX/over/over.match/over.match.funcs/p4.cpp
Modified:
cfe/branches/Apple/whitney/lib/Sema/SemaTemplateDeduction.cpp
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaTemplateDeduction.cpp?rev=119262&r1=119261&r2=119262&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaTemplateDeduction.cpp Mon Nov 15 15:46:51 2010
@@ -2124,7 +2124,31 @@
bool OnlyDeduced,
unsigned Level,
llvm::SmallVectorImpl<bool> &Deduced);
-
+
+/// \brief If this is a non-static member function,
+static void MaybeAddImplicitObjectParameterType(ASTContext &Context,
+ CXXMethodDecl *Method,
+ llvm::SmallVectorImpl<QualType> &ArgTypes) {
+ if (Method->isStatic())
+ return;
+
+ // C++ [over.match.funcs]p4:
+ //
+ // For non-static member functions, the type of the implicit
+ // object parameter is
+ // â "lvalue reference to cv X" for functions declared without a
+ // ref-qualifier or with the & ref-qualifier
+ // - "rvalue reference to cv X" for functions declared with the
+ // && ref-qualifier
+ //
+ // FIXME: We don't have ref-qualifiers yet, so we don't do that part.
+ QualType ArgTy = Context.getTypeDeclType(Method->getParent());
+ ArgTy = Context.getQualifiedType(ArgTy,
+ Qualifiers::fromCVRMask(Method->getTypeQualifiers()));
+ ArgTy = Context.getLValueReferenceType(ArgTy);
+ ArgTypes.push_back(ArgTy);
+}
+
/// \brief Determine whether the function template \p FT1 is at least as
/// specialized as \p FT2.
static bool isAtLeastAsSpecializedAs(Sema &S,
@@ -2151,12 +2175,24 @@
case TPOC_Call: {
// - In the context of a function call, the function parameter types are
// used.
- unsigned NumParams = std::min(Proto1->getNumArgs(), Proto2->getNumArgs());
+ llvm::SmallVector<QualType, 4> Args1;
+ if (CXXMethodDecl *Method1 = dyn_cast<CXXMethodDecl>(FD1))
+ MaybeAddImplicitObjectParameterType(S.Context, Method1, Args1);
+ Args1.insert(Args1.end(),
+ Proto1->arg_type_begin(), Proto1->arg_type_end());
+
+ llvm::SmallVector<QualType, 4> Args2;
+ if (CXXMethodDecl *Method2 = dyn_cast<CXXMethodDecl>(FD2))
+ MaybeAddImplicitObjectParameterType(S.Context, Method2, Args2);
+ Args2.insert(Args2.end(),
+ Proto2->arg_type_begin(), Proto2->arg_type_end());
+
+ unsigned NumParams = std::min(Args1.size(), Args2.size());
for (unsigned I = 0; I != NumParams; ++I)
if (DeduceTemplateArgumentsDuringPartialOrdering(S,
TemplateParams,
- Proto2->getArgType(I),
- Proto1->getArgType(I),
+ Args2[I],
+ Args1[I],
Info,
Deduced,
QualifierComparisons))
Added: cfe/branches/Apple/whitney/test/CXX/over/over.match/over.match.funcs/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CXX/over/over.match/over.match.funcs/p4.cpp?rev=119262&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/CXX/over/over.match/over.match.funcs/p4.cpp (added)
+++ cfe/branches/Apple/whitney/test/CXX/over/over.match/over.match.funcs/p4.cpp Mon Nov 15 15:46:51 2010
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR8130 {
+ struct A { };
+
+ template<class T> struct B {
+ template<class R> int &operator*(R&); // #1
+ };
+
+ template<class T, class R> float &operator*(T&, R&); // #2
+ void test() {
+ A a;
+ B<A> b;
+ int &ir = b * a; // calls #1a
+ }
+}
More information about the llvm-branch-commits
mailing list