[cfe-commits] r46633 - in /cfe/trunk: Sema/SemaExprObjC.cpp include/clang/Basic/DiagnosticKinds.def test/Parser/objc-forcollection-neg-2.m test/Parser/objc-forcollection-neg.m test/Sema/objc-bad-receiver-1.m

Chris Lattner sabre at nondot.org
Thu Jan 31 22:57:40 PST 2008


Author: lattner
Date: Fri Feb  1 00:57:39 2008
New Revision: 46633

URL: http://llvm.org/viewvc/llvm-project?rev=46633&view=rev
Log:
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__; });


Modified:
    cfe/trunk/Sema/SemaExprObjC.cpp
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/test/Parser/objc-forcollection-neg-2.m
    cfe/trunk/test/Parser/objc-forcollection-neg.m
    cfe/trunk/test/Sema/objc-bad-receiver-1.m

Modified: cfe/trunk/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExprObjC.cpp?rev=46633&r1=46632&r2=46633&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/Sema/SemaExprObjC.cpp Fri Feb  1 00:57:39 2008
@@ -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();

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=46633&r1=46632&r2=46633&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Fri Feb  1 00:57:39 2008
@@ -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

Modified: cfe/trunk/test/Parser/objc-forcollection-neg-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-forcollection-neg-2.m?rev=46633&r1=46632&r2=46633&view=diff

==============================================================================
--- cfe/trunk/test/Parser/objc-forcollection-neg-2.m (original)
+++ cfe/trunk/test/Parser/objc-forcollection-neg-2.m Fri Feb  1 00:57:39 2008
@@ -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;
 
 }

Modified: cfe/trunk/test/Parser/objc-forcollection-neg.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-forcollection-neg.m?rev=46633&r1=46632&r2=46633&view=diff

==============================================================================
--- cfe/trunk/test/Parser/objc-forcollection-neg.m (original)
+++ cfe/trunk/test/Parser/objc-forcollection-neg.m Fri Feb  1 00:57:39 2008
@@ -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

Modified: cfe/trunk/test/Sema/objc-bad-receiver-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-bad-receiver-1.m?rev=46633&r1=46632&r2=46633&view=diff

==============================================================================
--- cfe/trunk/test/Sema/objc-bad-receiver-1.m (original)
+++ cfe/trunk/test/Sema/objc-bad-receiver-1.m Fri Feb  1 00:57:39 2008
@@ -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'" }}
 }





More information about the cfe-commits mailing list