]> granicus.if.org Git - clang/commitdiff
tighten up some checks, don't allow sending a message to NSString****
authorChris Lattner <sabre@nondot.org>
Mon, 21 Jul 2008 05:54:02 +0000 (05:54 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 21 Jul 2008 05:54:02 +0000 (05:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53836 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprObjC.cpp

index 1067d1fb808a0fde85830a75a771110167c3a1f7..197bf372c4f4b62264a934ea4d3768c5ba31688e 100644 (file)
@@ -269,12 +269,13 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
           return true;
     }
   } else {
-    bool receiverIsQualId = isa<ObjCQualifiedIdType>(receiverType);
-    // FIXME (snaroff): checking in this code from Patrick. Needs to be
-    // revisited. how do we get the ClassDecl from the receiver expression?
-    if (!receiverIsQualId)
-      while (const PointerType *PTy = receiverType->getAsPointerType())
+    // We allow sending a message to a qualified ID ("id<foo>") to an interface
+    // directly ("[NSNumber foo]") and to a pointer to an interface (an object).
+    if (!isa<ObjCQualifiedIdType>(receiverType) &&
+        !isa<ObjCInterfaceType>(receiverType))
+      if (const PointerType *PTy = receiverType->getAsPointerType())
         receiverType = PTy->getPointeeType();
+      // else error, invalid receiver.
     
     ObjCInterfaceDecl* ClassDecl = 0;
     if (ObjCQualifiedIdType *QIT =