make some diagnostics more terse, update testcases.

Fix Sema::ActOnInstanceMessage to correctly do things in terms of canonical 
types, fixing bogus errors like:

NSDistantObject.m:10383:120: error: bad receiver type 'typeof((id<NSMutableCopying>)self)'
    id mess = ({ id __inv__ = ((void *)0); id __mb__ = _NSMessageBuilder((id <NSMutableCopying>)self, &__inv__); (void)[(__typeof__((id <NSMutableCopying>)self))__mb__ mutableCopyWithZone:((void *)0)]; if (!objc_collecting_enabled()) object_dispose(__mb__); __inv__; });



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46633 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExprObjC.cpp b/Sema/SemaExprObjC.cpp
index 0f53bbd..3e73930 100644
--- a/Sema/SemaExprObjC.cpp
+++ b/Sema/SemaExprObjC.cpp
@@ -197,18 +197,16 @@
   
   Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
   Expr *RExpr = static_cast<Expr *>(receiver);
-  QualType receiverType = RExpr->getType();
+  QualType receiverType = RExpr->getType().getCanonicalType();
   QualType returnType;
   ObjCMethodDecl *Method = 0;
   
-  // FIXME:
-  // FIXME: This code is not stripping off type qualifiers or typedefs!
-  // FIXME:
-  if (receiverType == Context.getObjCIdType() ||
-      receiverType == Context.getObjCClassType()) {
+  // FIXME: This code is not stripping off type qualifiers! Should it?
+  if (receiverType == Context.getObjCIdType().getCanonicalType() ||
+      receiverType == Context.getObjCClassType().getCanonicalType()) {
     Method = InstanceMethodPool[Sel].Method;
-	if (!Method)
-	  Method = FactoryMethodPool[Sel].Method;
+    if (!Method)
+      Method = FactoryMethodPool[Sel].Method;
     if (!Method) {
       Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
            SourceRange(lbrac, rbrac));
@@ -261,7 +259,8 @@
     else {
       ObjCInterfaceType *OCIReceiver =dyn_cast<ObjCInterfaceType>(receiverType);
       if (OCIReceiver == 0) {
-        Diag(lbrac, diag::error_bad_receiver_type, receiverType.getAsString());
+        Diag(lbrac, diag::error_bad_receiver_type,
+             RExpr->getType().getAsString());
         return true;
       }
       ClassDecl = OCIReceiver->getDecl();
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 02d3159..489575c 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -477,15 +477,15 @@
 DIAG(warn_method_not_found_in_protocol, WARNING,
      "method '%0%1' not found in protocol (return type defaults to 'id')")
 DIAG(err_collection_expr_type, ERROR,
-     "collection expression is not of valid object type (its type is '%0')")
+     "collection expression type ('%0') is not a valid object")
 DIAG(err_selector_element_type, ERROR,
-     "selector element is not of valid object type (its type is '%0')")
+     "selector element type ('%0') is not a valid object")
 DIAG(err_toomany_element_decls, ERROR,
      "Only one element declaration is allowed")
 DIAG(warn_expected_implementation, WARNING,
      "@end must appear in an @implementation context")
 DIAG(error_bad_receiver_type, ERROR,
-     "bad receiver type (its type is '%0')")
+     "bad receiver type '%0'")
 
 //===----------------------------------------------------------------------===//
 // Semantic Analysis
diff --git a/test/Parser/objc-forcollection-neg-2.m b/test/Parser/objc-forcollection-neg-2.m
index ba870aa..bde7d22 100644
--- a/test/Parser/objc-forcollection-neg-2.m
+++ b/test/Parser/objc-forcollection-neg-2.m
@@ -30,7 +30,7 @@
         for (id el in self) 
            ++i;
 	MyList<P> ***p;
-        for (p in self)  // expected-error {{selector element is not of valid object type (its type is 'MyList<P> ***')}}
+        for (p in self)  // expected-error {{selector element type ('MyList<P> ***') is not a valid object type}}
            ++i;
 
 }
diff --git a/test/Parser/objc-forcollection-neg.m b/test/Parser/objc-forcollection-neg.m
index 4137e63..8e1c05a 100644
--- a/test/Parser/objc-forcollection-neg.m
+++ b/test/Parser/objc-forcollection-neg.m
@@ -24,13 +24,13 @@
 - (void)compilerTestAgainst {
 
         int i=0;
-        for (int * elem in elem) // expected-error {{selector element is not of valid object type (its type is 'int *')}} \
-				    expected-error {{collection expression is not of valid object type (its type is 'int *')}}
+        for (int * elem in elem) // expected-error {{selector element type ('int *') is not a valid object}} \
+				    expected-error {{collection expression type ('int *') is not a valid object}}
            ++i;
         for (i in elem)  // expected-error {{use of undeclared identifier 'elem'}} \
-			    expected-error {{selector element is not of valid object type (its type is 'int')}}
+			    expected-error {{selector element type ('int') is not a valid object}}
            ++i;
-        for (id se in i) // expected-error {{collection expression is not of valid object type (its type is 'int')}} 
+        for (id se in i) // expected-error {{collection expression type ('int') is not a valid object}} 
            ++i;
 }
 @end
diff --git a/test/Sema/objc-bad-receiver-1.m b/test/Sema/objc-bad-receiver-1.m
index b181908..8376a5c 100644
--- a/test/Sema/objc-bad-receiver-1.m
+++ b/test/Sema/objc-bad-receiver-1.m
@@ -5,5 +5,5 @@
 @end
 
 void __raiseExc1() {
- [objc_lookUpClass("NSString") retain]; // expected-error {{ "bad receiver type (its type is 'int')" }}
+ [objc_lookUpClass("NSString") retain]; // expected-error {{ "bad receiver type 'int'" }}
 }