[cfe-commits] r70989 - in /cfe/branches/Apple/Dib: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprObjC.cpp test/SemaObjC/inst-method-lookup-in-root.m

Mike Stump mrs at apple.com
Tue May 5 11:43:11 PDT 2009


Author: mrs
Date: Tue May  5 13:43:03 2009
New Revision: 70989

URL: http://llvm.org/viewvc/llvm-project?rev=70989&view=rev
Log:
Merge in 70987:

Issue a warning in odd case of instance method used
in a 'Class' receiver which is not a root instance
method.

Added:
    cfe/branches/Apple/Dib/test/SemaObjC/inst-method-lookup-in-root.m
      - copied unchanged from r70987, cfe/trunk/test/SemaObjC/inst-method-lookup-in-root.m
Modified:
    cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp

Modified: cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td?rev=70989&r1=70988&r2=70989&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td Tue May  5 13:43:03 2009
@@ -1096,6 +1096,8 @@
 
 
 // Obj-c expressions
+def warn_root_inst_method_not_found : Warning<
+  "instance method %0 is being used on 'Class' which is not in the root class">;
 def warn_class_method_not_found : Warning<
   "method %objcclass0 not found (return type defaults to 'id')">;
 def warn_inst_method_not_found : Warning<

Modified: cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp?rev=70989&r1=70988&r2=70989&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp Tue May  5 13:43:03 2009
@@ -529,8 +529,17 @@
       if (!isSelfExpr(RExpr)) {
         Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac,rbrac));
         if (!Method) {
+          // If no class (factory) method was found, check if an _instance_
+          // method of the same name exists in the root class only.
           Method = LookupInstanceMethodInGlobalPool(
                                    Sel, SourceRange(lbrac,rbrac));
+          if (Method)
+              if (const ObjCInterfaceDecl *ID =
+                dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext())) {
+              if (ID->getSuperClass())
+                Diag(lbrac, diag::warn_root_inst_method_not_found)
+                  << Sel << SourceRange(lbrac, rbrac);
+            }
         }
       }
     }





More information about the cfe-commits mailing list