[cfe-commits] r135593 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOverload.cpp test/SemaObjCXX/arc-overloading.mm

Fariborz Jahanian fjahanian at apple.com
Wed Jul 20 10:14:09 PDT 2011


Author: fjahanian
Date: Wed Jul 20 12:14:09 2011
New Revision: 135593

URL: http://llvm.org/viewvc/llvm-project?rev=135593&view=rev
Log:
arc-objc++: Issue an arc specific diagnostic when overload resolution
fails because of lifetime differences of parameter and argument type.
// rdar://9790531

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaObjCXX/arc-overloading.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=135593&r1=135592&r2=135593&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 20 12:14:09 2011
@@ -1595,6 +1595,17 @@
     "%select{%ordinal5 argument|object argument}4; "
     "%select{|dereference the argument with *|"
     "take the address of the argument with &}6">;
+def note_ovl_candidate_bad_arc_conv : Note<"candidate "
+    "%select{function|function|constructor|"
+    "function |function |constructor |"
+    "constructor (the implicit default constructor)|"
+    "constructor (the implicit copy constructor)|"
+    "constructor (the implicit move constructor)|"
+    "function (the implicit copy assignment operator)|"
+    "function (the implicit move assignment operator)|"
+    "constructor (inherited)}0%1"
+    " not viable: cannot implicitly convert argument of type %2 to %3 for "
+    "%select{%ordinal5 argument|object argument}4 under ARC">;
 def note_ovl_candidate_bad_addrspace : Note<"candidate "
     "%select{function|function|constructor|"
     "function |function |constructor |"

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=135593&r1=135592&r2=135593&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jul 20 12:14:09 2011
@@ -6981,8 +6981,21 @@
     return;
   }
 
+  if (isa<ObjCObjectPointerType>(CFromTy) &&
+      isa<PointerType>(CToTy)) {
+      Qualifiers FromQs = CFromTy.getQualifiers();
+      Qualifiers ToQs = CToTy.getQualifiers();
+      if (FromQs.getObjCLifetime() != ToQs.getObjCLifetime()) {
+        S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
+        << (unsigned) FnKind << FnDesc
+        << (FromExpr ? FromExpr->getSourceRange() : SourceRange())
+        << FromTy << ToTy << (unsigned) isObjectArgument << I+1;
+        MaybeEmitInheritedConstructorNote(S, Fn);
+        return;
+      }
+  }
+  
   // TODO: specialize more based on the kind of mismatch
-
   // Emit the generic diagnostic and, optionally, add the hints to it.
   PartialDiagnostic FDiag = S.PDiag(diag::note_ovl_candidate_bad_conv);
   FDiag << (unsigned) FnKind << FnDesc

Modified: cfe/trunk/test/SemaObjCXX/arc-overloading.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-overloading.mm?rev=135593&r1=135592&r2=135593&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/arc-overloading.mm (original)
+++ cfe/trunk/test/SemaObjCXX/arc-overloading.mm Wed Jul 20 12:14:09 2011
@@ -173,3 +173,22 @@
   const __autoreleasing id& ar3 = unsafe_unretained_a;
   const __autoreleasing id& ar4 = weak_a;
 }
+
+// rdar://9790531
+void f9790531(void *inClientData); // expected-note {{candidate function not viable: cannot implicitly convert argument of type 'MixerEQGraphTestDelegate *const __strong' to 'void *' for 1st argument under ARC}}
+void f9790531_1(struct S*inClientData); // expected-note {{candidate function not viable}}
+void f9790531_2(char * inClientData); // expected-note {{candidate function not viable}}
+
+ at class UIApplication;
+
+ at interface MixerEQGraphTestDelegate
+- (void)applicationDidFinishLaunching;
+ at end
+
+ at implementation MixerEQGraphTestDelegate
+- (void)applicationDidFinishLaunching {
+    f9790531(self); // expected-error {{no matching function for call to 'f9790531'}}
+    f9790531_1(self); // expected-error {{no matching function for call to 'f9790531_1'}}
+    f9790531_2(self); // expected-error {{no matching function for call to 'f9790531_2'}}
+}
+ at end





More information about the cfe-commits mailing list