[cfe-commits] r103706 - in /cfe/trunk: lib/Sema/SemaTemplateDeduction.cpp test/SemaObjCXX/deduction.mm
John McCall
rjmccall at apple.com
Thu May 13 00:48:05 PDT 2010
Author: rjmccall
Date: Thu May 13 02:48:05 2010
New Revision: 103706
URL: http://llvm.org/viewvc/llvm-project?rev=103706&view=rev
Log:
When performing template argument deduction, match Objective C pointers
against pointer patterns.
Added:
cfe/trunk/test/SemaObjCXX/deduction.mm
Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=103706&r1=103705&r2=103706&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu May 13 02:48:05 2010
@@ -482,14 +482,20 @@
// T *
case Type::Pointer: {
- const PointerType *PointerArg = Arg->getAs<PointerType>();
- if (!PointerArg)
+ QualType PointeeType;
+ if (const PointerType *PointerArg = Arg->getAs<PointerType>()) {
+ PointeeType = PointerArg->getPointeeType();
+ } else if (const ObjCObjectPointerType *PointerArg
+ = Arg->getAs<ObjCObjectPointerType>()) {
+ PointeeType = PointerArg->getPointeeType();
+ } else {
return Sema::TDK_NonDeducedMismatch;
+ }
unsigned SubTDF = TDF & (TDF_IgnoreQualifiers | TDF_DerivedClass);
return DeduceTemplateArguments(S, TemplateParams,
cast<PointerType>(Param)->getPointeeType(),
- PointerArg->getPointeeType(),
+ PointeeType,
Info, Deduced, SubTDF);
}
Added: cfe/trunk/test/SemaObjCXX/deduction.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/deduction.mm?rev=103706&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/deduction.mm (added)
+++ cfe/trunk/test/SemaObjCXX/deduction.mm Thu May 13 02:48:05 2010
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ at class NSString;
+
+// Reduced from WebKit.
+namespace test0 {
+ template <typename T> struct RemovePointer {
+ typedef T Type;
+ };
+
+ template <typename T> struct RemovePointer<T*> {
+ typedef T Type;
+ };
+
+ template <typename T> struct RetainPtr {
+ typedef typename RemovePointer<T>::Type ValueType;
+ typedef ValueType* PtrType;
+ RetainPtr(PtrType ptr);
+ };
+
+ void test(NSString *S) {
+ RetainPtr<NSString*> ptr(S);
+ }
+}
More information about the cfe-commits
mailing list