]> granicus.if.org Git - clang/commitdiff
Implements -Wundeclared-selector for ObjC.
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 16 Jun 2009 16:25:00 +0000 (16:25 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 16 Jun 2009 16:25:00 +0000 (16:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73495 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExprObjC.cpp

index fa4f430591b28cfefed52b13402598466a5ff642..32be6f1caab95a51734804d306947a5b5a527261 100644 (file)
@@ -241,6 +241,9 @@ def error_property_implemented : Error<"property %0 is already implemented">;
 def warn_objc_property_attr_mutually_exclusive : Warning<
   "property attributes '%0' and '%1' are mutually exclusive">,
   InGroup<DiagGroup<"readonly-setter-attrs">>, DefaultIgnore;
+def warn_undeclared_selector : Warning<
+  "undeclared selector %0">,
+  InGroup<DiagGroup<"undeclared-selector">>, DefaultIgnore;
 
 // C++ declarations
 def err_static_assert_expression_is_not_constant : Error<
index b6cf9d8e738c2661c29166a9624dd5e7e7802100..71033b4eed1e1c54e25536bb565b9507c893b2f7 100644 (file)
@@ -130,6 +130,14 @@ Sema::ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
                                                    SourceLocation SelLoc,
                                                    SourceLocation LParenLoc,
                                                    SourceLocation RParenLoc) {
+  ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(Sel, 
+                             SourceRange(LParenLoc, RParenLoc));
+  if (!Method)
+    Method = LookupFactoryMethodInGlobalPool(Sel,
+                                          SourceRange(LParenLoc, RParenLoc));
+  if (!Method)
+    Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
+
   QualType Ty = Context.getObjCSelType();
   return new (Context) ObjCSelectorExpr(Ty, Sel, AtLoc, RParenLoc);
 }