]> granicus.if.org Git - clang/commitdiff
Improve on an objc_bridge_related diagnostic.
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 10 Dec 2013 19:22:41 +0000 (19:22 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 10 Dec 2013 19:22:41 +0000 (19:22 +0000)
// rdar://15499111

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196950 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0823b5dcd6a1c7bee82884e7e5a0189f10f76575..23339fe7ef100f1492b7948eec4a587214d4d872 100644 (file)
@@ -2472,8 +2472,9 @@ def err_objc_bridged_related_invalid_class : Error<
 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">;
index c0f65ea84d75bccd3ce54a5913210782e448af9b..960700bd5cfc4a641ad9e3cc9e34c6f96993fb9d 100644 (file)
@@ -3405,7 +3405,7 @@ bool Sema::checkObjCBridgeRelatedComponents(SourceLocation Loc,
     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::checkObjCBridgeRelatedComponents(SourceLocation Loc,
     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 Loc,
       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 Loc,
       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);
   }
index d78ee4dc4ed330299bb8441717c46811508a6372..d92c636da8df9e71e12445f16e89854e9aeba1e4 100644 (file)
@@ -25,9 +25,9 @@ NSColor * Test1(NSTextField *textField, CGColorRef newColor) {
 }
 
 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, CGColorRef newColor) {
 }
 
 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}}
 }
index aa6db6f96ee0b438553547acd207c9cfaa3caa1d..a6d5e2eb97f24c7dd908f66538000ebc04c3aaa9 100644 (file)
@@ -25,9 +25,9 @@ NSColor * Test1(NSTextField *textField, CGColorRef newColor) {
 }
 
 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, CGColorRef newColor) {
 }
 
 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}}
 }