r196950 - Improve on an objc_bridge_related diagnostic.

Fariborz Jahanian fjahanian at apple.com
Tue Dec 10 11:22:41 PST 2013


Author: fjahanian
Date: Tue Dec 10 13:22:41 2013
New Revision: 196950

URL: http://llvm.org/viewvc/llvm-project?rev=196950&view=rev
Log:
Improve on an objc_bridge_related diagnostic.
// rdar://15499111

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/test/SemaObjC/arc-objcbridge-related-attribute.m
    cfe/trunk/test/SemaObjC/objcbridge-related-attribute.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=196950&r1=196949&r2=196950&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 10 13:22:41 2013
@@ -2472,8 +2472,9 @@ def err_objc_bridged_related_invalid_cla
 def err_objc_bridged_related_invalid_class_name : Error<
   "%0 must be name of an Objective-C class to be able to convert %1 to %2">;
  def err_objc_bridged_related_unknown_method : Error<
- "you can't convert %0 to %1, without using an existing "
- "%select{class|instance}2 method for this conversion">;
+ "%0 cannot be directly converted to %1; specify "
+ "%select{a class|an instance}2 method in objc_bridge_related attribute"
+ " for this conversion">;
 def err_objc_bridged_related_known_method : Error<
  "%0 must be explicitly converted to %1; use %select{%objcclass2|%objcinstance2}3 "
  "method for this conversion">;

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=196950&r1=196949&r2=196950&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Dec 10 13:22:41 2013
@@ -3405,7 +3405,7 @@ bool Sema::checkObjCBridgeRelatedCompone
     ClassMethod = RelatedClass->lookupMethod(Sel, false);
     if (!ClassMethod) {
       Diag(Loc, diag::err_objc_bridged_related_known_method)
-            << SrcType << DestType << Sel << 0;
+            << SrcType << DestType << Sel << false;
       Diag(TDNDecl->getLocStart(), diag::note_declared_at);
       return false;
     }
@@ -3417,7 +3417,7 @@ bool Sema::checkObjCBridgeRelatedCompone
     InstanceMethod = RelatedClass->lookupMethod(Sel, true);
     if (!InstanceMethod) {
       Diag(Loc, diag::err_objc_bridged_related_known_method)
-            << SrcType << DestType << Sel << 1;
+            << SrcType << DestType << Sel << true;
       Diag(TDNDecl->getLocStart(), diag::note_declared_at);
       return false;
     }
@@ -3454,13 +3454,13 @@ Sema::CheckObjCBridgeRelatedConversions(
       SourceLocation SrcExprEndLoc = PP.getLocForEndOfToken(SrcExpr->getLocEnd());
       // Provide a fixit: [RelatedClass ClassMethod SrcExpr]
       Diag(Loc, diag::err_objc_bridged_related_known_method)
-        << SrcType << DestType << ClassMethod->getSelector() << 0
+        << SrcType << DestType << ClassMethod->getSelector() << false
         << FixItHint::CreateInsertion(SrcExpr->getLocStart(), ExpressionString)
         << FixItHint::CreateInsertion(SrcExprEndLoc, "]");
     }
     else
       Diag(Loc, diag::err_objc_bridged_related_unknown_method)
-        << SrcType << DestType << 0;
+        << SrcType << DestType << false;
     Diag(RelatedClass->getLocStart(), diag::note_declared_at);
     Diag(TDNDecl->getLocStart(), diag::note_declared_at);
   }
@@ -3474,13 +3474,13 @@ Sema::CheckObjCBridgeRelatedConversions(
       SourceLocation SrcExprEndLoc = PP.getLocForEndOfToken(SrcExpr->getLocEnd());
       
       Diag(Loc, diag::err_objc_bridged_related_known_method)
-      << SrcType << DestType << InstanceMethod->getSelector() << 1
+      << SrcType << DestType << InstanceMethod->getSelector() << true
       << FixItHint::CreateInsertion(SrcExpr->getLocStart(), "[")
       << FixItHint::CreateInsertion(SrcExprEndLoc, ExpressionString);
     }
     else
       Diag(Loc, diag::err_objc_bridged_related_unknown_method)
-        << SrcType << DestType << 1;
+        << SrcType << DestType << true;
     Diag(RelatedClass->getLocStart(), diag::note_declared_at);
     Diag(TDNDecl->getLocStart(), diag::note_declared_at);
   }

Modified: cfe/trunk/test/SemaObjC/arc-objcbridge-related-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-objcbridge-related-attribute.m?rev=196950&r1=196949&r2=196950&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-objcbridge-related-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/arc-objcbridge-related-attribute.m Tue Dec 10 13:22:41 2013
@@ -25,9 +25,9 @@ NSColor * Test1(NSTextField *textField,
 }
 
 NSColor * Test2(NSTextField *textField, CGColorRef1 newColor) {
-  foo(newColor); // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *', without using an existing class method for this conversion}}
-  textField.backgroundColor = newColor;  // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *__strong', without using an existing class method for this conversion}}
-  return newColor;  // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *', without using an existing class method for this conversion}}
+  foo(newColor); // expected-error {{'CGColorRef1' (aka 'struct CGColor1 *') cannot be directly converted to 'NSColor *'; specify a class method in objc_bridge_related attribute for this conversion}}
+  textField.backgroundColor = newColor;  // expected-error {{'CGColorRef1' (aka 'struct CGColor1 *') cannot be directly converted to 'NSColor *__strong'; specify a class method in objc_bridge_related attribute for this conversion}}
+  return newColor;  // expected-error {{'CGColorRef1' (aka 'struct CGColor1 *') cannot be directly converted to 'NSColor *'; specify a class method in objc_bridge_related attribute for this conversion}}
 }
 
 CGColorRef Test3(NSTextField *textField, CGColorRef newColor) {
@@ -36,6 +36,6 @@ CGColorRef Test3(NSTextField *textField,
 }
 
 CGColorRef2 Test4(NSTextField *textField, CGColorRef2 newColor) {
-  newColor = textField.backgroundColor; // expected-error {{you can't convert 'NSColor *' to 'CGColorRef2' (aka 'struct CGColor2 *'), without using an existing instance method for this conversion}}
-  return textField.backgroundColor; // expected-error {{you can't convert 'NSColor *' to 'CGColorRef2' (aka 'struct CGColor2 *'), without using an existing instance method for this conversion}}
+  newColor = textField.backgroundColor; // expected-error {{'NSColor *' cannot be directly converted to 'CGColorRef2' (aka 'struct CGColor2 *'); specify an instance method in objc_bridge_related attribute for this conversion}}
+  return textField.backgroundColor; // expected-error {{'NSColor *' cannot be directly converted to 'CGColorRef2' (aka 'struct CGColor2 *'); specify an instance method in objc_bridge_related attribute for this conversion}}
 }

Modified: cfe/trunk/test/SemaObjC/objcbridge-related-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objcbridge-related-attribute.m?rev=196950&r1=196949&r2=196950&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objcbridge-related-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/objcbridge-related-attribute.m Tue Dec 10 13:22:41 2013
@@ -25,9 +25,9 @@ NSColor * Test1(NSTextField *textField,
 }
 
 NSColor * Test2(NSTextField *textField, CGColorRef1 newColor) {
-  foo(newColor); // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *', without using an existing class method for this conversion}}
-  textField.backgroundColor = newColor;  // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *', without using an existing class method for this conversion}}
-  return newColor;  // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *', without using an existing class method for this conversion}}
+  foo(newColor); // expected-error {{'CGColorRef1' (aka 'struct CGColor1 *') cannot be directly converted to 'NSColor *'; specify a class method in objc_bridge_related attribute for this conversion}}
+  textField.backgroundColor = newColor;  // expected-error {{'CGColorRef1' (aka 'struct CGColor1 *') cannot be directly converted to 'NSColor *'; specify a class method in objc_bridge_related attribute for this conversion}}
+  return newColor;  // expected-error {{'CGColorRef1' (aka 'struct CGColor1 *') cannot be directly converted to 'NSColor *'; specify a class method in objc_bridge_related attribute for this conversion}}
 }
 
 CGColorRef Test3(NSTextField *textField, CGColorRef newColor) {
@@ -36,6 +36,6 @@ CGColorRef Test3(NSTextField *textField,
 }
 
 CGColorRef2 Test4(NSTextField *textField, CGColorRef2 newColor) {
-  newColor = textField.backgroundColor; // expected-error {{you can't convert 'NSColor *' to 'CGColorRef2' (aka 'struct CGColor2 *'), without using an existing instance method for this conversion}}
-  return textField.backgroundColor; // expected-error {{you can't convert 'NSColor *' to 'CGColorRef2' (aka 'struct CGColor2 *'), without using an existing instance method for this conversion}}
+  newColor = textField.backgroundColor; // expected-error {{'NSColor *' cannot be directly converted to 'CGColorRef2' (aka 'struct CGColor2 *'); specify an instance method in objc_bridge_related attribute for this conversion}}
+  return textField.backgroundColor; // expected-error {{'NSColor *' cannot be directly converted to 'CGColorRef2' (aka 'struct CGColor2 *'); specify an instance method in objc_bridge_related attribute for this conversion}}
 }





More information about the cfe-commits mailing list