[PATCH] D44916: [Sema] Avoid crash for category implementation without interface

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 27 12:02:19 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL328654: [Sema] Avoid crash for category implementation without interface (authored by smeenai, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44916

Files:
  cfe/trunk/lib/Sema/SemaExprMember.cpp
  cfe/trunk/test/SemaObjC/undef-class-property-error.m


Index: cfe/trunk/test/SemaObjC/undef-class-property-error.m
===================================================================
--- cfe/trunk/test/SemaObjC/undef-class-property-error.m
+++ cfe/trunk/test/SemaObjC/undef-class-property-error.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ at implementation I (C) // expected-error {{cannot find interface declaration for 'I'}}
+
++ (void)f {
+  self.m; // expected-error {{member reference base type 'Class' is not a structure or union}}
+}
+
+ at end
Index: cfe/trunk/lib/Sema/SemaExprMember.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp
@@ -1568,6 +1568,9 @@
       // Also must look for a getter name which uses property syntax.
       Selector Sel = S.PP.getSelectorTable().getNullarySelector(Member);
       ObjCInterfaceDecl *IFace = MD->getClassInterface();
+      if (!IFace)
+        goto fail;
+
       ObjCMethodDecl *Getter;
       if ((Getter = IFace->lookupClassMethod(Sel))) {
         // Check the use of this method.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44916.139967.patch
Type: text/x-patch
Size: 1106 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180327/83e438e3/attachment.bin>


More information about the cfe-commits mailing list