r181847 - Objective-C [diagnostics] [QOI], when method is not
Jordan Rose
jordan_rose at apple.com
Tue May 14 16:47:29 PDT 2013
Comments inline...
On May 14, 2013, at 16:24 , Fariborz Jahanian <fjahanian at apple.com> wrote:
> Author: fjahanian
> Date: Tue May 14 18:24:17 2013
> New Revision: 181847
>
> URL: http://llvm.org/viewvc/llvm-project?rev=181847&view=rev
> Log:
> Objective-C [diagnostics] [QOI], when method is not
> found for a receiver, note where receiver class
> is declaraed (this is most common when receiver is a forward
> class). // rdar://3258331
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaExprObjC.cpp
> cfe/trunk/test/Analysis/inlining/DynDispatchBifurcate.m
> cfe/trunk/test/Analysis/rdar-6540084.m
> cfe/trunk/test/Modules/objc-categories.m
> cfe/trunk/test/PCH/chain-categories2.m
> cfe/trunk/test/SemaObjC/call-super-2.m
> cfe/trunk/test/SemaObjC/compare-qualified-id.m
> cfe/trunk/test/SemaObjC/conditional-expr.m
> cfe/trunk/test/SemaObjC/error-outof-scope-property-use.m
> cfe/trunk/test/SemaObjC/instancetype.m
> cfe/trunk/test/SemaObjC/message.m
> cfe/trunk/test/SemaObjC/method-not-defined.m
> cfe/trunk/test/SemaObjC/missing-atend-metadata.m
> cfe/trunk/test/SemaObjC/property-5.m
> cfe/trunk/test/SemaObjC/protocol-id-test-1.m
> cfe/trunk/test/SemaObjCXX/instancetype.mm
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=181847&r1=181846&r2=181847&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 14 18:24:17 2013
> @@ -499,6 +499,8 @@ def note_while_in_implementation : Note<
> "detected while default synthesizing properties in class implementation">;
> def note_class_declared : Note<
> "class is declared here">;
> +def note_receiver_class_declared : Note<
> + "receiver is object of the class that is declared here">;
Bikeshedding on the diagnostic a little bit: "receiver is instance of class declared here" or even "receiver interface declared here". "object of the class" sounds very strange to me.
> def note_receiver_is_id : Note<
> "receiver is treated with 'id' type for purpose of method lookup">;
> def note_suppressed_class_declare : Note<
>
> Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=181847&r1=181846&r2=181847&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue May 14 18:24:17 2013
> @@ -1221,10 +1221,19 @@ bool Sema::CheckMessageArgumentTypes(Qua
> else
> DiagID = isClassMessage ? diag::warn_class_method_not_found
> : diag::warn_inst_method_not_found;
> - if (!getLangOpts().DebuggerSupport)
> + if (!getLangOpts().DebuggerSupport) {
> Diag(SelLoc, DiagID)
> << Sel << isClassMessage << SourceRange(SelectorLocs.front(),
> SelectorLocs.back());
> + // Find the class to which we are sending this message.
> + if (ReceiverType->isObjCObjectPointerType()) {
> + QualType ClassType =
> + ReceiverType->getAs<ObjCObjectPointerType>()->getPointeeType();
> + if (const ObjCObjectType *ClassTPtr = ClassType->getAs<ObjCObjectType>())
> + if (ObjCInterfaceDecl *Class = ClassTPtr->getInterface())
> + Diag(Class->getLocation(), diag::note_receiver_class_declared);
> + }
> + }
You don't really need to double the ifs here. Just use ReceiverType->getAs<ObjCObjectPointerType>() and then ObjCObjectPointerType::getInterfaceDecl().
> // In debuggers, we want to use __unknown_anytype for these
> // results so that clients can cast them.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130514/264bab8d/attachment.html>
More information about the cfe-commits
mailing list