[cfe-commits] r95334 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/FixIt/typo-crash.m test/FixIt/typo.m

Douglas Gregor dgregor at apple.com
Thu Feb 4 15:42:48 PST 2010


Author: dgregor
Date: Thu Feb  4 17:42:48 2010
New Revision: 95334

URL: http://llvm.org/viewvc/llvm-project?rev=95334&view=rev
Log:
Fix a crash with ill-formed code within a method in an ill-formed
category implementation, which showed up during (attempted) typo
correction. Fixes <rdar://problem/7605289>.

Added:
    cfe/trunk/test/FixIt/typo-crash.m
Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/test/FixIt/typo.m

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=95334&r1=95333&r2=95334&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Feb  4 17:42:48 2010
@@ -2027,6 +2027,9 @@
                                bool InBaseClass,
                                VisibleDeclConsumer &Consumer,
                                VisibleDeclsRecord &Visited) {
+  if (!Ctx)
+    return;
+
   // Make sure we don't visit the same context twice.
   if (Visited.visitedContext(Ctx->getPrimaryContext()))
     return;
@@ -2183,9 +2186,9 @@
           // For instance methods, look for ivars in the method's interface.
           LookupResult IvarResult(Result.getSema(), Result.getLookupName(),
                                   Result.getNameLoc(), Sema::LookupMemberName);
-          ObjCInterfaceDecl *IFace = Method->getClassInterface();
-          LookupVisibleDecls(IFace, IvarResult, /*QualifiedNameLookup=*/false, 
-                             /*InBaseClass=*/false, Consumer, Visited);
+          if (ObjCInterfaceDecl *IFace = Method->getClassInterface())
+            LookupVisibleDecls(IFace, IvarResult, /*QualifiedNameLookup=*/false, 
+                               /*InBaseClass=*/false, Consumer, Visited);
         }
 
         // We've already performed all of the name lookup that we need

Added: cfe/trunk/test/FixIt/typo-crash.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo-crash.m?rev=95334&view=auto

==============================================================================
--- cfe/trunk/test/FixIt/typo-crash.m (added)
+++ cfe/trunk/test/FixIt/typo-crash.m Thu Feb  4 17:42:48 2010
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/7605289>
+ at implementation Unknown (Blarg) // expected-error{{cannot find interface declaration for 'Unknown'}}
+- (int)method { return ivar; } // expected-error{{use of undeclared identifier 'ivar'}}
+ at end

Modified: cfe/trunk/test/FixIt/typo.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo.m?rev=95334&r1=95333&r2=95334&view=diff

==============================================================================
--- cfe/trunk/test/FixIt/typo.m (original)
+++ cfe/trunk/test/FixIt/typo.m Thu Feb  4 17:42:48 2010
@@ -86,5 +86,5 @@
 - (int)send:(void*)buffer bytes:(int)bytes;
 @end
 
- at interface IPv8 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}}
+ at interface IPv6 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}}
 @end





More information about the cfe-commits mailing list